#!/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" # init SETUPFILE & temp dir on mem drive sudo mkdir /var/cache/raspiblitz/temp sudo chown admin:admin /var/cache/raspiblitz/temp sudo rm $SETUPFILE 2>/dev/null echo "# RASPIBLITZ SETUP STATE" > $SETUPFILE sudo chown admin:admin $SETUPFILE sudo chmod 777 $SETUPFILE ############################################ # QuickOption: Update if [ "${setupPhase}" == "update" ]; then echo "TODO: Update" exit 1 # on cancel - default to normal setup if [ "$?" != "0" ]; then setupPhase="setup" echo "# you refused update option - defaulting to normal setup" exit 1 fi fi ############################################ # QuickOption: Recovery if [ "${setupPhase}" == "recovery" ]; then echo "TODO: Update" exit 1 # on cancel - default to normal setup if [ "$?" != "0" ]; then setupPhase="setup" echo "# you refused recovery option - defaulting to normal setup" exit 1 fi fi ############################################ # QuickOption: Migration from other node if [ "${setupPhase}" == "migration" ]; then echo "# Starting migration dialog ..." /home/admin/setup.scripts/dialogMigration.sh ${migrationOS} # on cancel - default to normal setup if [ "$?" != "0" ]; then setupPhase="setup" echo "# you refused node migration option - defaulting to normal setup" exit 1 fi fi ############################################ # DEFAULT: Fresh Setup # user might default to from quick options if [ "${setupPhase}" == "setup" ]; then echo "# Starting basic setup dialog ..." /home/admin/setup.scripts/dialogBasicSetup.sh result=$? echo "result(${result})" exit 1 # on cancel - let user exit to terminal if [ "$?" != "0" ]; then echo "# you selected cancel - sending exit code 1" exit 1 fi ############################################ # Setting Name for Node echo "# Starting basic setup dialog ..." /home/admin/setup.scripts/dialogName.sh ############################################ # Lightning Wallet (new or restore) do this before passwords # 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 echo "# you selected cancel - sending exit code 1" exit 1 fi done echo "# CREATING raspiblitz.conf from your setup choices" # prepare config file CONFIGFILE="/mnt/hdd/raspiblitz.conf" sudo rm $CONFIGFILE 2>/dev/null sudo chown admin:admin $CONFIGFILE sudo chmod 777 $CONFIGFILE # source the raspiblitz version source /home/admin/_version.info # source the setup state fresh source $SETUPFILE # 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 fi ############################################ # Enter Passwords # for fresh setup & migration echo "# Starting passwords dialog ..." /home/admin/setup.scripts/dialogPasswords.sh # set flag for bootstrap process to kick-off provision process sudo sed -i "s/^state=.*/state=waitprovision/g" /home/admin/raspiblitz.info clear echo "# setup dialog done - results in:" echo "# $SETUPFILE" echo "# $CONFIGFILE"