diff --git a/.install/ipfs.sh b/.install/ipfs.sh index e854161..2c5761e 100755 --- a/.install/ipfs.sh +++ b/.install/ipfs.sh @@ -1,5 +1,24 @@ +#!/bin/bash + # Install IPFS -ipfs() { + +MY_PATH="`dirname \"$0\"`" # relative +MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized + +## Config +diskSize="5G" +templates="$MY_PATH/templates/ipfs" + +if [ "$EUID" -eq 0 ] + then echo -e "${c_red}Veuillez ne pas executez ce script en root. Choisissez un utilisateur pour votre serveur G1sms+ (nous recommandons l'utilisateur pi)$c_" + exit 1 +else echo -e "${c_yellow}OK $USER, let's go!$c_"; +fi + +[[ -d ~/.ipfs-old/ ]] && echo "Backup exist, please remove backup before execute this script" && exit 1 +[[ -d ~/.ipfs/ ]] && rm -rf ~/.ipfs-old && mv ~/.ipfs/ ~/.ipfs-old + +ipfs_install() { echo -e "${c_yellow}Onboarding IPFS...$c_" [[ -f /usr/local/bin/ipfs ]] && sudo service ipfs stop if [[ $ARM == "yes" ]]; then @@ -20,11 +39,31 @@ ipfs() { echo "CREATE SYSTEMD ipfs SERVICE" [[ -f /etc/systemd/system/ipfs.service ]] && sudo rm /etc/systemd/system/ipfs.service - sudo cp -f $MY_PATH/templates/1/ipfs.service /etc/systemd/system/ + sudo cp -f $templates/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" + + ################ + # BECOME $USER + # INIT ipfs + ipfs init -p lowpower + # ipfs init -p server ## Uncomment for server infrastructure + + # ACTIVATE CONFIG OPTIONS + # PUBSUB + ipfs config Pubsub.Router gossipsub + # MAXSTORAGE + ipfs config Datastore.StorageMax $diskSize + ## PORT FORWARD (SSH) + ipfs config --json Experimental.Libp2pStreamMounting true + + ######### UPDATE BOOTSTRAP LIST ########### + ipfs bootstrap rm --all + } -$@ +ipfs_install + +exit 0 diff --git a/.install/templates/ipfs/ipfs.service b/.install/templates/ipfs/ipfs.service new file mode 100644 index 0000000..9804e8c --- /dev/null +++ b/.install/templates/ipfs/ipfs.service @@ -0,0 +1,11 @@ +[Unit] +Description=IPFS daemon +After=network.target + +[Service] +User=_USER +ExecStart=/usr/local/bin/ipfs daemon --enable-pubsub-experiment --enable-namesys-pubsub --enable-gc +Restart=on-failure + +[Install] +WantedBy=multi-user.target diff --git a/install.sh b/install.sh index 7a5ad69..1a04ec2 100755 --- a/install.sh +++ b/install.sh @@ -51,9 +51,6 @@ $MY_PATH/.install/export_colors.sh # -------------------------------------------- -# Install IPFS -source .install/ipfs.sh - # Install ScuttleButt source .install/scuttlebutt.sh @@ -71,7 +68,7 @@ iptubes() { functions=$(declare -F | awk '{print $NF}' | sort | egrep -v "^_" ) ## Check IPFS install -[[ -z $(which ipfs) ]] && ipfs +[[ -z $(which ipfs) ]] && source .install/ipfs.sh echo -e "${c_green}Astroport UP$c_" [[ -z $args ]] && echo -e "Select a gate to install:" && read apps