#!/bin/bash THUBVERSION="v0.12.13" # command info if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then echo "config script to install, update or uninstall ThunderHub" echo "bonus.thunderhub.sh [on|off|menu|update]" echo "install $THUBVERSION by default" exit 1 fi # check and load raspiblitz config # to know which network is running source /home/admin/raspiblitz.info source /mnt/hdd/raspiblitz.conf if [ ${#network} -eq 0 ]; then echo "FAIL - missing /mnt/hdd/raspiblitz.conf" exit 1 fi # show info menu if [ "$1" = "menu" ]; then # get network info localip=$(hostname -I | awk '{print $1}') toraddress=$(sudo cat /mnt/hdd/tor/thunderhub/hostname 2>/dev/null) fingerprint=$(openssl x509 -in /mnt/hdd/app-data/nginx/tls.cert -fingerprint -noout | cut -d"=" -f2) if [ "${runBehindTor}" = "on" ] && [ ${#toraddress} -gt 0 ]; then # Info with TOR /home/admin/config.scripts/blitz.display.sh qr "${toraddress}" whiptail --title " ThunderHub " --msgbox "Open in your local web browser: http://${localip}:3010\n https://${localip}:3011 with Fingerprint: ${fingerprint}\n Use your Password B to login.\n Hidden Service address for TOR Browser (see LCD for QR):\n${toraddress} " 16 67 /home/admin/config.scripts/blitz.display.sh hide else # Info without TOR whiptail --title " ThunderHub " --msgbox "Open in your local web browser & accept self-signed cert: http://${localip}:3010\n https://${localip}:3011 with Fingerprint: ${fingerprint}\n Use your Password B to login.\n Activate TOR to access the web interface from outside your local network. " 15 57 fi echo "please wait ..." exit 0 fi # add default value to raspi config if needed if ! grep -Eq "^thunderhub=" /mnt/hdd/raspiblitz.conf; then echo "thunderhub=off" >> /mnt/hdd/raspiblitz.conf fi # stop services echo "making sure services are not running" sudo systemctl stop thunderhub 2>/dev/null # switch on if [ "$1" = "1" ] || [ "$1" = "on" ]; then echo "*** INSTALL THUNDERHUB ***" isInstalled=$(sudo ls /etc/systemd/system/thunderhub.service 2>/dev/null | grep -c 'thunderhub.service') if ! [ ${isInstalled} -eq 0 ]; then echo "ThunderHub already installed." else ############### # INSTALL ############### # Preparations # check and install NodeJS /home/admin/config.scripts/bonus.nodejs.sh on # create thunderhub user sudo adduser --disabled-password --gecos "" thunderhub # download and install sudo -u thunderhub git clone https://github.com/apotdevin/thunderhub.git /home/thunderhub/thunderhub cd /home/thunderhub/thunderhub || exit 1 # https://github.com/apotdevin/thunderhub/releases sudo -u thunderhub git reset --hard $THUBVERSION echo "Running npm install and run build..." sudo -u thunderhub npm install if ! [ $? -eq 0 ]; then echo "FAIL - npm install did not run correctly, aborting" exit 1 fi sudo -u thunderhub npm run build ############### # CONFIG ############### # make sure symlink to central app-data directory exists ***" sudo rm -rf /home/thunderhub/.lnd # not a symlink.. delete it silently # create symlink sudo ln -s "/mnt/hdd/app-data/lnd/" "/home/thunderhub/.lnd" # make sure thunderhub is member of lndadmin sudo /usr/sbin/usermod --append --groups lndadmin thunderhub # persist settings in app-data sudo mkdir -p /mnt/hdd/app-data/thunderhub ################# # .env ################# echo "*** create ThunderHub .env file ***" cat > /home/admin/thunderhub.env < /home/admin/thubConfig.yaml <