rearrange setup dialog

This commit is contained in:
rootzoll
2021-05-21 20:23:26 -05:00
parent cfa2e2c6d1
commit 485abcacca
6 changed files with 248 additions and 129 deletions

View File

@@ -2,19 +2,13 @@
# get basic system information # get basic system information
# these are the same set of infos the WebGUI dialog/controler has # these are the same set of infos the WebGUI dialog/controler has
source /home/admin/raspiblitz.info source /home/admin/_version.info
# SETUPFILE # chose how to setup node (fresh or from a upload backup)
# this key/value file contains the state during the setup process
SETUPFILE="/var/cache/raspiblitz/temp/raspiblitz.setup"
source $SETUPFILE
# choose blockchain or select migration
OPTIONS=() OPTIONS=()
OPTIONS+=(BITCOIN1 "Setup BITCOIN & Lightning Network Daemon (LND)") OPTIONS+=(FRESHSETUP "Setup a new RaspiBlitz")
OPTIONS+=(BITCOIN2 "Setup BITCOIN & c-lightning by blockstream") OPTIONS+=(FROMBACKUP "Upload Migration Backup")
OPTIONS+=(LITECOIN "Setup LITECOIN & Lightning Network Daemon (LND)") OPTIONS+=(SHUTDOWN "Shutdown without Changes")
OPTIONS+=(MIGRATION "Upload a Migration File from old RaspiBlitz")
CHOICE=$(dialog --clear \ CHOICE=$(dialog --clear \
--backtitle "RaspiBlitz ${codeVersion} - Setup" \ --backtitle "RaspiBlitz ${codeVersion} - Setup" \
--title "⚡ Welcome to your RaspiBlitz ⚡" \ --title "⚡ Welcome to your RaspiBlitz ⚡" \
@@ -23,36 +17,23 @@ CHOICE=$(dialog --clear \
"${OPTIONS[@]}" \ "${OPTIONS[@]}" \
2>&1 >/dev/tty) 2>&1 >/dev/tty)
clear clear
network=""
lightning=""
migrationOS=""
case $CHOICE in case $CHOICE in
BITCOIN1) FRESHSETUP)
network="bitcoin" # 0 --> FRESH SETUP
lightning="lnd" exit 0;
;; ;;
BITCOIN2) FROMBACKUP)
network="bitcoin" # 1 --> UPLOAD MIGRATION BACKUP
lightning="cln" exit 1
;; ;;
LITECOIN) SHUTDOWN)
network="litecoin" # 2 --> SHUTDOWN
lightning="lnd" exit 2
;; ;;
MIGRATION) *)
migrationOS="raspiblitz" # 3 --> ESC/CANCEL = EXIT TO TERMINAL
;; clear
esac echo "Exit to Terminal from RaspiBlitz Setup ..."
echo "Command to return to Setup --> raspiblitz"
# on cancel - exit with 1 exit 3
if [ "${network}" == "" ] && [ "${migrationOS}" == "" ]; then esac
exit 1
fi
# write results to setup sate
echo "migrationOS='${migrationOS}'" >> $SETUPFILE
echo "migrationVersion=''" >> $SETUPFILE
echo "lightning=${lightning}" >> $SETUPFILE
echo "network=${network}" >> $SETUPFILE
exit 0

View File

@@ -0,0 +1,80 @@
#!/bin/bash
# get basic system information
# these are the same set of infos the WebGUI dialog/controler has
source /home/admin/raspiblitz.info
# SETUPFILE
# this key/value file contains the state during the setup process
SETUPFILE="/var/cache/raspiblitz/temp/raspiblitz.setup"
source $SETUPFILE
# values to determine by dialogs
network=""
lightning=""
# chose blockchain
OPTIONS=()
OPTIONS+=(BITCOIN "Setup BITCOIN Blockchain (BitcoinCore)")
OPTIONS+=(LITECOIN "Setup LITECOIN Blockchain"))
CHOICE=$(dialog --clear \
--backtitle "RaspiBlitz ${codeVersion} - Setup" \
--title "⚡ Blockchain ⚡" \
--menu "\nChoose which Blockchain to run: \n " \
13 64 7 \
"${OPTIONS[@]}" \
2>&1 >/dev/tty)
clear
case $CHOICE in
BITCOIN)
# bitcoin core
network="bitcoin"
;;
LITECOIN)
# litecoin
network="litecoin"
# can only work with LND
lightning="lnd"
;;
*)
clear
echo "User Cancel"
exit 1
esac
if [ "${network}" == "bitcoin" ]; then
# choose lightning client
OPTIONS=()
OPTIONS+=(LND "LND - Lightning Network Daemon (DEFAULT)")
OPTIONS+=(CLN "c-lightning by blockstream (fewer Apps)")
OPTIONS+=(NONE "Run without Lightning")
CHOICE=$(dialog --clear \
--backtitle "RaspiBlitz ${codeVersion} - Setup" \
--title "⚡ Lightning ⚡" \
--menu "\nChoose your Lightning Client: \n " \
13 64 7 \
"${OPTIONS[@]}" \
2>&1 >/dev/tty)
clear
case $CHOICE in
LND)
lightning="lnd"
;;
CLN)
lightning="cln"
;;
NONE)
lightning=""
;;
*)
clear
echo "User Cancel"
exit 1
esac
# write results to setup sate
echo "lightning=${lightning}" >> $SETUPFILE
echo "network=${network}" >> $SETUPFILE
exit 0

View File

@@ -99,8 +99,6 @@ if [ "${migrationOS}" == "raspiblitz" ]; then
# migration OS & Version were already set earlier in setup process - now add migration filename # migration OS & Version were already set earlier in setup process - now add migration filename
echo "migrationFile='${filename}'" >> $SETUPFILE echo "migrationFile='${filename}'" >> $SETUPFILE
# user needs to reset password A
echo "setPasswordA=1" >> $SETUPFILE
exit 0 exit 0
fi fi
@@ -126,15 +124,8 @@ Do you want to start migration to RaspiBlitz now?
# user cancel - signal by exit code # user cancel - signal by exit code
exit 1 exit 1
fi fi
# write migration info # signal that user wants to proceed with migration
echo "migrationOS='umbrel'" >> $SETUPFILE
echo "migrationVersion='${migrationVersion}'" >> $SETUPFILE
# user needs to reset password A, B & C
echo "setPasswordA=1" >> $SETUPFILE
echo "setPasswordB=1" >> $SETUPFILE
echo "setPasswordC=1" >> $SETUPFILE
exit 0 exit 0
fi fi
@@ -160,14 +151,8 @@ Do you want to start migration to RaspiBlitz now?
# user cancel - signal by exit code # user cancel - signal by exit code
exit 1 exit 1
fi fi
# write migration info
echo "migrationOS='mynode'" >> $SETUPFILE
echo "migrationVersion='${migrationVersion}'" >> $SETUPFILE
# user needs to reset password A # signal that user wants to proceed with migration
echo "setPasswordA=1" >> $SETUPFILE
echo "setPasswordB=1" >> $SETUPFILE
echo "setPasswordC=1" >> $SETUPFILE
exit 0 exit 0
fi fi

View File

@@ -15,5 +15,10 @@ Please make sure to have your seed words & static channel backup file (just in c
Do you want to start RECOVERY of your RaspiBlitz now? Do you want to start RECOVERY of your RaspiBlitz now?
" 18 65 " 18 65
result=$? if [ "$?" == "0" ]; then
echo "result($result)" # 0 --> run recover
exit 0
else
# 1 --> other options
exit 1
fi

View File

@@ -0,0 +1,25 @@
#!/bin/bash
# get basic system information
# these are the same set of infos the WebGUI dialog/controler has
source /home/admin/_version.info
source /home/admin/raspiblitz.info
whiptail --title " RASPIBLITZ UPDATE " --yes-button "Start Update" --no-button "Other Options" --yesno "We found data from an old RaspiBlitz on your HDD/SSD.
You can start now the UPDATE to version ${codeVersion}.
You will need to set a new Password A for the SSH login. All your channels will stay open and other passwords will stay the same.
Please make sure to have your seed words & static channel backup file (just in case).
Do you want to start UPDATE of your RaspiBlitz now?
" 18 65
if [ "$?" == "0" ]; then
# 0 --> run recover
exit 0
else
# 1 --> other options
exit 1
fi

View File

@@ -19,42 +19,51 @@ sudo chmod 777 $SETUPFILE
############################################ ############################################
# QuickOption: Update # QuickOption: Update
if [ "${setupPhase}" == "update" ]; then if [ "${setupPhase}" == "update" ]; then
# show update dialog
echo "TODO: Update" /home/admin/setup.scripts/dialogUpdate.sh
exit 1 if [ "$?" == "0" ]; then
# proceed with provision (mark Password A to be set)
# on cancel - default to normal setup echo "# OK update process starting .."
if [ "$?" != "0" ]; then echo "setPasswordA=1" >> $SETUPFILE
else
# default to normal setup options
setupPhase="setup" setupPhase="setup"
echo "# you refused update option - defaulting to normal setup" echo "# you refused recovery option - defaulting to normal setup"
exit 1
fi fi
fi fi
############################################ ############################################
# QuickOption: Recovery # QuickOption: Recovery
if [ "${setupPhase}" == "recovery" ]; then if [ "${setupPhase}" == "recovery" ]; then
# show recovery dialog
echo "TODO: RECOVERY" /home/admin/setup.scripts/dialogRecovery.sh
exit 1 if [ "$?" == "0" ]; then
# proceed with provision (mark Password A to be set)
# on cancel - default to normal setup echo "# OK recover process starting .."
if [ "$?" != "0" ]; then echo "setPasswordA=1" >> $SETUPFILE
else
# default to normal setup options
setupPhase="setup" setupPhase="setup"
echo "# you refused recovery option - defaulting to normal setup" echo "# you refused recovery option - defaulting to normal setup"
exit 1
fi fi
fi fi
############################################ ############################################
# QuickOption: Migration from other node # QuickOption: Migration from other node
if [ "${setupPhase}" == "migration" ]; then if [ "${setupPhase}" == "migration" ]; then
# show recovery dialog
echo "# Starting migration dialog ..." echo "# Starting migration dialog ..."
/home/admin/setup.scripts/dialogMigration.sh ${migrationOS} /home/admin/setup.scripts/dialogMigration.sh ${migrationOS}
if [ "$?" == "0" ]; then
# on cancel - default to normal setup # mark migration to happen on provision
if [ "$?" != "0" ]; then echo "migrationOS='umbrel'" >> $SETUPFILE
echo "migrationVersion='${migrationVersion}'" >> $SETUPFILE
# user needs to reset password A, B & C
echo "setPasswordA=1" >> $SETUPFILE
echo "setPasswordB=1" >> $SETUPFILE
echo "setPasswordC=1" >> $SETUPFILE
else
# on cancel - default to normal setup
setupPhase="setup" setupPhase="setup"
echo "# you refused node migration option - defaulting to normal setup" echo "# you refused node migration option - defaulting to normal setup"
exit 1 exit 1
@@ -63,77 +72,111 @@ if [ "${setupPhase}" == "migration" ]; then
fi fi
############################################ ############################################
# DEFAULT: Fresh Setup # DEFAULT: Basic Setup menu
# user might default to from quick options # user might default to from quick options
if [ "${setupPhase}" == "setup" ]; then if [ "${setupPhase}" == "setup" ]; then
echo "# Starting basic setup dialog ..." echo "# Starting basic setup dialog ..."
/home/admin/setup.scripts/dialogBasicSetup.sh /home/admin/setup.scripts/dialogBasicSetup.sh
menuresult=$?
result=$? # exit to terminal
echo "result(${result})" if [ "${menuresult}" == "3" ]; then
exit 1 exit 0
fi
# shutdown without changes
if [ "${menuresult}" == "2" ]; then
sudo shutdown now
exit 0
fi
# on cancel - let user exit to terminal # uplaod and setup from migration backup
if [ "$?" != "0" ]; then if [ "${menuresult}" == "1" ]; then
echo "# you selected cancel - sending exit code 1" /home/admin/setup.scripts/dialogMigration.sh raspiblitz
exit 1 if [ "$?" == "1" ]; then
echo "Upload did not worked ... doing shutdown. Restart for new try."
sudo shutdown now
exit 0
fi
# user needs to reset password A
echo "setPasswordA=1" >> $SETUPFILE
fi fi
############################################ ############################################
# Setting Name for Node # FRESH SETUP
if [ "${menuresult}" == "0" ]; then
echo "# Starting basic setup dialog ..." ############################################
/home/admin/setup.scripts/dialogName.sh # Choosing Blockchain & Lightning
############################################ echo "# Starting Blockchain & Lightning selection ..."
# Lightning Wallet (new or restore) do this before passwords /home/admin/setup.scripts/dialogBlockchainLightning.sh
# because password C not needed if LND rescue file is uploaded
lightningWalletDone=0
while [ "${lightningWalletDone}" == "0" ]
do
echo "# Starting lightning wallet dialog ..."
/home/admin/setup.scripts/dialogLightningWallet.sh
# only if dialog exited clean end loop
if [ "$?" == "0" ]; then
lightningWalletDone=1
fi
# allow user to cancel to terminal on dialog main menu
# all other cancels have other exit codes
if [ "$?" == "1" ]; then if [ "$?" == "1" ]; then
echo "# you selected cancel - sending exit code 1" echo "Shutting down ... Restart for new try."
exit 1 sudo shutdown now
exit 0
fi fi
done ############################################
# Setting Name for Node
echo "# CREATING raspiblitz.conf from your setup choices" echo "# Starting name dialog ..."
/home/admin/setup.scripts/dialogName.sh
# prepare config file ############################################
CONFIGFILE="/mnt/hdd/raspiblitz.conf" # Lightning Wallet (new or restore) do this before passwords
sudo rm $CONFIGFILE 2>/dev/null # because password C not needed if LND rescue file is uploaded
sudo chown admin:admin $CONFIGFILE
sudo chmod 777 $CONFIGFILE
# source the raspiblitz version lightningWalletDone=0
source /home/admin/_version.info while [ "${lightningWalletDone}" == "0" ]
do
# source the setup state fresh echo "# Starting lightning wallet dialog ..."
source $SETUPFILE /home/admin/setup.scripts/dialogLightningWallet.sh
# write basic config file data # only if dialog exited clean end loop
echo "# RASPIBLITZ CONFIG FILE" > $CONFIGFILE if [ "$?" == "0" ]; then
echo "raspiBlitzVersion='${codeVersion}'" >> $CONFIGFILE lightningWalletDone=1
echo "lcdrotate=1" >> $CONFIGFILE fi
echo "lightning=${lightning}" >> $CONFIGFILE
echo "network=${network}" >> $CONFIGFILE # allow user to cancel to terminal on dialog main menu
echo "chain=main" >> $CONFIGFILE # all other cancels have other exit codes
echo "runBehindTor=on" >> $CONFIGFILE if [ "$?" == "1" ]; then
echo "# you selected cancel - sending exit code 1"
exit 1
fi
done
echo "# CREATING raspiblitz.conf from your setup choices"
# source the raspiblitz version
source /home/admin/_version.info
# source the setup state fresh
source $SETUPFILE
# prepare config file
CONFIGFILE="/mnt/hdd/raspiblitz.conf"
sudo rm $CONFIGFILE 2>/dev/null
sudo chown admin:admin $CONFIGFILE
sudo chmod 777 $CONFIGFILE
# write basic config file data
echo "# RASPIBLITZ CONFIG FILE" > $CONFIGFILE
echo "raspiBlitzVersion='${codeVersion}'" >> $CONFIGFILE
echo "lcdrotate=1" >> $CONFIGFILE
echo "lightning=${lightning}" >> $CONFIGFILE
echo "network=${network}" >> $CONFIGFILE
echo "chain=main" >> $CONFIGFILE
echo "runBehindTor=on" >> $CONFIGFILE
# user needs to set all passwords
echo "setPasswordA=1" >> $SETUPFILE
echo "setPasswordB=1" >> $SETUPFILE
echo "setPasswordC=1" >> $SETUPFILE
fi
fi fi