#!/bin/bash ################################# # # # W12 Storj Auto Install Script # # by RIS # # # ################################# ESC_SEQ="\x1b[" COL_RESET=$ESC_SEQ"39;49;00m" RED=$ESC_SEQ"31;01m" GREEN=$ESC_SEQ"32;01m" YELLOW=$ESC_SEQ"33;01m" BLUE=$ESC_SEQ"34;01m" MAGENTA=$ESC_SEQ"35;01m" CYAN=$ESC_SEQ"36;01m" function spinner { local pid=$! local delay=0.75 local spinstr='W12' #local charwidth=3 while [ "$(ps a | awk '{print $1}' | grep $pid)" ]; do local temp=${spinstr#?} printf " [%c] " "$spinstr" local spinstr=$temp${spinstr%"$temp"} sleep $delay printf "\b\b\b\b\b\b" done printf " \b\b\b\b" } function hide_output { OUTPUT=$(mktemp) $@ &> $OUTPUT & spinner E=$? if [ $E != 0 ]; then echo echo FAILED: $@ echo ----------------------------------------- cat $OUTPUT echo ----------------------------------------- exit $E fi rm -f $OUTPUT } function apt_install { PACKAGES=$@ apt_get_quiet install $PACKAGES } function restart_service { hide_output sudo service $1 restart } function message_box { dialog --title "$1" --msgbox "$2" 0 0 } function input_box { declare -n result=$4 declare -n result_code=$4_EXITCODE result=$(dialog --stdout --title "$1" --inputbox "$2" 0 0 "$3") result_code=$? } function input_menu { declare -n result=$4 declare -n result_code=$4_EXITCODE local IFS=^$'\n' result=$(dialog --stdout --title "$1" --menu "$2" 0 0 0 $3) result_code=$? } whiptail --title "RIS Storj Install" --msgbox "Storj Installation wird nun gestartet" 10 50 3>&1 1>&2 2>&3 clear echo echo hide_output sudo apt install screen ufw hide_output sudo ufw enable hide_output sudo ufw allow `cat ~/.config/ssh.txt` # SSH für Ref User hide_output sudo ufw allow 28967/tcp hide_output sudo ufw allow 14002 hide_output sudo ufw allow 45278 # vnc für Ref User hide_output sudo ufw allow 28967/udp if whiptail --title "RIS Storj Install" --yes-button "ok" --no-button "abrechen" --yesno "Achtung! Die Festplatte wird nun gelöscht" 8 78 then { clear echo echo 25 sleep 2 sudo umount /dev/sda1 2>/dev/null hide_output sudo fdisk /dev/sda < ID sleep 3 sudo su <> /etc/fstab HERE sleep 6 echo echo 75 sleep 2 hide_output sudo mkdir /mnt/storagenode hide_output sudo chown -R ubuntu:ubuntu /mnt/storagenode hide_output sudo chmod -R 775 /mnt/storagenode sleep 2 sudo su < /boot/firmware/cmdline.txt HERE hide_output curl -L https://github.com/storj/storj/releases/latest/download/identity_linux_arm64.zip -o identity_linux_arm64.zip hide_output unzip -o identity_linux_arm64.zip chmod +x identity sudo mv identity /usr/local/bin/identity identity create storagenode hide_output sudo rm -fr ~/storjt storjt=$(whiptail --title "Storj token Eingabe" --inputbox "bitte token so eingeben -> email:auth_token <-" 20 50 3>&1 1>&2 2>&3) clear; echo echo -e "$RED dein Storj token=$COL_RESET" $storjt sleep 6 identity authorize storagenode $storjt echo grep -c BEGIN ~/.local/share/storj/identity/storagenode/ca.cert grep -c BEGIN ~/.local/share/storj/identity/storagenode/identity.cert echo echo #fi whiptail --title "RIS Storj Install" --msgbox "Storj wird eingerichtet" 10 50 3>&1 1>&2 2>&3 echo clear; echo echo -e "$YELLOW warte... $COL_RESET" echo hide_output sudo apt-get update 2>/dev/null hide_output sudo apt-get install ca-certificates curl gnupg lsb-release -y 2>/dev/null sudo rm -fr /usr/share/keyrings/docker-archive-keyring.gpg 2>/dev/null curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null hide_output sudo apt-get update -y 2>/dev/null hide_output sudo apt-get install docker-ce docker-ce-cli containerd.io -y 2>/dev/null hide_output sudo systemctl enable docker.service 2>/dev/null hide_output sudo usermod -aG docker ubuntu 2>/dev/null sleep 15 hide_output sudo docker pull storjlabs/storagenode:latest echo hide_output sudo rm ~/storjsetup.sh 2>/dev/null echo touch ~/storjsetup.sh cat << "CONFIG" >> ~/storjsetup.sh sudo docker run --rm -e SETUP="true" \ --mount type=bind,source=/home/ubuntu/.local/share/storj/identity/storagenode,destination=/app/identity \ --mount type=bind,source=/mnt/storagenode,destination=/app/config \ --name storagenode storjlabs/storagenode:latest CONFIG echo sleep 2 bash storjsetup.sh sleep 5 hide_output rm ~/storjsetup.sh echo echo -e "$YELLOW warte... $COL_RESET" echo clear hide_output rm ~/storj.sh echo touch ~/storj.sh cat << "CONFIG" >> ~/storj.sh sudo docker run -d --restart always --stop-timeout 300 \ -p 28967:28967/tcp \ -p 28967:28967/udp \ -p 14002:14002 \ CONFIG echo eth=$(whiptail --inputbox "Bitte deine ETH Wallet Addy eingeben!" 10 50 3>&1 1>&2 2>&3) clear; echo echo -e "$RED deine ETH Addy=$COL_RESET" $eth sleep 5 echo echo '-e WALLET='""$eth"" '\' >> ~/storj.sh echo mail=$(whiptail --inputbox "Bitte deine E-mail Adresse eingeben!" 10 40 3>&1 1>&2 2>&3) clear; echo echo -e "$RED deine E-mail Addy=$COL_RESET" $mail sleep 5 clear; echo '-e EMAIL='""$mail"" '\' >> ~/storj.sh echo sdyn=$(whiptail --inputbox "Bitte deine dyndns Adresse eingeben!" 10 40 3>&1 1>&2 2>&3) clear; echo echo -e "$RED deine dyndns Addy=$COL_RESET" $sdyn sleep 5 clear; echo '-e ADDRESS='""$sdyn:28967"" '\' >> ~/storj.sh echo sfest=$(whiptail --inputbox "Festplatten Grösse in TB - 10% Speicherabzug eingeben! TB mitangeben z.b. 4.5TB" 10 50 3>&1 1>&2 2>&3) clear; echo echo -e "$RED dein Festplattenspeicher=$COL_RESET" $sfest sleep 5 clear; echo echo '-e STORAGE='""$sfest"" '\'>> ~/storj.sh echo cat << "CONFIG" >> ~/storj.sh --memory=800m \ --log-opt max-size=50m \ --log-opt max-file=10 \ --mount type=bind,source=/home/ubuntu/.local/share/storj/identity/storagenode,destination=/app/identity \ --mount type=bind,source=/mnt/storagenode,destination=/app/config \ --name storagenode storjlabs/storagenode:latest CONFIG echo hide_output sudo chmod +x ~/storj.sh hide_output sh ~/storj.sh sleep 5 hide_output sudo docker pull storjlabs/watchtower sleep 5 hide_output sudo docker run -d --restart=always --name watchtower -v /var/run/docker.sock:/var/run/docker.sock storjlabs/watchtower storagenode watchtower --stop-timeout 300s --interval 21600 echo clear; echo echo -e "$GREEN [done] $COL_RESET" echo echo -e "$GREEN Dashboard unter deineIP:14002 im Browser erreichbar $COL_RESET" echo echo -e "$GREEN Storj Stoppen -> sudo docker stop storagenode $COL_RESET" echo echo -e "$GREEN Storj löschen -> sudo docker rm storagenode$COL_RESET" echo echo -e "$GREEN Storj neu starten -> sh ~/storj.sh$COL_RESET" echo sleep 10 exit