2021-04-30 12:44:24 +02:00
#!/bin/bash
2021-05-01 02:42:22 +02:00
# get basic info
2021-04-30 12:44:24 +02:00
source /home/admin/raspiblitz.info
2021-05-01 02:42:22 +02:00
# temp file for dialog results
_temp = $( mktemp -p /dev/shm/)
2021-05-01 15:49:13 +02:00
# flags of what passwords are to set by user
setPasswordA = 1
setPasswordB = 1
setPasswordC = 1
2021-04-30 12:44:24 +02:00
# choose blockchain or select migration
OPTIONS = ( )
2021-05-01 02:42:22 +02:00
OPTIONS += ( BITCOIN1 "Setup BITCOIN & Lightning Network Daemon (LND)" )
OPTIONS += ( BITCOIN2 "Setup BITCOIN & c-lightning by blockstream" )
OPTIONS += ( LITECOIN "Setup LITECOIN & Lightning Network Daemon (LND)" )
2021-04-30 12:44:24 +02:00
OPTIONS += ( MIGRATION "Upload a Migration File from old RaspiBlitz" )
CHOICE = $( dialog --clear \
--backtitle " RaspiBlitz ${ codeVersion } - Setup " \
--title "⚡ Welcome to your RaspiBlitz ⚡" \
--menu "\nChoose how you want to setup your RaspiBlitz: \n " \
2021-05-01 02:42:22 +02:00
13 64 7 \
2021-04-30 12:44:24 +02:00
" ${ OPTIONS [@] } " \
2>& 1 >/dev/tty)
clear
network = ""
2021-05-01 02:42:22 +02:00
lightning = ""
2021-04-30 12:44:24 +02:00
case $CHOICE in
2021-05-01 02:42:22 +02:00
BITCOIN1)
network = "bitcoin"
lightning = "lnd"
2021-04-30 12:44:24 +02:00
; ;
2021-05-01 02:42:22 +02:00
BITCOIN2)
2021-04-30 12:44:24 +02:00
network = "bitcoin"
2021-05-01 02:42:22 +02:00
lightning = "cln"
2021-04-30 12:44:24 +02:00
; ;
LITECOIN)
network = "litecoin"
2021-05-01 02:42:22 +02:00
lightning = "lnd"
2021-04-30 12:44:24 +02:00
; ;
MIGRATION)
2021-05-01 02:19:03 +02:00
# send over to the migration dialogs
/home/admin/00migrationDialog.sh raspiblitz
exit 0
2021-04-30 12:44:24 +02:00
; ;
esac
2021-05-01 02:19:03 +02:00
# on cancel - exit to terminal
if [ " ${ network } " = = "" ] ; then
2021-05-01 02:42:22 +02:00
echo "# you selected cancel - exited to terminal"
2021-05-01 15:49:13 +02:00
echo "# use command 'restart' to reboot & start again"
2021-05-01 02:19:03 +02:00
exit 1
2021-04-30 12:44:24 +02:00
fi
2021-05-01 02:19:03 +02:00
# prepare the config file (what will later become the raspiblitz.config)
source /home/admin/_version.info
CONFIGFILE = "/home/admin/raspiblitz.config.tmp"
rm $CONFIGFILE 2>/dev/null
echo "# RASPIBLITZ CONFIG FILE" > $CONFIGFILE
echo " raspiBlitzVersion=' ${ codeVersion } ' " >> $CONFIGFILE
echo "lcdrotate=1" >> $CONFIGFILE
2021-05-01 02:42:22 +02:00
echo " lightning= ${ lightning } " >> $CONFIGFILE
2021-05-01 02:19:03 +02:00
echo " network= ${ network } " >> $CONFIGFILE
echo "chain=main" >> $CONFIGFILE
2021-05-01 15:49:13 +02:00
echo "runBehindTor=on" >> $CONFIGFILE
2021-05-01 02:19:03 +02:00
# prepare the setup file (that constains info just needed for the rest of setup process)
SETUPFILE = "/home/admin/raspiblitz.setup.tmp"
rm $SETUPFILE 2>/dev/null
echo "# RASPIBLITZ SETUP FILE" > $SETUPFILE
2021-04-30 12:44:24 +02:00
###################
# ENTER NAME
###################
# welcome and ask for name of RaspiBlitz
result = ""
while [ ${# result } -eq 0 ]
do
l1 = "Please enter the name of your new RaspiBlitz:\n"
l2 = "one word, keep characters basic & not too long"
dialog --backtitle " RaspiBlitz - Setup ( ${ network } / ${ chain } ) " --inputbox " $l1 $l2 " 11 52 2>$_temp
result = $( cat $_temp | tr -dc '[:alnum:]-.' | tr -d ' ' )
shred -u $_temp
echo "processing ..."
sleep 3
done
2021-05-01 15:49:13 +02:00
echo " hostname= ${ result } " >> $CONFIGFILE
###################
# DECIDE LIGHTNING
# do this before passwords, because password C not needed if LND rescue file is uploaded
###################
# flags for sub dialogs after choice
uploadLNDRESCUE = 0
enterSEED = 0
uploadSCB = 0
OPTIONS = ( )
OPTIONS += ( NEW "Setup a brand new Lightning Node (DEFAULT)" )
OPTIONS += ( OLD "I had an old Node I want to recover/restore" )
CHOICE = $( dialog --backtitle "RaspiBlitz" --clear --title "LND Setup" --menu "LND Data & Wallet" 11 60 6 " ${ OPTIONS [@] } " 2>& 1 >/dev/tty)
if [ " ${ CHOICE } " = = "NEW" ] ; then
# mark all passwords to be set at the end
setPasswordA = 1
setPasswordB = 1
setPasswordC = 1
elif [ " ${ CHOICE } " = = "OLD" ] ; then
# get more details what kind of old lightning wallet user has
OPTIONS = ( )
OPTIONS += ( LNDRESCUE "LND tar.gz-Backupfile (BEST)" )
OPTIONS += ( SEED+SCB "Seed & channel.backup file (OK)" )
OPTIONS += ( ONLYSEED "Only Seed Word List (FALLBACK)" )
CHOICE = $( dialog --backtitle "RaspiBlitz" --clear --title "RECOVER LND DATA & WALLET" --menu "Data you have to recover from?" 11 60 6 " ${ OPTIONS [@] } " 2>& 1 >/dev/tty)
if [ " ${ CHOICE } " = = "LNDRESCUE" ] ; then
# just activate LND rescue upload
uploadLNDRESCUE = 1
# dont set password c anymore later on
setPasswordC = 0
elif [ " ${ CHOICE } " = = "SEED+SCB" ] ; then
# activate SEED input & SCB upload
enterSEED = 1
uploadSCB = 1
elif [ " ${ CHOICE } " = = "ONLYSEED" ] ; then
# activate SEED input & SCB upload
enterSEED = 1
2021-04-30 12:44:24 +02:00
2021-05-01 15:49:13 +02:00
else
echo "# you selected cancel - exited to terminal"
echo "# use command 'restart' to reboot & start again"
exit 1
fi
2021-04-30 12:44:24 +02:00
else
2021-05-01 15:49:13 +02:00
echo "# you selected cancel - exited to terminal"
echo "# use command 'restart' to reboot & start again"
exit 1
fi
# UPLOAD LND RESCUE FILE dialog (if activated by dialogs above)
if [ ${ uploadLNDRESCUE } -eq 1 ] ; then
echo "TODO: UPLOAD LND RESCUE FILE"
exit 1
fi
# INPUT LIGHTNING SEED dialog (if activated by dialogs above)
if [ ${ enterSEED } -eq 1 ] ; then
echo "TODO: INPUT LIGHTNING SEED"
exit 1
fi
# UPLOAD STATIC CHANNEL BACKUP FILE dialog (if activated by dialogs above)
if [ ${ uploadSCB } -eq 1 ] ; then
echo "TODO: UPLOAD STATIC CHANNEL BACKUP FILE"
exit 1
2021-04-30 12:44:24 +02:00
fi
###################
2021-05-01 15:49:13 +02:00
# ENTER PASSWORDS ---> combine with migration dialog to reduce code duplication
2021-04-30 12:44:24 +02:00
###################
# show password info dialog
2021-05-01 15:49:13 +02:00
dialog --backtitle "RaspiBlitz - Setup" --msgbox " RaspiBlitz uses 3 different passwords.
Referenced as password A, B & C.
2021-04-30 12:44:24 +02:00
2021-05-01 15:49:13 +02:00
PASSWORD A) Main User Password ( SSH & WebUI, sudo)
PASSWORD B) APP Password ( RPC & Additional Apps)
PASSWORD C) Lightning Wallet Password for Unlock
2021-04-30 12:44:24 +02:00
2021-05-01 15:49:13 +02:00
Set now the 3 passwords - all min 8 chars,
2021-04-30 12:44:24 +02:00
no spaces and only special characters - or .
Write them down & store them in a safe place.
2021-05-01 15:49:13 +02:00
" 15 54
2021-04-30 12:44:24 +02:00
2021-05-01 15:49:13 +02:00
clear
sudo /home/admin/config.scripts/blitz.setpassword.sh x "PASSWORD A - Main User Password" $_temp
password = $( sudo cat $_temp )
echo " passwordA=' ${ password } ' " >> $SETUPFILE
dialog --backtitle "RaspiBlitz - Setup" --msgbox "\n Password A set" 7 20
2021-04-30 12:44:24 +02:00
2021-05-01 15:49:13 +02:00
clear
sudo /home/admin/config.scripts/blitz.setpassword.sh x "PASSWORD B - APP Password" $_temp
password = $( sudo cat $_temp )
echo " passwordB=' ${ password } ' " >> $SETUPFILE
dialog --backtitle "RaspiBlitz - Setup" --msgbox "\n Password B set" 7 20
2021-04-30 12:44:24 +02:00
2021-05-01 15:49:13 +02:00
clear
sudo /home/admin/config.scripts/blitz.setpassword.sh x "PASSWORD C - Lightning Wallet Password" $_temp
password = $( sudo cat $_temp )
echo " passwordC=' ${ password } ' " >> $SETUPFILE
dialog --backtitle "RaspiBlitz - Setup" --msgbox "\n Password C set" 7 20
2021-04-30 12:44:24 +02:00
2021-05-01 15:49:13 +02:00
echo "TODO: continue with further "
exit 1
2021-04-30 12:44:24 +02:00
clear