Try the javascript implementation of ipfs
This commit is contained in:
parent
387a74371e
commit
b259230133
|
@ -33,13 +33,16 @@ VARIANTS='mesh'
|
||||||
IPFS_GO_REPO="https://github.com/ipfs/go-ipfs"
|
IPFS_GO_REPO="https://github.com/ipfs/go-ipfs"
|
||||||
IPFS_COMMIT='20b06a4cbce8884f5b194da6e98cb11f2c77f166'
|
IPFS_COMMIT='20b06a4cbce8884f5b194da6e98cb11f2c77f166'
|
||||||
IPFS_PORT=4001
|
IPFS_PORT=4001
|
||||||
|
IPFS_NODE_VERSION='6.2.2'
|
||||||
|
IPFS_JS_VERSION='0.14.3'
|
||||||
|
IPFS_JS_RONIN_VERSION='0.3.11'
|
||||||
|
|
||||||
function reconfigure_ipfs {
|
function reconfigure_ipfs {
|
||||||
echo -n ''
|
echo -n ''
|
||||||
}
|
}
|
||||||
|
|
||||||
function upgrade_ipfs {
|
function upgrade_ipfs_go {
|
||||||
if ! grep -Fxq "install_ipfs" $COMPLETION_FILE; then
|
if ! grep -Fxq "install_ipfs_go" $COMPLETION_FILE; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -50,6 +53,23 @@ function upgrade_ipfs {
|
||||||
set_repo_commit $GOPATH/src/github.com/ipfs/go-ipfs "ipfs commit" "$IPFS_COMMIT" $IPFS_REPO
|
set_repo_commit $GOPATH/src/github.com/ipfs/go-ipfs "ipfs commit" "$IPFS_COMMIT" $IPFS_REPO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function upgrade_ipfs_js {
|
||||||
|
if ! grep -Fxq "install_ipfs_js" $COMPLETION_FILE; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
npm cache clean -f
|
||||||
|
npm install -g n
|
||||||
|
n ${IPFS_NODE_VERSION}
|
||||||
|
npm install ronin@${IPFS_JS_RONIN_VERSION} --global
|
||||||
|
npm install ipfs@${IPFS_JS_VERSION} --global
|
||||||
|
}
|
||||||
|
|
||||||
|
function upgrade_ipfs {
|
||||||
|
upgrade_ipfs_js
|
||||||
|
upgrade_ipfs_go
|
||||||
|
}
|
||||||
|
|
||||||
function backup_local_ipfs {
|
function backup_local_ipfs {
|
||||||
if ! grep -q "Admin user" $COMPLETION_FILE; then
|
if ! grep -q "Admin user" $COMPLETION_FILE; then
|
||||||
return
|
return
|
||||||
|
@ -121,8 +141,8 @@ function restore_remote_ipfs {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function remove_ipfs {
|
function remove_ipfs_go {
|
||||||
if ! grep -Fxq "install_ipfs" $COMPLETION_FILE; then
|
if ! grep -Fxq "install_ipfs_go" $COMPLETION_FILE; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
function_check select_go_version
|
function_check select_go_version
|
||||||
|
@ -136,10 +156,35 @@ function remove_ipfs {
|
||||||
function_check save_firewall_settings
|
function_check save_firewall_settings
|
||||||
save_firewall_settings
|
save_firewall_settings
|
||||||
sed -i '/install_ipfs/d' $COMPLETION_FILE
|
sed -i '/install_ipfs/d' $COMPLETION_FILE
|
||||||
sed -i '/ipfs /d' $COMPLETION_FILE
|
sed -i '/ipfs/d' $COMPLETION_FILE
|
||||||
sed -i '/configure_firewall_for_ipfs/d' $COMPLETION_FILE
|
sed -i '/configure_firewall_for_ipfs/d' $COMPLETION_FILE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function remove_ipfs_js {
|
||||||
|
if ! grep -Fxq "install_ipfs_js" $COMPLETION_FILE; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
systemctl stop ipfs
|
||||||
|
systemctl disable ipfs
|
||||||
|
rm /etc/systemd/system/ipfs.service
|
||||||
|
systemctl daemon-reload
|
||||||
|
|
||||||
|
npm uninstall ipfs --global
|
||||||
|
npm uninstall ronin --global
|
||||||
|
|
||||||
|
iptables -D INPUT -p tcp --dport $IPFS_PORT -j ACCEPT
|
||||||
|
function_check save_firewall_settings
|
||||||
|
save_firewall_settings
|
||||||
|
sed -i '/install_ipfs/d' $COMPLETION_FILE
|
||||||
|
sed -i '/ipfs/d' $COMPLETION_FILE
|
||||||
|
sed -i '/configure_firewall_for_ipfs/d' $COMPLETION_FILE
|
||||||
|
}
|
||||||
|
|
||||||
|
function remove_ipfs {
|
||||||
|
remove_ipfs_js
|
||||||
|
remove_ipfs_go
|
||||||
|
}
|
||||||
|
|
||||||
function configure_firewall_for_ipfs {
|
function configure_firewall_for_ipfs {
|
||||||
if grep -Fxq "configure_firewall_for_ipfs" $COMPLETION_FILE; then
|
if grep -Fxq "configure_firewall_for_ipfs" $COMPLETION_FILE; then
|
||||||
return
|
return
|
||||||
|
@ -155,8 +200,93 @@ function configure_firewall_for_ipfs {
|
||||||
echo 'configure_firewall_for_ipfs' >> $COMPLETION_FILE
|
echo 'configure_firewall_for_ipfs' >> $COMPLETION_FILE
|
||||||
}
|
}
|
||||||
|
|
||||||
function install_ipfs {
|
function install_ipfs_js {
|
||||||
if grep -Fxq "install_ipfs" $COMPLETION_FILE; then
|
if grep -Fxq "install_ipfs_js" $COMPLETION_FILE; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
apt-get -y install npm libpam0g-dev fuse
|
||||||
|
|
||||||
|
npm cache clean -f
|
||||||
|
npm install -g n
|
||||||
|
n ${IPFS_NODE_VERSION}
|
||||||
|
npm install ronin@${IPFS_JS_RONIN_VERSION} --global
|
||||||
|
npm install ipfs@${IPFS_JS_VERSION} --global
|
||||||
|
|
||||||
|
IPFS_PATH=/usr/local/bin
|
||||||
|
|
||||||
|
# initialise
|
||||||
|
su -c "$IPFS_PATH/ipfs init -b 4096" - $MY_USERNAME
|
||||||
|
if [ ! -d /home/$MY_USERNAME/.ipfs ]; then
|
||||||
|
echo "IPFS could not be initialised for user $MY_USERNAME"
|
||||||
|
exit 7358
|
||||||
|
fi
|
||||||
|
|
||||||
|
# directories to mount to
|
||||||
|
if [ ! -d /ipfs ]; then
|
||||||
|
mkdir /ipfs
|
||||||
|
mkdir /ipns
|
||||||
|
chown $MY_USERNAME:$MY_USERNAME /ipfs
|
||||||
|
chown $MY_USERNAME:$MY_USERNAME /ipns
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f /etc/fuse.conf ]; then
|
||||||
|
chown $MY_USERNAME:$MY_USERNAME /etc/fuse.conf
|
||||||
|
fi
|
||||||
|
if [ -f /dev/fuse ]; then
|
||||||
|
chown $MY_USERNAME:$MY_USERNAME /dev/fuse
|
||||||
|
fi
|
||||||
|
|
||||||
|
IPFS_DAEMON_NAME=ipfs
|
||||||
|
IPFS_DAEMON_FILE=/etc/systemd/system/${IPFS_DAEMON_NAME}.service
|
||||||
|
echo '[Unit]' > $IPFS_DAEMON_FILE
|
||||||
|
echo 'Description=IPFS javascript daemon' >> $IPFS_DAEMON_FILE
|
||||||
|
echo 'After=syslog.target' >> $IPFS_DAEMON_FILE
|
||||||
|
echo 'After=network.target' >> $IPFS_DAEMON_FILE
|
||||||
|
echo '' >> $IPFS_DAEMON_FILE
|
||||||
|
echo '[Service]' >> $IPFS_DAEMON_FILE
|
||||||
|
echo 'Type=simple' >> $IPFS_DAEMON_FILE
|
||||||
|
echo "User=$MY_USERNAME" >> $IPFS_DAEMON_FILE
|
||||||
|
echo "Group=$MY_USERNAME" >> $IPFS_DAEMON_FILE
|
||||||
|
echo "WorkingDirectory=/home/$MY_USERNAME" >> $IPFS_DAEMON_FILE
|
||||||
|
echo "ExecStart=${IPFS_PATH}/jsipfs daemon --mount" >> $IPFS_DAEMON_FILE
|
||||||
|
echo 'Restart=on-failure' >> $IPFS_DAEMON_FILE
|
||||||
|
echo "Environment=\"USER=$MY_USERNAME\" \"HOME=/home/$MY_USERNAME\"" >> $IPFS_DAEMON_FILE
|
||||||
|
echo '' >> $IPFS_DAEMON_FILE
|
||||||
|
echo '[Install]' >> $IPFS_DAEMON_FILE
|
||||||
|
echo 'WantedBy=multi-user.target' >> $IPFS_DAEMON_FILE
|
||||||
|
|
||||||
|
systemctl daemon-reload
|
||||||
|
systemctl enable ${IPFS_DAEMON_NAME}
|
||||||
|
systemctl restart ${IPFS_DAEMON_NAME}
|
||||||
|
|
||||||
|
if [ -d /etc/avahi ]; then
|
||||||
|
su -c "echo $($IPFS_PATH/ipfs id | grep '\"ID\":' | awk -F '\"' '{print $4}') > /tmp/ipfsid" - $MY_USERNAME
|
||||||
|
if [ ! -f /tmp/ipfsid ]; then
|
||||||
|
echo 'No IPFS identity was created'
|
||||||
|
exit 37895
|
||||||
|
fi
|
||||||
|
IPFS_PEER_ID=$(cat /tmp/ipfsid)
|
||||||
|
if [ ${#IPFS_PEER_ID} -lt 10 ]; then
|
||||||
|
echo 'Invalid IPFS peer ID'
|
||||||
|
echo "$IPFS_PEER_ID"
|
||||||
|
exit 74782
|
||||||
|
fi
|
||||||
|
# Add an avahi service
|
||||||
|
function_check create_avahi_service
|
||||||
|
create_avahi_service ipfs "ipfs" udp $IPFS_PORT "$IPFS_PEER_ID"
|
||||||
|
rm /tmp/ipfsid
|
||||||
|
fi
|
||||||
|
|
||||||
|
function_check configure_firewall_for_ipfs
|
||||||
|
configure_firewall_for_ipfs
|
||||||
|
|
||||||
|
echo 'install_ipfs_js' >> $COMPLETION_FILE
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function install_ipfs_go {
|
||||||
|
if grep -Fxq "install_ipfs_go" $COMPLETION_FILE; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -240,7 +370,7 @@ function install_ipfs {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo '[Unit]' > /etc/systemd/system/ipfs.service
|
echo '[Unit]' > /etc/systemd/system/ipfs.service
|
||||||
echo 'Description=IPFS daemon' >> /etc/systemd/system/ipfs.service
|
echo 'Description=IPFS go daemon' >> /etc/systemd/system/ipfs.service
|
||||||
echo 'After=syslog.target' >> /etc/systemd/system/ipfs.service
|
echo 'After=syslog.target' >> /etc/systemd/system/ipfs.service
|
||||||
echo 'After=network.target' >> /etc/systemd/system/ipfs.service
|
echo 'After=network.target' >> /etc/systemd/system/ipfs.service
|
||||||
echo '' >> /etc/systemd/system/ipfs.service
|
echo '' >> /etc/systemd/system/ipfs.service
|
||||||
|
@ -281,5 +411,10 @@ function install_ipfs {
|
||||||
function_check configure_firewall_for_ipfs
|
function_check configure_firewall_for_ipfs
|
||||||
configure_firewall_for_ipfs
|
configure_firewall_for_ipfs
|
||||||
|
|
||||||
echo 'install_ipfs' >> $COMPLETION_FILE
|
echo 'install_ipfs_go' >> $COMPLETION_FILE
|
||||||
|
}
|
||||||
|
|
||||||
|
function install_ipfs {
|
||||||
|
install_ipfs_js
|
||||||
|
#install_ipfs_go
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue