2021-05-03 14:00:01 +02:00
|
|
|
#!/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
|
2021-05-03 15:24:54 +02:00
|
|
|
SETUPFILE="/var/cache/raspiblitz/temp/raspiblitz.setup"
|
2021-05-03 14:00:01 +02:00
|
|
|
|
2021-05-03 17:16:28 +02:00
|
|
|
# init SETUPFILE & temp dir on mem drive
|
2021-05-03 15:24:54 +02:00
|
|
|
sudo mkdir /var/cache/raspiblitz/temp
|
|
|
|
sudo chown admin:admin /var/cache/raspiblitz/temp
|
2021-05-03 14:28:50 +02:00
|
|
|
sudo rm $SETUPFILE 2>/dev/null
|
2021-05-03 14:00:01 +02:00
|
|
|
echo "# RASPIBLITZ SETUP STATE" > $SETUPFILE
|
2021-05-03 14:28:50 +02:00
|
|
|
sudo chown admin:admin $SETUPFILE
|
|
|
|
sudo chmod 777 $SETUPFILE
|
2021-05-03 14:00:01 +02:00
|
|
|
|
|
|
|
############################################
|
2021-05-21 11:52:20 -05:00
|
|
|
# QuickOption: Update
|
|
|
|
if [ "${setupPhase}" == "update" ]; then
|
2021-05-03 14:00:01 +02:00
|
|
|
|
2021-05-21 11:52:20 -05:00
|
|
|
echo "TODO: Update"
|
|
|
|
exit 1
|
2021-05-03 14:00:01 +02:00
|
|
|
|
2021-05-21 11:52:20 -05:00
|
|
|
# on cancel - default to normal setup
|
2021-05-03 14:00:01 +02:00
|
|
|
if [ "$?" != "0" ]; then
|
2021-05-21 11:52:20 -05:00
|
|
|
setupPhase="setup"
|
|
|
|
echo "# you refused update option - defaulting to normal setup"
|
2021-05-03 14:00:01 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2021-05-21 11:52:20 -05:00
|
|
|
############################################
|
|
|
|
# QuickOption: Recovery
|
|
|
|
if [ "${setupPhase}" == "recovery" ]; then
|
2021-05-03 17:16:28 +02:00
|
|
|
|
2021-05-21 11:52:20 -05:00
|
|
|
echo "TODO: Update"
|
|
|
|
exit 1
|
2021-05-03 14:00:01 +02:00
|
|
|
|
2021-05-21 11:52:20 -05:00
|
|
|
# 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
|
2021-05-03 14:00:01 +02:00
|
|
|
|
|
|
|
echo "# Starting migration dialog ..."
|
2021-05-21 11:52:20 -05:00
|
|
|
/home/admin/setup.scripts/dialogMigration.sh ${migrationOS}
|
2021-05-03 14:00:01 +02:00
|
|
|
|
2021-05-21 11:52:20 -05:00
|
|
|
# on cancel - default to normal setup
|
2021-05-03 14:00:01 +02:00
|
|
|
if [ "$?" != "0" ]; then
|
2021-05-21 11:52:20 -05:00
|
|
|
setupPhase="setup"
|
|
|
|
echo "# you refused node migration option - defaulting to normal setup"
|
2021-05-03 14:00:01 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-05-21 11:52:20 -05:00
|
|
|
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
|
|
|
|
|
2021-05-03 14:00:01 +02:00
|
|
|
|
2021-05-21 11:52:20 -05:00
|
|
|
# on cancel - let user exit to terminal
|
|
|
|
if [ "$?" != "0" ]; then
|
|
|
|
echo "# you selected cancel - sending exit code 1"
|
|
|
|
exit 1
|
|
|
|
fi
|
2021-05-03 14:00:01 +02:00
|
|
|
|
|
|
|
############################################
|
|
|
|
# Setting Name for Node
|
|
|
|
|
2021-05-03 14:13:54 +02:00
|
|
|
echo "# Starting basic setup dialog ..."
|
2021-05-03 14:21:29 +02:00
|
|
|
/home/admin/setup.scripts/dialogName.sh
|
2021-05-03 14:00:01 +02:00
|
|
|
|
|
|
|
############################################
|
|
|
|
# Lightning Wallet (new or restore) do this before passwords
|
|
|
|
# because password C not needed if LND rescue file is uploaded
|
|
|
|
|
2021-05-03 14:13:54 +02:00
|
|
|
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
|
|
|
|
|
2021-05-03 14:21:29 +02:00
|
|
|
# allow user to cancel to terminal on dialog main menu
|
|
|
|
# all other cancels have other exit codes
|
|
|
|
if [ "$?" == "1" ]; then
|
2021-05-05 01:23:45 +02:00
|
|
|
echo "# you selected cancel - sending exit code 1"
|
2021-05-03 14:21:29 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-05-03 14:13:54 +02:00
|
|
|
done
|
2021-05-03 14:00:01 +02:00
|
|
|
|
|
|
|
echo "# CREATING raspiblitz.conf from your setup choices"
|
|
|
|
|
2021-05-21 11:52:20 -05:00
|
|
|
# prepare config file
|
2021-05-20 22:52:31 -05:00
|
|
|
CONFIGFILE="/mnt/hdd/raspiblitz.conf"
|
2021-05-03 14:56:39 +02:00
|
|
|
sudo rm $CONFIGFILE 2>/dev/null
|
|
|
|
sudo chown admin:admin $CONFIGFILE
|
|
|
|
sudo chmod 777 $CONFIGFILE
|
|
|
|
|
|
|
|
# source the raspiblitz version
|
2021-05-03 14:00:01 +02:00
|
|
|
source /home/admin/_version.info
|
|
|
|
|
2021-05-03 14:56:39 +02:00
|
|
|
# source the setup state fresh
|
|
|
|
source $SETUPFILE
|
|
|
|
|
2021-05-20 21:13:35 -05:00
|
|
|
# write basic config file data
|
2021-05-03 14:00:01 +02:00
|
|
|
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
|
|
|
|
|
2021-05-21 11:52:20 -05:00
|
|
|
fi
|
2021-05-03 14:56:39 +02:00
|
|
|
|
2021-05-21 11:52:20 -05:00
|
|
|
############################################
|
|
|
|
# Enter Passwords
|
|
|
|
# for fresh setup & migration
|
2021-05-03 14:00:01 +02:00
|
|
|
|
2021-05-21 11:52:20 -05:00
|
|
|
echo "# Starting passwords dialog ..."
|
|
|
|
/home/admin/setup.scripts/dialogPasswords.sh
|
2021-05-03 14:00:01 +02:00
|
|
|
|
2021-05-21 11:52:20 -05:00
|
|
|
# set flag for bootstrap process to kick-off provision process
|
|
|
|
sudo sed -i "s/^state=.*/state=waitprovision/g" /home/admin/raspiblitz.info
|
|
|
|
|
2021-05-03 14:00:01 +02:00
|
|
|
clear
|
|
|
|
echo "# setup dialog done - results in:"
|
|
|
|
echo "# $SETUPFILE"
|
|
|
|
echo "# $CONFIGFILE"
|