ipfs.service template inside EOF (no more curl for it)

This commit is contained in:
qo-op 2020-05-17 12:04:05 +02:00
parent e74a76bfc8
commit bb6f39dbf4
1 changed files with 20 additions and 6 deletions

View File

@ -26,6 +26,7 @@ fi
echo -e "${c_yellow}Onboarding IPFS...$c_"
# CHECK node IP isLAN?
myIP=$(hostname -I | awk '{print $1}')
isLAN=$(echo $myIP | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/")
@ -34,20 +35,33 @@ MACHINE_TYPE=`uname -m`
[ ${MACHINE_TYPE:0:3} == 'arm' ] && curl -s https://dist.ipfs.io/ipfs-update/v1.5.2/ipfs-update_v1.5.2_linux-arm.tar.gz -o $MY_PATH/ipfs-update.tar.gz || err+="Download ipfs-update"
[ ! -f $MY_PATH/ipfs-update.tar.gz ] && echo "Your $MACHINE_TYPE is not supported yet... Please add an issue." && exit 1
echo "INSTALL ipfs-update"
echo "INSTALL ipfs-update >>>>>>>>>>>>>>>>>>>>>>>>>>"
sudo tar -xvzf $MY_PATH/ipfs-update.tar.gz -C /usr/src/ || err+="Untar ipfs-update"
rm $MY_PATH/ipfs-update.tar.gz
cd /usr/src/ipfs-update/
sudo ./install.sh || err+="Install ipfs-update"
cd $MY_PATH
echo "INSTALL latest ipfs"
echo "INSTALL latest ipfs >>>>>>>>>>>>>>>>>>>>>>>>>>"
sudo ipfs-update install latest || err+="Install IPFS"
echo "CREATE SYSTEMD ipfs SERVICE"
curl -s https://git.p2p.legal/axiom-team/astroport/raw/master/.install/templates/ipfs/ipfs.service -o /tmp/ipfs.service
echo "CREATE SYSTEMD ipfs SERVICE >>>>>>>>>>>>>>>>>>"
cat > /tmp/ipfs.service <<EOF
[Unit]
Description=IPFS daemon
After=network.target
[Service]
User=_USER_
ExecStart=/usr/local/bin/ipfs daemon --enable-pubsub-experiment --enable-namesys-pubsub --routing=dhtclient --enable-gc
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOF
sudo cp -f /tmp/ipfs.service /etc/systemd/system/
sudo sed -i "s/_USER/$USER/g" /etc/systemd/system/ipfs.service
sudo sed -i "s/_USER_/$USER/g" /etc/systemd/system/ipfs.service
sudo systemctl daemon-reload || err+="Restart IPFS"
sudo systemctl enable ipfs || err+="Enable IPFS daemon"
@ -78,7 +92,7 @@ ipfs bootstrap add /ip6/fd42:feed:feed:feed::1/tcp/4001/p2p/Qmb6Gyy3KFWTxWh4v6fB
sudo systemctl restart ipfs || err+="Restart IPFS daemon"
sleep 10
sleep 7
[[ ! $(ipfs swarm peers) ]] && echo "${c_red}No peers found in swarm. Please open issue :https://git.p2p.legal/axiom-team/astroport/issues" && exit 1