2019-04-16 18:55:25 +01:00
|
|
|
#!/bin/bash
|
2021-05-20 21:13:35 -05:00
|
|
|
|
|
|
|
#######################################
|
|
|
|
# SSH USER INTERFACE
|
|
|
|
# gets called when user logins per SSH
|
|
|
|
# or calls 'raspiblitz' on the terminal
|
|
|
|
#######################################
|
2021-05-25 20:19:22 -05:00
|
|
|
echo "Starting SSH user interface ... (please wait)"
|
2019-04-16 18:55:25 +01:00
|
|
|
|
|
|
|
# CONFIGFILE - configuration of RaspiBlitz
|
|
|
|
configFile="/mnt/hdd/raspiblitz.conf"
|
|
|
|
|
|
|
|
# INFOFILE - state data from bootstrap
|
|
|
|
infoFile="/home/admin/raspiblitz.info"
|
|
|
|
|
2021-05-05 01:01:11 +02:00
|
|
|
# check if raspiblitz.info exists
|
|
|
|
systemInfoExists=$(ls ${infoFile} | grep -c "${infoFile}")
|
|
|
|
if [ "${systemInfoExists}" != "1" ]; then
|
|
|
|
echo "systemInfoExists(${systemInfoExists})"
|
|
|
|
echo "FAIL: ${infoFile} does not exist .. which it should at this point."
|
|
|
|
echo "Check logs & bootstrap.service for errors and report to devs."
|
2019-12-14 16:06:28 +01:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-05-05 01:01:11 +02:00
|
|
|
# get system state information raspiblitz.info
|
|
|
|
source ${infoFile}
|
|
|
|
|
|
|
|
# check that basic system phase/state information is available
|
|
|
|
if [ "${setupPhase}" == "" ] || [ "${state}" == "" ]; then
|
|
|
|
echo "setupPhase(${setupPhase}) state(${state})"
|
2021-07-15 21:28:47 +02:00
|
|
|
echo "FAIL: ${infoFile} does not exist or missing state."
|
2021-05-05 01:01:11 +02:00
|
|
|
echo "Check logs & bootstrap.service for errors and report to devs."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-06-20 20:59:05 +02:00
|
|
|
# special state: copysource
|
|
|
|
if [ "${state}" = "copysource" ]; then
|
|
|
|
echo "***********************************************************"
|
|
|
|
echo "INFO: You lost connection during copying the blockchain"
|
|
|
|
echo "You have the following options:"
|
|
|
|
echo "a) continue/check progress with command: sourcemode"
|
|
|
|
echo "b) return to normal mode with command: restart"
|
|
|
|
echo "***********************************************************"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
# special state: copytarget
|
2021-06-21 01:17:38 +02:00
|
|
|
source <(/home/admin/config.scripts/blitz.copychain.sh status)
|
2021-06-20 20:59:05 +02:00
|
|
|
if [ "${copyInProgress}" = "1" ]; then
|
|
|
|
echo "Detected interrupted COPY blochain process ..."
|
|
|
|
/home/admin/config.scripts/blitz.copychain.sh target
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
# special state: reindex was triggered
|
|
|
|
if [ "${state}" = "reindex" ]; then
|
|
|
|
echo "Re-Index in progress ... start monitoring:"
|
|
|
|
/home/admin/config.scripts/network.reindex.sh
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
# special state: copystation
|
|
|
|
if [ "${state}" = "copystation" ]; then
|
|
|
|
echo "Copy Station is Runnning ..."
|
|
|
|
echo "reboot to return to normal"
|
|
|
|
sudo /home/admin/XXcopyStation.sh
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2021-05-05 01:01:11 +02:00
|
|
|
# prepare status file
|
|
|
|
# TODO: this is to be replaced and unified together with raspiblitz.info
|
|
|
|
# when we move to a background monitoring thread & redis for WebUI with v1.8
|
|
|
|
sudo touch /var/cache/raspiblitz/raspiblitz.status
|
|
|
|
sudo chown admin:admin /var/cache/raspiblitz/raspiblitz.status
|
|
|
|
sudo chmod 740 /var/cache/raspiblitz/raspiblitz.status
|
|
|
|
|
2021-05-20 21:13:35 -05:00
|
|
|
#####################################
|
|
|
|
# SSH MENU LOOP
|
|
|
|
# this loop runs until user exits or
|
|
|
|
# an error drops user to terminal
|
|
|
|
#####################################
|
|
|
|
|
2021-05-05 01:01:11 +02:00
|
|
|
exitMenuLoop=0
|
2021-05-25 20:19:22 -05:00
|
|
|
doneIBD=0
|
2021-05-05 01:01:11 +02:00
|
|
|
while [ ${exitMenuLoop} -eq 0 ]
|
|
|
|
do
|
|
|
|
|
|
|
|
#####################################
|
2021-05-20 21:13:35 -05:00
|
|
|
# Access fresh system info on every loop
|
|
|
|
|
|
|
|
# refresh system state information
|
|
|
|
source ${infoFile}
|
|
|
|
|
|
|
|
# gather fresh status scan and store results in memory
|
|
|
|
# TODO: move this into background loop and unify with redis data storage later
|
|
|
|
sudo /home/admin/config.scripts/blitz.statusscan.sh > /var/cache/raspiblitz/raspiblitz.status
|
|
|
|
source /var/cache/raspiblitz/raspiblitz.status
|
|
|
|
|
2021-05-25 18:44:35 -05:00
|
|
|
#####################################
|
|
|
|
# ALWAYS: Handle System States
|
|
|
|
#####################################
|
|
|
|
|
|
|
|
############################
|
|
|
|
# LND Wallet Unlock
|
|
|
|
|
2021-07-20 22:58:24 +02:00
|
|
|
if [ "${lndActive}" == "1" ] && [ "${walletLocked}" == "1" ] && [ "${state}" == "ready" ]; then
|
2021-05-25 18:44:35 -05:00
|
|
|
/home/admin/config.scripts/lnd.unlock.sh
|
|
|
|
fi
|
|
|
|
|
2021-05-20 21:13:35 -05:00
|
|
|
#####################################
|
|
|
|
# SETUP MENU
|
2021-05-05 01:01:11 +02:00
|
|
|
#####################################
|
|
|
|
|
2021-05-20 21:13:35 -05:00
|
|
|
# when is needed & bootstrap process signals that it waits for user dialog
|
2021-05-05 01:18:32 +02:00
|
|
|
if [ "${setupPhase}" != "done" ] && [ "${state}" == "waitsetup" ]; then
|
2021-05-05 01:01:11 +02:00
|
|
|
# push user to main menu
|
2021-06-20 21:03:39 +02:00
|
|
|
/home/admin/setup.scripts/controlSetupDialog.sh
|
2021-05-05 01:18:32 +02:00
|
|
|
# use the exit code from setup menu as signal if menu loop should exited
|
2021-05-05 01:10:41 +02:00
|
|
|
# 0 = continue loop / everything else = break loop and exit to terminal
|
|
|
|
exitMenuLoop=$?
|
|
|
|
if [ "${exitMenuLoop}" != "0" ]; then break; fi
|
|
|
|
fi
|
|
|
|
|
2021-05-25 17:29:57 -05:00
|
|
|
#####################################
|
|
|
|
# SETUP DONE DIALOGS
|
|
|
|
#####################################
|
|
|
|
|
|
|
|
# when is needed & bootstrap process signals that it waits for user dialog
|
|
|
|
if [ "${setupPhase}" != "done" ] && [ "${state}" == "waitfinal" ]; then
|
|
|
|
# push to final setup gui dialogs
|
2021-06-20 21:03:39 +02:00
|
|
|
/home/admin/setup.scripts/controlFinalDialog.sh
|
2021-05-25 22:10:57 -05:00
|
|
|
continue
|
2021-05-25 17:29:57 -05:00
|
|
|
fi
|
|
|
|
|
2021-05-25 20:19:22 -05:00
|
|
|
#####################################
|
2021-05-25 22:10:57 -05:00
|
|
|
# INITIAL BLOCKCHAIN SYNC (SUBLOOP)
|
2021-05-25 20:19:22 -05:00
|
|
|
#####################################
|
2021-05-25 22:10:57 -05:00
|
|
|
if [ "${setupPhase}" == "done" ] && [ "${state}" == "ready" ] && [ "${initialSync}" == "1" ]; then
|
2021-07-15 23:36:53 +02:00
|
|
|
echo "debug wait eventBlockchainSync.sh ..."
|
|
|
|
sleep 3
|
2021-05-25 22:10:57 -05:00
|
|
|
/home/admin/setup.scripts/eventBlockchainSync.sh ssh loop
|
|
|
|
continue
|
2021-05-25 20:19:22 -05:00
|
|
|
fi
|
|
|
|
|
2021-05-05 01:10:41 +02:00
|
|
|
#####################################
|
2021-05-25 19:30:29 -05:00
|
|
|
# MAIN MENU or BLOCKCHAIN SYNC
|
2021-05-05 01:10:41 +02:00
|
|
|
#####################################
|
|
|
|
|
2021-05-20 21:13:35 -05:00
|
|
|
# when setup is done & state is ready .. jump to main menu
|
2021-05-05 01:18:32 +02:00
|
|
|
if [ "${setupPhase}" == "done" ] && [ "${state}" == "ready" ]; then
|
2021-05-25 20:33:16 -05:00
|
|
|
# MAIN MENU
|
|
|
|
/home/admin/00mainMenu.sh
|
|
|
|
# use the exit code from main menu as signal if menu loop should exited
|
|
|
|
# 0 = continue loop / everything else = break loop and exit to terminal
|
|
|
|
exitMenuLoop=$?
|
|
|
|
if [ "${exitMenuLoop}" != "0" ]; then break; fi
|
2021-05-05 01:01:11 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
#####################################
|
|
|
|
# DURING SETUP: Handle System States
|
|
|
|
#####################################
|
|
|
|
|
|
|
|
if [ "${setupPhase}" != "done" ]; then
|
|
|
|
|
2021-07-03 00:39:55 +02:00
|
|
|
#echo "# DURING SETUP: Handle System State (${state})"
|
2021-05-06 00:12:09 +02:00
|
|
|
|
2021-05-06 02:23:02 +02:00
|
|
|
# when no HDD on Vagrant - just print info & exit (admin info & exit)
|
2021-05-06 00:12:09 +02:00
|
|
|
if [ "${state}" == "noHDD" ] && [ ${vagrant} -gt 0 ]; then
|
2021-05-06 00:13:18 +02:00
|
|
|
echo "***********************************************************"
|
|
|
|
echo "VAGRANT INFO"
|
|
|
|
echo "***********************************************************"
|
|
|
|
echo "To connect a HDD data disk to your VagrantVM:"
|
|
|
|
echo "- shutdown VM with command: off"
|
|
|
|
echo "- open your VirtualBox GUI and select RaspiBlitzVM"
|
|
|
|
echo "- change the 'mass storage' settings"
|
|
|
|
echo "- add a second 'Primary Slave' drive to the already existing controller"
|
|
|
|
echo "- close VirtualBox GUI and run: vagrant up & vagrant ssh"
|
|
|
|
echo "***********************************************************"
|
|
|
|
echo "You can either create a new dynamic VDI with around 900GB or download"
|
|
|
|
echo "a VDI with a presynced blockchain to speed up setup. If you dont have 900GB"
|
|
|
|
echo "space on your laptop you can store the VDI file on an external drive."
|
|
|
|
echo "***********************************************************"
|
|
|
|
exit 1
|
2021-05-18 18:43:59 -05:00
|
|
|
fi
|
2021-05-06 02:23:02 +02:00
|
|
|
|
|
|
|
# for all critical errors (admin info & exit)
|
|
|
|
if [ "${state}" == "errorHDD" ]; then
|
|
|
|
echo "***********************************************************"
|
|
|
|
echo "SETUP ERROR - please report to development team"
|
|
|
|
echo "***********************************************************"
|
|
|
|
echo "state(${state}) message(${message})"
|
|
|
|
if [ "${state}" == "errorHDD" ]; then
|
|
|
|
# print some debug detail info on HDD/SSD error
|
|
|
|
sudo /home/admin/config.scripts/blitz.datadrive.sh status
|
|
|
|
fi
|
|
|
|
echo "command to shutdown --> off"
|
|
|
|
exit 1
|
2021-05-06 00:13:18 +02:00
|
|
|
else
|
2021-05-06 00:12:09 +02:00
|
|
|
# every other state just push as event to SSH frontend
|
2021-07-15 23:36:53 +02:00
|
|
|
echo "debug wait eventInfoWait.sh ..."
|
2021-07-15 23:34:50 +02:00
|
|
|
sleep 3
|
2021-05-06 00:40:33 +02:00
|
|
|
/home/admin/setup.scripts/eventInfoWait.sh "${state}" "${message}"
|
2020-10-14 01:31:27 +02:00
|
|
|
fi
|
2021-05-05 01:01:11 +02:00
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
done
|
2021-05-18 18:43:59 -05:00
|
|
|
|
2021-05-05 01:30:39 +02:00
|
|
|
echo "# menu loop received exit code ${exitMenuLoop} --> exit to terminal"
|
2021-05-05 01:16:46 +02:00
|
|
|
echo "***********************************"
|
|
|
|
echo "* RaspiBlitz Commandline"
|
|
|
|
echo "* Here be dragons .. have fun :)"
|
|
|
|
echo "***********************************"
|
2021-05-05 01:17:23 +02:00
|
|
|
if [ "${setupPhase}" == "done" ]; then
|
2021-08-03 21:31:17 +02:00
|
|
|
echo "Bitcoin command line options: ${network}-cli help"
|
|
|
|
if [ "${lightning}" == "lnd" ]; then
|
|
|
|
echo "LND command line options: lncli -h"
|
|
|
|
fi
|
|
|
|
if [ "${lightning}" == "cln" ]; then
|
|
|
|
echo "C-Lightning command line options: lightning-cli help"
|
|
|
|
fi
|
2021-05-05 01:21:43 +02:00
|
|
|
else
|
|
|
|
echo "Your setup is not finished."
|
2021-05-05 01:33:34 +02:00
|
|
|
echo "For setup logs: cat raspiblitz.log"
|
2021-05-05 01:21:43 +02:00
|
|
|
echo "or call the command 'debug' to see bigger report."
|
2021-05-05 01:16:46 +02:00
|
|
|
fi
|
|
|
|
echo "Back to menus use command: raspiblitz"
|
|
|
|
echo
|
2021-05-05 01:10:41 +02:00
|
|
|
exit 0
|