2020-05-02 01:27:09 +02:00
|
|
|
#!/bin/bash
|
2020-05-04 17:05:23 +02:00
|
|
|
########################################################################
|
|
|
|
{ # this ensures the entire script is downloaded #
|
2020-05-02 01:27:09 +02:00
|
|
|
MY_PATH="`dirname \"$0\"`" # relative
|
|
|
|
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
|
2020-05-04 17:05:23 +02:00
|
|
|
ME="${0##*/}"
|
2020-05-02 01:27:09 +02:00
|
|
|
|
2020-05-03 18:14:41 +02:00
|
|
|
# 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) ]] \
|
2020-05-03 18:17:30 +02:00
|
|
|
&& echo "ipfs daemon already running. EVERYTHING OK!" \
|
2020-05-03 19:58:28 +02:00
|
|
|
&& ipfs id && echo "ipfs swarm peers" && ipfs swarm peers \
|
2020-05-09 21:34:28 +02:00
|
|
|
&& echo "ipfs bootstrap list" && ipfs bootstrap list \
|
|
|
|
&& echo "Please RUN : sudo systemctl stop ipfs" && exit 0
|
2020-05-03 18:14:41 +02:00
|
|
|
|
|
|
|
# CHECK not root user !!
|
2020-05-02 01:27:09 +02:00
|
|
|
if [ "$EUID" -eq 0 ]
|
|
|
|
then echo -e "${c_red}DO NOT EXECUTE AS root. Choose a user for your Astroport Station (we like pi)$c_"
|
|
|
|
exit 1
|
|
|
|
else echo -e "${c_yellow}OK $USER, let's go!$c_";
|
|
|
|
fi
|
|
|
|
|
|
|
|
[[ -d ~/.ipfs ]] && echo "IPFS install exist, please remove backup before execute this script" && exit 1
|
|
|
|
|
|
|
|
echo -e "${c_yellow}Onboarding IPFS...$c_"
|
|
|
|
|
2020-05-03 18:03:39 +02:00
|
|
|
MACHINE_TYPE=`uname -m`
|
2020-05-03 18:05:52 +02:00
|
|
|
[ ${MACHINE_TYPE} == 'x86_64' ] && wget 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' ] && wget 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
|
|
|
|
|
2020-05-02 01:27:09 +02:00
|
|
|
|
|
|
|
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"
|
|
|
|
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
|
|
|
|
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"
|
|
|
|
|
|
|
|
# INIT ipfs
|
|
|
|
ipfs init -p lowpower
|
|
|
|
# ipfs init -p server ## Uncomment for server infrastructure
|
|
|
|
|
|
|
|
# ACTIVATE CONFIG OPTIONS
|
|
|
|
# PUBSUB
|
|
|
|
ipfs config Pubsub.Router gossipsub
|
|
|
|
# MAXSTORAGE
|
|
|
|
availableDiskSize=$(df -P ~/ | awk 'NR>1{sum+=$4}END{print sum}')
|
|
|
|
diskSize="$((availableDiskSize / 2))"
|
|
|
|
ipfs config Datastore.StorageMax $diskSize
|
|
|
|
## PORT FORWARD (SSH)
|
|
|
|
ipfs config --json Experimental.Libp2pStreamMounting true
|
|
|
|
|
|
|
|
######### UPDATE BOOTSTRAP LIST ###########
|
|
|
|
ipfs bootstrap rm --all
|
2020-05-10 03:28:36 +02:00
|
|
|
# ipfs bootstrap add /dnsaddr/rec.copylaradio.com/tcp/4001/ipfs/Qmb6Gyy3KFWTxWh4v6fBeh5ANxAF6YAahWQtokmsNsqGda
|
2020-05-02 01:27:09 +02:00
|
|
|
|
|
|
|
sudo systemctl restart ipfs || err+="Restart IPFS daemon"
|
2020-05-04 17:05:23 +02:00
|
|
|
} # this ensures the entire script is downloaded #
|