Fix errors states of ipfs_alone install

This commit is contained in:
poka 2020-05-17 20:05:07 +02:00
parent 958b7183d7
commit e45b6da1f1
1 changed files with 15 additions and 9 deletions

View File

@ -8,6 +8,12 @@ ME="${0##*/}"
# Ask user password on start
sudo true
## Error funciton
err() {
echo "${c_red}$1$c_"
exit 1
}
# CHECK if daemon is already running
[[ $(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1) ]] \
&& echo "ipfs daemon already running. EVERYTHING OK!" \
@ -31,19 +37,19 @@ 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])/")
MACHINE_TYPE=`uname -m`
[ ${MACHINE_TYPE} == 'x86_64' ] && curl -s https://dist.ipfs.io/ipfs-update/v1.5.2/ipfs-update_v1.5.2_linux-amd64.tar.gz -o $MY_PATH/ipfs-update.tar.gz || err+="Download ipfs-update"
[ ${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"
[ ${MACHINE_TYPE} == 'x86_64' ] && curl -s https://dist.ipfs.io/ipfs-update/v1.5.2/ipfs-update_v1.5.2_linux-amd64.tar.gz -o $MY_PATH/ipfs-update.tar.gz || err "Download ipfs-update"
[ ${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 >>>>>>>>>>>>>>>>>>>>>>>>>>"
sudo tar -xvzf $MY_PATH/ipfs-update.tar.gz -C /usr/src/ || err+="Untar 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"
sudo ./install.sh || err "Install ipfs-update"
cd $MY_PATH
echo "INSTALL latest ipfs >>>>>>>>>>>>>>>>>>>>>>>>>>"
sudo ipfs-update install latest || err+="Install IPFS"
sudo ipfs-update install latest || err "Install IPFS"
echo "CREATE SYSTEMD ipfs SERVICE >>>>>>>>>>>>>>>>>>"
cat > /tmp/ipfs.service <<EOF
@ -63,8 +69,8 @@ EOF
sudo cp -f /tmp/ipfs.service /etc/systemd/system/
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"
sudo systemctl daemon-reload || err "Restart IPFS"
sudo systemctl enable ipfs || err "Enable IPFS daemon"
# INIT ipfs
[[ $isLAN ]] && ipfs init -p lowpower \
@ -92,10 +98,10 @@ ipfs bootstrap add /ip4/51.15.166.54/tcp/4001/p2p/Qmb6Gyy3KFWTxWh4v6fBeh5ANxAF6Y
ipfs bootstrap add /ip6/fd42:feed:feed:feed::1/tcp/4001/p2p/Qmb6Gyy3KFWTxWh4v6fBeh5ANxAF6YAahWQtokmsNsqGda
###########################################
sudo systemctl restart ipfs || err+="Restart IPFS daemon"
sudo systemctl restart ipfs || err "Restart IPFS daemon"
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
[[ ! $(ipfs swarm peers) ]] && err "No peers found in swarm. Please open issue :https://git.p2p.legal/axiom-team/astroport/issues" || exit 1
} # this ensures the entire script is downloaded #