mirror of
https://github.com/raspiblitz/raspiblitz.git
synced 2025-09-26 19:47:05 +02:00
rearrange setup dialog
This commit is contained in:
@@ -2,19 +2,13 @@
|
||||
|
||||
# get basic system information
|
||||
# these are the same set of infos the WebGUI dialog/controler has
|
||||
source /home/admin/raspiblitz.info
|
||||
source /home/admin/_version.info
|
||||
|
||||
# SETUPFILE
|
||||
# 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
|
||||
# chose how to setup node (fresh or from a upload backup)
|
||||
OPTIONS=()
|
||||
OPTIONS+=(BITCOIN1 "Setup BITCOIN & Lightning Network Daemon (LND)")
|
||||
OPTIONS+=(BITCOIN2 "Setup BITCOIN & c-lightning by blockstream")
|
||||
OPTIONS+=(LITECOIN "Setup LITECOIN & Lightning Network Daemon (LND)")
|
||||
OPTIONS+=(MIGRATION "Upload a Migration File from old RaspiBlitz")
|
||||
OPTIONS+=(FRESHSETUP "Setup a new RaspiBlitz")
|
||||
OPTIONS+=(FROMBACKUP "Upload Migration Backup")
|
||||
OPTIONS+=(SHUTDOWN "Shutdown without Changes")
|
||||
CHOICE=$(dialog --clear \
|
||||
--backtitle "RaspiBlitz ${codeVersion} - Setup" \
|
||||
--title "⚡ Welcome to your RaspiBlitz ⚡" \
|
||||
@@ -23,36 +17,23 @@ CHOICE=$(dialog --clear \
|
||||
"${OPTIONS[@]}" \
|
||||
2>&1 >/dev/tty)
|
||||
clear
|
||||
network=""
|
||||
lightning=""
|
||||
migrationOS=""
|
||||
case $CHOICE in
|
||||
BITCOIN1)
|
||||
network="bitcoin"
|
||||
lightning="lnd"
|
||||
FRESHSETUP)
|
||||
# 0 --> FRESH SETUP
|
||||
exit 0;
|
||||
;;
|
||||
BITCOIN2)
|
||||
network="bitcoin"
|
||||
lightning="cln"
|
||||
FROMBACKUP)
|
||||
# 1 --> UPLOAD MIGRATION BACKUP
|
||||
exit 1
|
||||
;;
|
||||
LITECOIN)
|
||||
network="litecoin"
|
||||
lightning="lnd"
|
||||
SHUTDOWN)
|
||||
# 2 --> SHUTDOWN
|
||||
exit 2
|
||||
;;
|
||||
MIGRATION)
|
||||
migrationOS="raspiblitz"
|
||||
;;
|
||||
esac
|
||||
|
||||
# on cancel - exit with 1
|
||||
if [ "${network}" == "" ] && [ "${migrationOS}" == "" ]; then
|
||||
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
|
||||
*)
|
||||
# 3 --> ESC/CANCEL = EXIT TO TERMINAL
|
||||
clear
|
||||
echo "Exit to Terminal from RaspiBlitz Setup ..."
|
||||
echo "Command to return to Setup --> raspiblitz"
|
||||
exit 3
|
||||
esac
|
80
home.admin/setup.scripts/dialogBlockchainLightning.sh
Normal file
80
home.admin/setup.scripts/dialogBlockchainLightning.sh
Normal 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
|
@@ -99,8 +99,6 @@ if [ "${migrationOS}" == "raspiblitz" ]; then
|
||||
|
||||
# migration OS & Version were already set earlier in setup process - now add migration filename
|
||||
echo "migrationFile='${filename}'" >> $SETUPFILE
|
||||
# user needs to reset password A
|
||||
echo "setPasswordA=1" >> $SETUPFILE
|
||||
exit 0
|
||||
|
||||
fi
|
||||
@@ -126,15 +124,8 @@ Do you want to start migration to RaspiBlitz now?
|
||||
# user cancel - signal by exit code
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# write migration info
|
||||
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
|
||||
|
||||
# signal that user wants to proceed with migration
|
||||
exit 0
|
||||
|
||||
fi
|
||||
@@ -160,14 +151,8 @@ Do you want to start migration to RaspiBlitz now?
|
||||
# user cancel - signal by exit code
|
||||
exit 1
|
||||
fi
|
||||
# write migration info
|
||||
echo "migrationOS='mynode'" >> $SETUPFILE
|
||||
echo "migrationVersion='${migrationVersion}'" >> $SETUPFILE
|
||||
|
||||
# user needs to reset password A
|
||||
echo "setPasswordA=1" >> $SETUPFILE
|
||||
echo "setPasswordB=1" >> $SETUPFILE
|
||||
echo "setPasswordC=1" >> $SETUPFILE
|
||||
# signal that user wants to proceed with migration
|
||||
exit 0
|
||||
|
||||
fi
|
||||
|
@@ -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?
|
||||
" 18 65
|
||||
|
||||
result=$?
|
||||
echo "result($result)"
|
||||
if [ "$?" == "0" ]; then
|
||||
# 0 --> run recover
|
||||
exit 0
|
||||
else
|
||||
# 1 --> other options
|
||||
exit 1
|
||||
fi
|
25
home.admin/setup.scripts/dialogUpdate.sh
Normal file
25
home.admin/setup.scripts/dialogUpdate.sh
Normal 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
|
@@ -19,42 +19,51 @@ sudo chmod 777 $SETUPFILE
|
||||
############################################
|
||||
# QuickOption: Update
|
||||
if [ "${setupPhase}" == "update" ]; then
|
||||
|
||||
echo "TODO: Update"
|
||||
exit 1
|
||||
|
||||
# on cancel - default to normal setup
|
||||
if [ "$?" != "0" ]; then
|
||||
# show update dialog
|
||||
/home/admin/setup.scripts/dialogUpdate.sh
|
||||
if [ "$?" == "0" ]; then
|
||||
# proceed with provision (mark Password A to be set)
|
||||
echo "# OK update process starting .."
|
||||
echo "setPasswordA=1" >> $SETUPFILE
|
||||
else
|
||||
# default to normal setup options
|
||||
setupPhase="setup"
|
||||
echo "# you refused update option - defaulting to normal setup"
|
||||
exit 1
|
||||
echo "# you refused recovery option - defaulting to normal setup"
|
||||
fi
|
||||
fi
|
||||
|
||||
############################################
|
||||
# QuickOption: Recovery
|
||||
if [ "${setupPhase}" == "recovery" ]; then
|
||||
|
||||
echo "TODO: RECOVERY"
|
||||
exit 1
|
||||
|
||||
# on cancel - default to normal setup
|
||||
if [ "$?" != "0" ]; then
|
||||
# show recovery dialog
|
||||
/home/admin/setup.scripts/dialogRecovery.sh
|
||||
if [ "$?" == "0" ]; then
|
||||
# proceed with provision (mark Password A to be set)
|
||||
echo "# OK recover process starting .."
|
||||
echo "setPasswordA=1" >> $SETUPFILE
|
||||
else
|
||||
# default to normal setup options
|
||||
setupPhase="setup"
|
||||
echo "# you refused recovery option - defaulting to normal setup"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
############################################
|
||||
# QuickOption: Migration from other node
|
||||
if [ "${setupPhase}" == "migration" ]; then
|
||||
|
||||
# show recovery dialog
|
||||
echo "# Starting migration dialog ..."
|
||||
/home/admin/setup.scripts/dialogMigration.sh ${migrationOS}
|
||||
|
||||
# on cancel - default to normal setup
|
||||
if [ "$?" != "0" ]; then
|
||||
if [ "$?" == "0" ]; then
|
||||
# mark migration to happen on provision
|
||||
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"
|
||||
echo "# you refused node migration option - defaulting to normal setup"
|
||||
exit 1
|
||||
@@ -63,77 +72,111 @@ if [ "${setupPhase}" == "migration" ]; then
|
||||
fi
|
||||
|
||||
############################################
|
||||
# DEFAULT: Fresh Setup
|
||||
# DEFAULT: Basic Setup menu
|
||||
# user might default to from quick options
|
||||
if [ "${setupPhase}" == "setup" ]; then
|
||||
|
||||
echo "# Starting basic setup dialog ..."
|
||||
/home/admin/setup.scripts/dialogBasicSetup.sh
|
||||
menuresult=$?
|
||||
|
||||
result=$?
|
||||
echo "result(${result})"
|
||||
exit 1
|
||||
# exit to terminal
|
||||
if [ "${menuresult}" == "3" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# shutdown without changes
|
||||
if [ "${menuresult}" == "2" ]; then
|
||||
sudo shutdown now
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# on cancel - let user exit to terminal
|
||||
if [ "$?" != "0" ]; then
|
||||
echo "# you selected cancel - sending exit code 1"
|
||||
exit 1
|
||||
# uplaod and setup from migration backup
|
||||
if [ "${menuresult}" == "1" ]; then
|
||||
/home/admin/setup.scripts/dialogMigration.sh raspiblitz
|
||||
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
|
||||
|
||||
############################################
|
||||
# Setting Name for Node
|
||||
# FRESH SETUP
|
||||
if [ "${menuresult}" == "0" ]; then
|
||||
|
||||
echo "# Starting basic setup dialog ..."
|
||||
/home/admin/setup.scripts/dialogName.sh
|
||||
############################################
|
||||
# Choosing Blockchain & Lightning
|
||||
|
||||
############################################
|
||||
# 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
|
||||
echo "# Starting Blockchain & Lightning selection ..."
|
||||
/home/admin/setup.scripts/dialogBlockchainLightning.sh
|
||||
if [ "$?" == "1" ]; then
|
||||
echo "# you selected cancel - sending exit code 1"
|
||||
exit 1
|
||||
echo "Shutting down ... Restart for new try."
|
||||
sudo shutdown now
|
||||
exit 0
|
||||
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"
|
||||
sudo rm $CONFIGFILE 2>/dev/null
|
||||
sudo chown admin:admin $CONFIGFILE
|
||||
sudo chmod 777 $CONFIGFILE
|
||||
############################################
|
||||
# Lightning Wallet (new or restore) do this before passwords
|
||||
# because password C not needed if LND rescue file is uploaded
|
||||
|
||||
# source the raspiblitz version
|
||||
source /home/admin/_version.info
|
||||
lightningWalletDone=0
|
||||
while [ "${lightningWalletDone}" == "0" ]
|
||||
do
|
||||
|
||||
# source the setup state fresh
|
||||
source $SETUPFILE
|
||||
echo "# Starting lightning wallet dialog ..."
|
||||
/home/admin/setup.scripts/dialogLightningWallet.sh
|
||||
|
||||
# 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
|
||||
# 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"
|
||||
|
||||
# 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
|
||||
|
||||
|
Reference in New Issue
Block a user