From acfc43546f9b1d46e403a969dc9dcc9f83f6d461 Mon Sep 17 00:00:00 2001 From: rootzoll Date: Tue, 25 May 2021 17:29:57 -0500 Subject: [PATCH] prepare final setup dialogs --- home.admin/00raspiblitz.sh | 10 ++ home.admin/_bootstrap.sh | 118 ++++++++++-------- .../setup.scripts/finalDialogControl.sh | 42 +++++++ 3 files changed, 121 insertions(+), 49 deletions(-) create mode 100755 home.admin/setup.scripts/finalDialogControl.sh diff --git a/home.admin/00raspiblitz.sh b/home.admin/00raspiblitz.sh index afbbc654f..c70fda636 100755 --- a/home.admin/00raspiblitz.sh +++ b/home.admin/00raspiblitz.sh @@ -75,6 +75,16 @@ do if [ "${exitMenuLoop}" != "0" ]; then break; fi fi + ##################################### + # SETUP DONE DIALOGS + ##################################### + + # when is needed & bootstrap process signals that it waits for user dialog + if [ "${setupPhase}" != "done" ] && [ "${state}" == "waitfinal" ]; then + # push to final setup gui dialogs + /home/admin/setup.scripts/finalDialogControl.sh + fi + ##################################### # MAIN MENU ##################################### diff --git a/home.admin/_bootstrap.sh b/home.admin/_bootstrap.sh index d9345a54d..4f974f022 100755 --- a/home.admin/_bootstrap.sh +++ b/home.admin/_bootstrap.sh @@ -514,11 +514,22 @@ if [ ${isMounted} -eq 0 ]; then fi ################################################### - # WAIT LOOP: AFTER FRESH SETUP, MIFGRATION OR ERROR + # WAIT LOOP: AFTER FRESH SETUP, MIGRATION # successfull update & recover can skip this ################################################### - until [ "${state}" != "ready" ] + if [ "${setupPhase}" == "setup" ] || [ "${setupPhase}" == "migration" ]; then + echo "# Go into WAIT LOOP for final setup dialog ..." >> $logFile + sed -i "s/^state=.*/state=waitfinal/g" ${infoFile} + sed -i "s/^message=.*/message='Setup Done'/g" ${infoFile} + else + echo "# Skip WAIT LOOP boot directly into main menu ..." >> $logFile + sed -i "s/^state=.*/state=finalready/g" ${infoFile} + sed -i "s/^message=.*/message='Setup Done'/g" ${infoFile} + fi + + source ${infoFile} + until [ "${state}" == "finalready" ] do # TODO: DETECT WHEN USER SETUP IS DONE @@ -544,30 +555,70 @@ if [ ${isMounted} -eq 0 ]; then ######################################## # AFTER FINAL SETUP TASKS + # make sure for future starts that blockchain service gets started after boostrap + sed -i "s/^Wants=.*/Wants=bootstrap.service/g" /etc/systemd/system/${network}d.service + sed -i "s/^After=.*/After=network.target/g" /etc/systemd/system/${network}d.service + # delete provision in progress flag sudo rm /home/admin/provision.flag - # TODO: - echo "TODO: add wants/after to systemd if blockchain service at the end" >> $logFile - exit 1 + # signal that setup phas is over + sed -i "s/^setupPhase=.*/setupPhase='done'/g" ${infoFile} - exit 0 - - echo "rebooting" >> $logFile - echo "state=recovered" >> /home/admin/recover.flag - echo "shutdown in 1min" >> $logFile + #echo "rebooting" >> $logFile + #echo "state=recovered" >> /home/admin/recover.flag + #echo "shutdown in 1min" >> $logFile # save log file for inspection before reboot - sudo cp ${logFile} ${logFile}.recover - sync - sudo shutdown -r -F -t 60 - exit 0 + #sudo cp ${logFile} ${logFile}.recover + #sync + #sudo shutdown -r -F -t 60 + #exit 0 + +else + + ############################ + ############################ + # NORMAL START BOOTSTRAP (not executed after setup) + # Blockchain & Lightning not running + ############################ + + ###################################################################### + # MAKE SURE LND RPC/REST ports are standard & open to all connections + ###################################################################### + sudo sed -i "s/^rpclisten=.*/rpclisten=0.0.0.0:10009/g" /mnt/hdd/lnd/lnd.conf + sudo sed -i "s/^restlisten=.*/restlisten=0.0.0.0:8080/g" /mnt/hdd/lnd/lnd.conf + + ################################# + # FIX BLOCKCHAINDATA OWNER (just in case) + # https://github.com/rootzoll/raspiblitz/issues/239#issuecomment-450887567 + ################################# + sudo chown bitcoin:bitcoin -R /mnt/hdd/bitcoin 2>/dev/null + + ################################# + # FIX BLOCKING FILES (just in case) + # https://github.com/rootzoll/raspiblitz/issues/1901#issue-774279088 + # https://github.com/rootzoll/raspiblitz/issues/1836#issue-755342375 + sudo rm -f /mnt/hdd/bitcoin/bitcoind.pid 2>/dev/null + sudo rm -f /mnt/hdd/bitcoin/.lock 2>/dev/null + + ################################ + # DELETE LOG & LOCK FILES + ################################ + # LND and Blockchain Errors will be still in systemd journals + + # /mnt/hdd/bitcoin/debug.log + sudo rm /mnt/hdd/${network}/debug.log 2>/dev/null + # /mnt/hdd/lnd/logs/bitcoin/mainnet/lnd.log + sudo rm /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log 2>/dev/null + # https://github.com/rootzoll/raspiblitz/issues/1700 + sudo rm /mnt/storage/app-storage/electrs/db/mainnet/LOCK 2>/dev/null fi -############################ -############################ -# NORMAL START BOOTSTRAP -############################ +############################## +############################## +# BOOSTRAP IN EVERY SITUATION +############################## sed -i "s/^setupPhase=.*/setupPhase='starting'/g" ${infoFile} @@ -599,25 +650,6 @@ source ${configFile} # update public IP on boot - set to domain if available /home/admin/config.scripts/internet.sh update-publicip ${lndAddress} -###################################################################### -# MAKE SURE LND RPC/REST ports are standard & open to all connections -###################################################################### -sudo sed -i "s/^rpclisten=.*/rpclisten=0.0.0.0:10009/g" /mnt/hdd/lnd/lnd.conf -sudo sed -i "s/^restlisten=.*/restlisten=0.0.0.0:8080/g" /mnt/hdd/lnd/lnd.conf - -################################# -# FIX BLOCKCHAINDATA OWNER (just in case) -# https://github.com/rootzoll/raspiblitz/issues/239#issuecomment-450887567 -################################# -sudo chown bitcoin:bitcoin -R /mnt/hdd/bitcoin 2>/dev/null - -################################# -# FIX BLOCKING FILES (just in case) -# https://github.com/rootzoll/raspiblitz/issues/1901#issue-774279088 -# https://github.com/rootzoll/raspiblitz/issues/1836#issue-755342375 -sudo rm -f /mnt/hdd/bitcoin/bitcoind.pid 2>/dev/null -sudo rm -f /mnt/hdd/bitcoin/.lock 2>/dev/null - ################################# # MAKE SURE USERS HAVE LATEST LND CREDENTIALS ################################# @@ -653,18 +685,6 @@ fi sed -i "s/^state=.*/state=ready/g" ${infoFile} sed -i "s/^message=.*/message='waiting login'/g" ${infoFile} -################################ -# DELETE LOG & LOCK FILES -################################ -# LND and Blockchain Errors will be still in systemd journals - -# /mnt/hdd/bitcoin/debug.log -sudo rm /mnt/hdd/${network}/debug.log 2>/dev/null -# /mnt/hdd/lnd/logs/bitcoin/mainnet/lnd.log -sudo rm /mnt/hdd/lnd/logs/${network}/${chain}net/lnd.log 2>/dev/null -# https://github.com/rootzoll/raspiblitz/issues/1700 -sudo rm /mnt/storage/app-storage/electrs/db/mainnet/LOCK 2>/dev/null - ##################################### # CLEAN HDD TEMP ##################################### diff --git a/home.admin/setup.scripts/finalDialogControl.sh b/home.admin/setup.scripts/finalDialogControl.sh new file mode 100755 index 000000000..dce1bd9eb --- /dev/null +++ b/home.admin/setup.scripts/finalDialogControl.sh @@ -0,0 +1,42 @@ +#!/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 +if [ "${setupPhase}" == "setup" ]; then + + echo "Write down your seedwords: ${seedwords6x4NEW}" + echo "PRESS ENTER" + readkey + +fi + +############################################ +# SETUP DONE CONFIRMATION (Konfetti Moment) + +# when coming from fresh setup +if [ "${setupPhase}" == "setup" ]; + + echo "Hooray :) Everything is Setup!" + echo "PRESS ENTER" + readkey + +elif [ "${setupPhase}" == "migration" ]; then + + echo "Hooray :) Your Migration to RaspiBlitz is Done!" + echo "PRESS ENTER" + readkey + +else + echo "Missing Final Done Dialog for: ${setupPhase}" + echo "PRESS ENTER" + readkey +fi \ No newline at end of file