2021-05-25 17:29:57 -05: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
SETUPFILE = "/var/cache/raspiblitz/temp/raspiblitz.setup"
source ${ SETUPFILE }
############################################
# SHOW SEED WORDS AFTER SETUP
2021-06-19 00:06:58 +02:00
if [ " ${ setupPhase } " = = "setup" ] && [ " ${ seedwords6x4NEW } " != "" ] ; then
2021-05-25 18:11:58 -05:00
ack = 0
while [ ${ ack } -eq 0 ]
do
2021-05-25 18:13:20 -05:00
whiptail --title "IMPORTANT SEED WORDS - PLEASE WRITE DOWN" --msgbox " LND Wallet got created. Store these numbered words in a safe location:\n\n ${ seedwords6x4NEW } " 12 76
2021-05-25 18:11:58 -05:00
whiptail --title "Please Confirm" --yes-button "Show Again" --no-button "CONTINUE" --yesno " Are you sure that you wrote down the word list?" 8 55
if [ $? -eq 1 ] ; then
ack = 1
fi
done
2021-05-25 17:29:57 -05:00
fi
2021-05-25 22:10:57 -05:00
############################################
# BLOCKCHAIN INFO & OPTIONS
2021-06-25 00:17:54 +02:00
# get fresh data
source <( sudo /home/admin/config.scripts/blitz.statusscan.sh)
2021-07-02 22:16:02 +02:00
syncProgressFull = $( echo " ${ syncProgress } " | cut -d "." -f1)
if [ " ${ syncProgressFull } " != "" ] && [ " ${ network } " = = "bitcoin" ] && [ ${ syncProgressFull } -lt 75 ] ; then
2021-06-19 00:06:58 +02:00
# offer choice to copy blockchain over LAN
OPTIONS = ( )
2021-07-16 00:10:00 +02:00
OPTIONS += ( SELFSYNC "Run full self sync/validation (takes long)" )
2021-06-19 02:13:39 +02:00
OPTIONS += ( COPY "Copy from Computer/RaspiBlitz over LAN (±6h)" )
2021-06-19 00:56:56 +02:00
CHOICESUB = $( dialog --backtitle "RaspiBlitz" --clear --title " Blockchain Sync/Validation " --menu " \nYour Blockchain sync is just at ${ syncProgress } %\nThe full validation might take multiple days to finish.\n\nHow do you want to proceed: " 13 63 7 " ${ OPTIONS [@] } " 2>& 1 >/dev/tty)
2021-06-19 00:06:58 +02:00
2021-06-19 02:14:23 +02:00
if [ " ${ CHOICESUB } " = = "COPY" ] ; then
2021-06-21 01:17:38 +02:00
/home/admin/config.scripts/blitz.copychain.sh target
2021-06-19 02:13:39 +02:00
fi
2021-07-02 23:11:50 +02:00
2021-05-25 22:10:57 -05:00
fi
2021-06-20 19:11:09 +02:00
############# SCB activation
2021-06-25 00:14:41 +02:00
# check if there is a channel.backup to activate
gotSCB = $( ls /home/admin/channel.backup 2>/dev/null | grep -c 'channel.backup' )
if [ " ${ gotSCB } " = = "1" ] ; then
echo "*** channel.backup Recovery ***"
lncli --chain= ${ network } restorechanbackup --multi_file= /home/admin/channel.backup 2>/home/admin/.error.tmp
error = ` cat /home/admin/.error.tmp`
rm /home/admin/.error.tmp 2>/dev/null
if [ ${# error } -gt 0 ] ; then
# output error message
echo ""
echo "!!! FAIL !!! SOMETHING WENT WRONG:"
echo " ${ error } "
# check if its possible to give background info on the error
notMachtingSeed = $( echo $error | grep -c 'unable to unpack chan backup' )
if [ ${ notMachtingSeed } -gt 0 ] ; then
echo "--> ERROR BACKGROUND:"
echo "The WORD SEED is not matching the channel.backup file."
echo "Either there was an error in the word seed list or"
echo "or the channel.backup file is from another RaspiBlitz."
2021-06-20 19:11:09 +02:00
echo
2021-06-25 00:14:41 +02:00
fi
# basic info on error
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo
echo "You can try after full setup to restore channel.backup file again with:"
echo " lncli --chain= ${ network } restorechanbackup --multi_file=/home/admin/channel.backup "
echo
echo "Press ENTER to continue for now ..."
read key
else
mv /home/admin/channel.backup /home/admin/channel.backup.done
dialog --title " OK channel.backup IMPORT " --msgbox "
2021-06-20 19:11:09 +02:00
LND accepted the channel.backup file you uploaded.
It will now take around a hour until you can see,
if LND was able to recover funds from your channels.
2021-06-25 00:14:41 +02:00
" 9 56
2021-06-20 19:11:09 +02:00
fi
2021-06-25 00:14:41 +02:00
fi
2021-06-20 19:11:09 +02:00
2021-05-25 17:29:57 -05:00
############################################
# SETUP DONE CONFIRMATION (Konfetti Moment)
# when coming from fresh setup
2021-05-25 18:15:45 -05:00
if [ " ${ setupPhase } " = = "setup" ] ; then
2021-05-25 18:08:45 -05:00
clear
2021-06-19 00:06:58 +02:00
whiptail --title " SetUp Done " --msgbox " \
Your RaspiBlitz Setup is done . Welcome new node operator! :D\n
There might now be some waiting time until your Blockchain is fully synced before you can enter the RaspiBlitz user menu.\n
Its safe to logout during sync and return later.\n
" 12 65
2021-05-25 17:29:57 -05:00
2021-05-25 18:08:45 -05:00
# when coming from migration from other node
2021-05-25 17:29:57 -05:00
elif [ " ${ setupPhase } " = = "migration" ] ; then
2021-05-25 18:08:45 -05:00
clear
2021-06-19 00:06:58 +02:00
whiptail --title " Migration Done " --msgbox " \
Your running now RaspiBlitz. Welcome to the family! :D\n
There might now be some waiting time until your Blockchain is fully synced before you can enter the RaspiBlitz user menu.\n
Its safe to logout during sync and return later.\n
" 12 65
2021-05-25 17:29:57 -05:00
2021-05-25 18:08:45 -05:00
# just in case then from another phase
2021-05-25 17:29:57 -05:00
else
2021-05-25 18:08:45 -05:00
clear
2021-05-25 17:29:57 -05:00
echo " Missing Final Done Dialog for: ${ setupPhase } "
echo "PRESS ENTER"
2021-05-25 18:15:00 -05:00
read key
2021-05-25 18:10:22 -05:00
fi
2021-06-20 23:30:56 +02:00
echo "Starting ... (please wait)"
2021-05-26 12:06:40 -05:00
2021-05-25 18:21:26 -05:00
# signal to backend that all is good and it can continue
2021-07-02 23:11:50 +02:00
sudo sed -i "s/^state=.*/state='ready'/g" /home/admin/raspiblitz.info