2021-08-04 00:18:30 +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-12-14 23:34:35 +01:00
source /var/cache/raspiblitz/temp/raspiblitz.setup
2021-08-04 00:18:30 +02:00
2021-10-07 13:57:03 +02:00
# make sure also admin user can write to log
sudo chmod 777 /home/admin/raspiblitz.log
2021-08-04 00:18:30 +02:00
############################################
# SHOW SEED WORDS AFTER SETUP
if [ " ${ lightning } " = = "lnd" ] ; then
walletName = "LND"
2021-09-26 10:30:09 +01:00
elif [ " ${ lightning } " = = "cl" ] ; then
2021-08-04 00:18:30 +02:00
walletName = "C-lightning"
fi
if [ " ${ setupPhase } " = = "setup" ] && [ " ${ seedwords6x4NEW } " != "" ] ; then
ack = 0
while [ ${ ack } -eq 0 ]
do
whiptail --title "IMPORTANT SEED WORDS - PLEASE WRITE DOWN" \
--msgbox " Created the ${ walletName } wallet.\nStore these numbered words in a safe location:\n\n ${ seedwords6x4NEW } " 13 76
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
fi
############################################
# BLOCKCHAIN INFO & OPTIONS
# get fresh data
2022-01-25 12:07:11 +01:00
source <( /home/admin/_cache.sh get btc_default_sync_percentage network)
2021-12-14 23:34:35 +01:00
syncProgressFull = $( echo " ${ btc_default_sync_percentage } " | cut -d "." -f1)
2021-08-04 00:18:30 +02:00
if [ " ${ syncProgressFull } " != "" ] && [ " ${ network } " = = "bitcoin" ] && [ ${ syncProgressFull } -lt 75 ] ; then
# offer choice to copy blockchain over LAN
OPTIONS = ( )
OPTIONS += ( SELFSYNC "Run full self sync/validation (takes long)" )
2021-10-04 09:56:16 +02:00
OPTIONS += ( COPY "Copy from Computer/RaspiBlitz over LAN (3-10h)" )
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 66 7 " ${ OPTIONS [@] } " 2>& 1 >/dev/tty)
2021-08-04 00:18:30 +02:00
if [ " ${ CHOICESUB } " = = "COPY" ] ; then
/home/admin/config.scripts/blitz.copychain.sh target
fi
fi
############################################
# SETUP DONE CONFIRMATION (Konfetti Moment)
# when coming from fresh setup
if [ " ${ setupPhase } " = = "setup" ] ; then
clear
2021-09-07 17:42:49 +01:00
whiptail --title " Setup Done " --msgbox " \
Your RaspiBlitz setup is done . Welcome new Node Operator! :D\n
2021-10-05 12:27:52 +02:00
After the final reboot there can be some waiting time until your blockchain is fully synced before you can enter the RaspiBlitz user menu.\n
2021-09-07 17:42:49 +01:00
It is safe to log out during the sync and return later.\n
2021-10-05 12:27:52 +02:00
" 13 65
2021-08-04 00:18:30 +02:00
# when coming from migration from other node
elif [ " ${ setupPhase } " = = "migration" ] ; then
clear
whiptail --title " Migration Done " --msgbox " \
Your running now RaspiBlitz. Welcome to the family! :D\n
2021-10-05 12:27:52 +02:00
After the final reboot there might now be some waiting time until your Blockchain is fully synced before you can enter the RaspiBlitz user menu.\n
2021-08-04 00:18:30 +02:00
Its safe to logout during sync and return later.\n
2021-10-05 12:27:52 +02:00
" 13 65
2021-08-04 00:18:30 +02:00
# just in case then from another phase
else
clear
2021-10-05 12:27:52 +02:00
whiptail --title " Recovery/Update Done " --msgbox " \
Your RaspiBlitz is now ready again :D\n
After the final reboot there might now be some waiting time until your Blockchain sync has catched up before you can enter the RaspiBlitz user menu.\n
" 11 65
2021-08-04 00:18:30 +02:00
fi
2021-10-05 12:27:52 +02:00
########################################
# AFTER FINAL SETUP TASKS
2021-10-07 13:17:11 +02:00
echo "# AFTER FINAL SETUP TASKS" >> /home/admin/raspiblitz.log
2021-10-05 12:27:52 +02:00
2021-10-07 12:06:24 +02:00
# source info fresh
source /home/admin/raspiblitz.info
2021-10-07 13:17:11 +02:00
echo "# source /home/admin/raspiblitz.info" >> /home/admin/raspiblitz.log
cat /home/admin/raspiblitz.info >> /home/admin/raspiblitz.log
# make sure network defaults to bitcoin
if [ " ${ network } " = = "" ] ; then
echo "# WARN: default network to bitcoin" >> /home/admin/raspiblitz.log
network = "bitcoin"
fi
2021-10-07 12:06:24 +02:00
2021-10-05 12:27:52 +02:00
# make sure for future starts that blockchain service gets started after bootstrap
# so deamon reloas needed ... system will go into reboot after last loop
# needs to be after wait loop because otherwise the "restart" on COPY OVER LAN will not work
2021-10-05 12:36:56 +02:00
echo " # Updating service ${ network } d.service ... "
2021-10-05 12:27:52 +02:00
sudo sed -i "s/^Wants=.*/Wants=bootstrap.service/g" /etc/systemd/system/${ network } d.service
sudo sed -i "s/^After=.*/After=bootstrap.service/g" /etc/systemd/system/${ network } d.service
2021-10-07 12:06:24 +02:00
sudo systemctl daemon-reload 2>/dev/null
2021-10-05 12:27:52 +02:00
# delete setup data from RAM
2021-12-14 23:34:35 +01:00
sudo rm /var/cache/raspiblitz/temp/raspiblitz.setup
2021-10-05 12:27:52 +02:00
# signal that setup phase is over
2021-12-14 23:34:35 +01:00
/home/admin/_cache.sh set setupPhase "done"
2021-10-05 12:27:52 +02:00
2021-10-07 12:06:24 +02:00
sleep 2
2021-10-05 13:47:36 +02:00
clear
2021-12-14 23:34:35 +01:00
source <( /home/admin/_cache.sh get internet_localip)
/home/admin/_cache.sh set setupPhase "done"
2021-10-05 13:47:36 +02:00
echo "***********************************************************"
echo "RaspiBlitz going to reboot"
echo "***********************************************************"
echo "This is the final setup reboot - you will get disconnected."
echo "SSH again into system with:"
2021-12-14 23:34:35 +01:00
echo " ssh admin@ ${ internet_localip } "
2021-10-05 13:47:36 +02:00
echo "Use your password A"
echo "***********************************************************"
2021-10-07 13:17:11 +02:00
echo "# final setup reboot ..." >> /home/admin/raspiblitz.log
2021-10-05 13:47:36 +02:00
2021-10-05 12:27:52 +02:00
########################################
# AFTER SETUP REBOOT
# touchscreen activation, start with configured SWAP, fix LCD text bug
sudo cp /home/admin/raspiblitz.log /home/admin/raspiblitz.setup.log
2022-01-04 23:41:19 +01:00
sudo chmod 640 /home/admin/raspiblitz.setup.log
2022-01-16 22:07:17 +01:00
sudo chown root:sudo /home/admin/raspiblitz.setup.log
2021-10-05 12:27:52 +02:00
timeout 120 /home/admin/config.scripts/blitz.shutdown.sh reboot finalsetup
# if system has not rebooted yet - force reboot directly
sudo shutdown -r now
sleep 120
echo "FAIL: automatic final reboot didnt worked .. please report to dev team and try to reboot manually"
exit 0