From 1768323e0d2521516f07f00054acc36688645a33 Mon Sep 17 00:00:00 2001 From: rootzoll Date: Thu, 6 Dec 2018 17:39:06 +0100 Subject: [PATCH] Update & Provisioning --- README.md | 2 +- home.admin/00infoLCD.sh | 3 +- home.admin/00mainMenu.sh | 9 +- home.admin/10setupBlitz.sh | 4 +- home.admin/20recoverDialog.sh | 84 +++++++++++ .../{20initDialog.sh => 20setupDialog.sh} | 0 home.admin/40addHDD.sh | 63 ++++---- home.admin/70initLND.sh | 1 + home.admin/90finishSetup.sh | 45 +----- home.admin/95finalSetup.sh | 45 ++++++ home.admin/_bootstrap.migration.sh | 54 ++++--- home.admin/_bootstrap.presync.sh | 5 - home.admin/_bootstrap.provision.sh | 135 ++++++++++++++++++ home.admin/_bootstrap.sh | 17 ++- 14 files changed, 363 insertions(+), 104 deletions(-) create mode 100755 home.admin/20recoverDialog.sh rename home.admin/{20initDialog.sh => 20setupDialog.sh} (100%) create mode 100755 home.admin/95finalSetup.sh create mode 100644 home.admin/_bootstrap.provision.sh diff --git a/README.md b/README.md index 7950eaa..c88e5b1 100644 --- a/README.md +++ b/README.md @@ -115,7 +115,7 @@ First thing to setup is giving your RaspiBlitz an name: This name is given to the RaspiBlitz as hostname in the local network and later on also for the alias of the lightning node. -*Background: This and the following setup dialogues are part of the script `20initDialog.sh`. The idea is to request much as needed setup information from the user at the start in this dialogs, so after that the setup can just run without many breaks.* +*Background: This and the following setup dialogues are part of the script `20setupDialog.sh`. The idea is to request much as needed setup information from the user at the start in this dialogs, so after that the setup can just run without many breaks.* Then the user gets requested to write down 4 passwords: diff --git a/home.admin/00infoLCD.sh b/home.admin/00infoLCD.sh index cd63ab5..6535f9c 100755 --- a/home.admin/00infoLCD.sh +++ b/home.admin/00infoLCD.sh @@ -21,7 +21,6 @@ while : # get the local network IP to be displayed on the lCD localip=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/') - dhcpMissing= if [ ${#localip} -eq 0 ]; then @@ -34,7 +33,7 @@ while : elif [ "${localip:0:4}" = "169." ]; then - # waiting for IP in general + # waiting for DHCP in general l1="Waiting for DHCP ...\n" l2="Not able to get local IP.\n" l3="Is Router working?\n" diff --git a/home.admin/00mainMenu.sh b/home.admin/00mainMenu.sh index 124b753..18588d0 100755 --- a/home.admin/00mainMenu.sh +++ b/home.admin/00mainMenu.sh @@ -32,12 +32,19 @@ if [ ${bootstrapInfoExists} -eq 1 ]; then echo "device=${device}" >> $infoFile fi - # signal if bootstrap is not ready yet + # signal if bootstrap recover is not ready yet if [ "${state}" = "recovering" ]; then echo "WARNING: bootstrap is still updating - please close SSH and login later again" exit 1 fi + # signal that after bootstrap recover user dialog is needed + if [ "${state}" = "recovered" ]; then + echo "System recovered - needs final user settings" + ./20recoverDialog.sh + exit 1 + fi + fi ## default menu settings diff --git a/home.admin/10setupBlitz.sh b/home.admin/10setupBlitz.sh index 989b2f2..408c246 100755 --- a/home.admin/10setupBlitz.sh +++ b/home.admin/10setupBlitz.sh @@ -21,6 +21,7 @@ if [ ${setupStep} -gt 89 ];then echo "FINISH by setupstep(${setupStep})" sleep 3 ./90finishSetup.sh + ./95finalSetup.sh exit 0 fi @@ -77,6 +78,7 @@ if [ ${lndRunning} -eq 1 ]; then echo "FINSIH ... " sleep 3 ./90finishSetup.sh + ./95finalSetup.sh exit 0 fi #end - when lighting is running @@ -178,7 +180,7 @@ fi # end HDD is already auto-mountes if [ ${setupStep} -eq 0 ]; then # run initial user dialog - ./20initDialog.sh + ./20setupDialog.sh # set SetupState sudo sed -i "s/^setupStep=.*/setupStep=20/g" ${infoFile} diff --git a/home.admin/20recoverDialog.sh b/home.admin/20recoverDialog.sh new file mode 100755 index 0000000..12a5b97 --- /dev/null +++ b/home.admin/20recoverDialog.sh @@ -0,0 +1,84 @@ +#!/bin/bash +_temp="./download/dialog.$$" + +## get basic info +source /home/admin/raspiblitz.info 2>/dev/null + +passwordValid=0 +result="" +while [ ${passwordValid} -eq 0 ] + do + # show password info dialog + dialog --backtitle "RaspiBlitz - Setup" --msgbox "RaspiBlitz uses 4 different passwords. +Referenced as password A, B, C and D. + +A) Master User Password +B) Blockchain RPC Password +C) LND Wallet Password +D) LND Seed Password + +Choose now 4 new passwords - all min 8 chars, +no spaces and only special characters - or . +Write them down & store them in a safe place. +" 15 52 + + # ask user for new password A + dialog --backtitle "RaspiBlitz - Setup"\ + --inputbox "Please enter your Master/Admin Password A:\n!!! This is new password to login per SSH !!!" 10 52 2>$_temp + + # get user input + result=$( cat $_temp ) + shred $_temp + passwordValid=1 + + clearedResult=$(echo "${result}" | tr -dc '[:alnum:]-.' | tr -d ' ') + if [ ${#clearedResult} != ${#result} ] || [ ${#clearedResult} -eq 0 ]; then + clear + echo "FAIL - Password contained not allowed chars (see next screen)" + echo "Press ENTER to continue .." + read key + passwordValid=0 + else + + # change user passwords and then change hostname + echo "pi:$result" | sudo chpasswd + echo "root:$result" | sudo chpasswd + echo "bitcoin:$result" | sudo chpasswd + echo "admin:$result" | sudo chpasswd + sleep 1 + + # sucess info dialog + dialog --backtitle "RaspiBlitz" --msgbox "OK - password changed to '$result'\nfor all users pi, admin, root & bitcoin" 6 52 + + # repeat until user input is nit length 0 + result="" + dialog --backtitle "RaspiBlitz - Setup"\ + --inputbox "Enter your RPC Password B:" 9 52 2>$_temp + result=$( cat $_temp ) + shred $_temp + + clearedResult=$(echo "${result}" | tr -dc '[:alnum:]-.' | tr -d ' ') + if [ ${#clearedResult} != ${#result} ] || [ ${#clearedResult} -eq 0 ]; then + clear + echo "FAIL - Password contained not allowed chars (see next screen)" + echo "Press ENTER to continue to start again" + read key + passwordValid=0 + else + + # set Blockchain RPC Password (for admin cli & template for user bitcoin) + sed -i "s/^rpcpassword=.*/rpcpassword=${result}/g" /home/admin/assets/${network}.conf + sed -i "s/^${network}d.rpcpass=.*/${network}d.rpcpass=${result}/g" /home/admin/assets/lnd.${network}.conf + + # success info dialog + dialog --backtitle "RaspiBlitz - SetUP" --msgbox "OK - RPC password changed to '$result'\n\nNow starting the Setup of your RaspiBlitz." 7 52 + clear + + fi + + fi + + done + + + diff --git a/home.admin/20initDialog.sh b/home.admin/20setupDialog.sh similarity index 100% rename from home.admin/20initDialog.sh rename to home.admin/20setupDialog.sh diff --git a/home.admin/40addHDD.sh b/home.admin/40addHDD.sh index aeaf445..c64bea2 100755 --- a/home.admin/40addHDD.sh +++ b/home.admin/40addHDD.sh @@ -5,6 +5,7 @@ echo "" source /home/admin/raspiblitz.info 2>/dev/null echo "*** Adding HDD to the System ***" +echo "started from state(${state})" sleep 5 existsHDD=$(lsblk | grep -c sda) if [ ${existsHDD} -gt 0 ]; then @@ -34,39 +35,53 @@ if [ ${existsHDD} -gt 0 ]; then fi fstabOK=$(cat /etc/fstab | grep -c ${uuid}) if [ ${fstabOK} -eq 1 ]; then - echo "OK - HDD is listed in /etc/fstab" - echo "" - echo "*** Mount HDD ***" - sudo mkdir /mnt/hdd - sudo mount -a - mountOK=$(df | grep -c /mnt/hdd) - if [ ${mountOK} -eq 1 ]; then - echo "OK - HDD is mounted" - echo "" + echo "OK - HDD is listed in /etc/fstab" + echo "" + echo "*** Mount HDD ***" + sudo mkdir /mnt/hdd + sudo mount -a + mountOK=$(df | grep -c /mnt/hdd) + if [ ${mountOK} -eq 1 ]; then + echo "OK - HDD is mounted" + echo "" - # set SetupState - sudo sed -i "s/^setupStep=.*/setupStep=40/g" /home/admin/raspiblitz.info + # set SetupState + sudo sed -i "s/^setupStep=.*/setupStep=40/g" /home/admin/raspiblitz.info - echo "*** Analysing HDD Content ***" - if [ -d "/mnt/hdd/${network}" ]; then - sudo chown -R bitcoin:bitcoin /mnt/hdd/bitcoin 2>/dev/null - sudo chown -R bitcoin:bitcoin /mnt/hdd/litecoin 2>/dev/null - echo "Looks like the HDD is prepared with the Blockchain." - echo "Continuing with finishing the system setup ..." - ./60finishHDD.sh - else - # HDD is empty - let setupBlitz - display next options - ./10setupBlitz.sh - fi - else + echo "*** Analysing HDD Content ***" + if [ -d "/mnt/hdd/${network}" ]; then + sudo chown -R bitcoin:bitcoin /mnt/hdd/bitcoin 2>/dev/null + sudo chown -R bitcoin:bitcoin /mnt/hdd/litecoin 2>/dev/null + echo "Looks like the HDD is prepared with the Blockchain." + + if [ "${state}" = "recovering" ]; then + # when HDD got added on update/provisioning + echo "OK HDD got added ... returning to provisioning" + exit 1 + else + # when normal setup + echo "Continuing with finishing the system setup ..." + ./60finishHDD.sh + fi + + else + # HDD is empty - let setupBlitz - display next options + echo "HDD empty --> go setup" + ./10setupBlitz.sh + fi # END Analysing HDD Content + + else echo "FAIL - was not able to mount" - fi + fi # END Mount check + else echo "FAIL - was not able to edit /etc/fstab" fi + else echo "FAIL - the HDD is not in ext4 format AND named 'BLOCKCHAIN'" fi + fi else echo "FAIL - no HDD as device sda found" diff --git a/home.admin/70initLND.sh b/home.admin/70initLND.sh index 7b09e10..a99c320 100755 --- a/home.admin/70initLND.sh +++ b/home.admin/70initLND.sh @@ -238,3 +238,4 @@ sudo sed -i "s/^setupStep=.*/setupStep=80/g" /home/admin/raspiblitz.info ###### finishSetup ./90finishSetup.sh +./95finalSetup.sh diff --git a/home.admin/90finishSetup.sh b/home.admin/90finishSetup.sh index ff97224..04b75d4 100755 --- a/home.admin/90finishSetup.sh +++ b/home.admin/90finishSetup.sh @@ -4,12 +4,6 @@ echo "" # add bonus scripts ./91addBonus.sh -# load setup config -source /home/admin/raspiblitz.info - -# load version -source /home/admin/_version.info - ###### SWAP & FS echo "*** SWAP file ***" swapExists=$(swapon -s | grep -c /mnt/hdd/swapfile) @@ -87,41 +81,4 @@ sudo apt-get upgrade -f -y --allow-change-held-packages echo "OK - System is now up to date" # mark setup is done -sudo sed -i "s/^setupStep=.*/setupStep=90/g" /home/admin/raspiblitz.info - -# show info to user -dialog --backtitle "RaspiBlitz - Setup" --title " RaspiBlitz Setup is done :) " --msgbox " - Press OK for a final reboot. - - Remember: After every reboot - you need to unlock the LND wallet. -" 10 42 - -# set the hostname inputed on initDialog -if [ ${#hostname} -gt 0 ]; then - echo "Setting new network hostname '$hostname'" - sudo raspi-config nonint do_hostname ${hostname} -else - echo "WARN: hostname not set" -fi - -# mark setup is done (100%) -sudo sed -i "s/^setupStep=.*/setupStep=100/g" /home/admin/raspiblitz.info - -# init the RASPIBLITZ Config -configFile="/mnt/hdd/raspiblitz.conf" -echo "# RASPIBLITZ CONFIG FILE" > $configFile -echo "raspiBlitzVersion='${codeVersion}'" >> $configFile -sudo chmod 777 ${configFile} - -# transfer data from SD info file -echo "hostname=${hostname}" >> $configFile -echo "network=${network}" >> $configFile -echo "chain=${chain}" >> $configFile - -# let migration/init script do the rest -./_bootstrap.migration.sh - -clear -echo "Setup done. Rebooting now." -sudo shutdown -r now +sudo sed -i "s/^setupStep=.*/setupStep=90/g" /home/admin/raspiblitz.info \ No newline at end of file diff --git a/home.admin/95finalSetup.sh b/home.admin/95finalSetup.sh new file mode 100755 index 0000000..721e1ac --- /dev/null +++ b/home.admin/95finalSetup.sh @@ -0,0 +1,45 @@ +#!/bin/bash +echo "" + +# load setup config +source /home/admin/raspiblitz.info + +# load version +source /home/admin/_version.info + +# show info to user +dialog --backtitle "RaspiBlitz - Setup" --title " RaspiBlitz Setup is done :) " --msgbox " + Press OK for a final reboot. + + Remember: After every reboot + you need to unlock the LND wallet. +" 10 42 + +# init the RASPIBLITZ Config +configFile="/mnt/hdd/raspiblitz.conf" +echo "# RASPIBLITZ CONFIG FILE" > $configFile +echo "raspiBlitzVersion='${codeVersion}'" >> $configFile +sudo chmod 777 ${configFile} + +# transfer data from SD info file +echo "hostname=${hostname}" >> $configFile +echo "network=${network}" >> $configFile +echo "chain=${chain}" >> $configFile + +# let migration/init script do the rest +./_bootstrap.migration.sh + +# set the hostname inputed on initDialog +if [ ${#hostname} -gt 0 ]; then + echo "Setting new network hostname '$hostname'" + sudo raspi-config nonint do_hostname ${hostname} +else + echo "WARN: hostname not set" +fi + +# mark setup is done (100%) +sudo sed -i "s/^setupStep=.*/setupStep=100/g" /home/admin/raspiblitz.info + +clear +echo "Setup done. Rebooting now." +sudo shutdown -r now diff --git a/home.admin/_bootstrap.migration.sh b/home.admin/_bootstrap.migration.sh index d17282a..cfb4250 100644 --- a/home.admin/_bootstrap.migration.sh +++ b/home.admin/_bootstrap.migration.sh @@ -1,14 +1,26 @@ #!/bin/bash -# LOAD DATA & PRECHECK +# LOGFILE - store debug logs of bootstrap +logFile="/home/admin/raspiblitz.log" + +# INFOFILE - state data from bootstrap +infoFile="/home/admin/raspiblitz.info" -# path to old or init configuration of RaspiBlitz +# CONFIGFILE - configuration of RaspiBlitz configFile="/mnt/hdd/raspiblitz.conf" +# debug info +echo "STARTED Migration/Init --> see logs in ${logFile}" +echo "STARTED Migration/Init" >> ${logFile} + sudo sed -i "s/^message=.*/message='Running Data Migration'/g" ${infoFile} + +# LOAD DATA & PRECHECK + # check if there is a config file configExists=$(ls ${configFile} 2>/dev/null | grep -c '.conf') if [ ${configExists} -eq 0 ]; then - echo "FAIL: no config file (${configFile}) found to init or upgrade!" + echo "FAIL see ${logFile}" + echo "FAIL: no config file (${configFile}) found to init or upgrade!" >> ${logFile} exit 1 fi @@ -17,19 +29,22 @@ source ${configFile} # check if config files contains basic: network if [ ${#network} -eq 0 ]; then + echo "FAIL see ${logFile}" echo "FAIL: missing network in (${configFile})!" exit 1 fi # check if config files contains basic: chain if [ ${#chain} -eq 0 ]; then - echo "FAIL: missing chain in (${configFile})!" + echo "FAIL see ${logFile}" + echo "FAIL: missing chain in (${configFile})!" >> ${logFile} exit 1 fi # check if config files contains basic: hostname if [ ${#hostname} -eq 0 ]; then - echo "FAIL: missing hostname in (${configFile})!" + echo "FAIL see ${logFile}" + echo "FAIL: missing hostname in (${configFile})!" >> ${logFile} exit 1 fi @@ -38,16 +53,14 @@ source /home/admin/_version.info # check if code version was loaded if [ ${#codeVersion} -eq 0 ]; then - echo "FAIL: no code version (/home/admin/_version.info) found!" + echo "FAIL see ${logFile}" + echo "FAIL: no code version (/home/admin/_version.info) found!" >> ${logFile} exit 1 fi -# DEFAULT VALUES - MISSING data fields on init or upadte +echo "prechecks OK" >> ${logFile} -echo "" -echo "*****************************" -echo "Default Values" -echo "*****************************" +# DEFAULT VALUES - MISSING data fields on init or upadte # AUTOPILOT # autoPilot=off|on @@ -73,24 +86,23 @@ if [ ${#rtlWebinterface} -eq 0 ]; then echo "rtlWebinterface=off" >> $configFile fi +echo "default values OK" >> ${logFile} + # MIGRATION - DATA CONVERSION when updating config # this is the place if on a future version change # a conversion of config data or app data is needed -echo "" -echo "*****************************" -echo "Version Migration Steps" -echo "*****************************" -echo "Version Code: ${codeVersion}" -echo "Version Data: ${raspiBlitzVersion}" +echo "Version Code: ${codeVersion}" >> ${logFile} +echo "Version Data: ${raspiBlitzVersion}" >> ${logFile} if [ "${raspiBlitzVersion}" != "${codeVersion}" ]; then - echo "detected version change ... starting migration script" - echo "TODO: Update Migration check ... only needed after version 1.0" + echo "detected version change ... starting migration script" >> ${logFile} + echo "TODO: Update Migration check ... only needed after version 1.0" >> ${logFile} else - echo "OK - version of config data is up to date" + echo "OK - version of config data is up to date" >> ${logFile} fi -echo "" +echo "END Migration/Init" >> ${logFile} + exit 0 diff --git a/home.admin/_bootstrap.presync.sh b/home.admin/_bootstrap.presync.sh index 4fb32dc..fdba35d 100644 --- a/home.admin/_bootstrap.presync.sh +++ b/home.admin/_bootstrap.presync.sh @@ -1,10 +1,5 @@ #!/bin/bash -# This script runs on every start calles by boostrap.service -# It makes sure that the system is configured like the -# default values or as in the config. -# For more details see background_raspiblitzSettings.md - # LOGFILE - store debug logs of bootstrap # resets on every start logFile="/home/admin/raspiblitz.log" diff --git a/home.admin/_bootstrap.provision.sh b/home.admin/_bootstrap.provision.sh new file mode 100644 index 0000000..c170b2e --- /dev/null +++ b/home.admin/_bootstrap.provision.sh @@ -0,0 +1,135 @@ +#!/bin/bash + +# This script gets called from a fresh SD card +# starting up that has an config file on HDD +# from old RaspiBlitz or manufacturer to +# to install and config services + +# LOGFILE - store debug logs of bootstrap +logFile="/home/admin/raspiblitz.log" + +# INFOFILE - state data from bootstrap +infoFile="/home/admin/raspiblitz.info" + +# CONFIGFILE - configuration of RaspiBlitz +configFile="/mnt/hdd/raspiblitz.conf" + +# debug info +echo "STARTED Provisioning --> see logs in ${logFile}" +echo "STARTED Provisioning from preset config file" >> ${logFile} +sudo sed -i "s/^message=.*/message='Provisioning from Config'/g" ${infoFile} + +# check if there is a config file +configExists=$(ls ${configFile} 2>/dev/null | grep -c '.conf') +if [ ${configExists} -eq 0 ]; then + echo "FAIL: no config file (${configFile}) found to run provision!" >> ${logFile} + exit 1 +fi + +########################## +# BASIC SYSTEM SETTINGS +########################## + +echo "### BASIC SYSTEM SETTINGS ###" >> ${logFile} + +# set hostname data +echo "Setting lightning alias: ${hostname}" >> ${logFile} +sudo sed -i "s/^alias=.*/alias=${hostname}/g" /home/admin/assets/lnd.${network}.conf >> ${logFile} 2>&1 + +# auto-mount HDD +sudo umount -l /mnt/hdd >> ${logFile} 2>&1 +echo "Auto-Mounting HDD - calling script" >> ${logFile} +/home/admin/40addHDD.sh >> ${logFile} 2>&1 + +# link and copy HDD content into new OS +echo "Link HDD content for user bitcoin" >> ${logFile} +sudo chown -R bitcoin:bitcoin /mnt/hdd/lnd >> ${logFile} 2>&1 +sudo chown -R bitcoin:bitcoin /mnt/hdd/${network} >> ${logFile} 2>&1 +sudo ln -s /mnt/hdd/${network} /home/bitcoin/.${network} >> ${logFile} 2>&1 +sudo ln -s /mnt/hdd/lnd /home/bitcoin/.lnd >> ${logFile} 2>&1 +sudo chown -R bitcoin:bitcoin /home/bitcoin/.${network} >> ${logFile} 2>&1 +sudo chown -R bitcoin:bitcoin /home/bitcoin/.lnd >> ${logFile} 2>&1 +echo "Copy HDD content for user admin" >> ${logFile} +sudo mkdir /home/admin/.${network} >> ${logFile} 2>&1 +sudo cp /mnt/hdd/${network}/${network}.conf /home/admin/.${network}/${network}.conf >> ${logFile} 2>&1 +sudo mkdir /home/admin/.lnd >> ${logFile} 2>&1 +sudo cp /mnt/hdd/lnd/lnd.conf /home/admin/.lnd/lnd.conf >> ${logFile} 2>&1 +sudo cp /mnt/hdd/lnd/tls.cert /home/admin/.lnd/tls.cert >> ${logFile} 2>&1 +sudo mkdir /home/admin/.lnd/data >> ${logFile} 2>&1 +sudo cp -r /mnt/hdd/lnd/data/chain /home/admin/.lnd/data/chain >> ${logFile} 2>&1 +sudo chown -R admin:admin /home/admin/.${network} >> ${logFile} 2>&1 +sudo chown -R admin:admin /home/admin/.lnd >> ${logFile} 2>&1 +echo "Enabling Services" >> ${logFile} +sudo cp /home/admin/assets/${network}d.service /etc/systemd/system/${network}d.service >> ${logFile} 2>&1 +sudo chmod +x /etc/systemd/system/${network}d.service >> ${logFile} 2>&1 +sudo systemctl daemon-reload >> ${logFile} 2>&1 +sudo systemctl enable ${network}d.service >> ${logFile} 2>&1 +sed -i "5s/.*/Wants=${network}d.service/" ./assets/lnd.service >> ${logFile} 2>&1 +sed -i "6s/.*/After=${network}d.service/" ./assets/lnd.service >> ${logFile} 2>&1 +sudo cp /home/admin/assets/lnd.service /etc/systemd/system/lnd.service >> ${logFile} 2>&1 +sudo chmod +x /etc/systemd/system/lnd.service >> ${logFile} 2>&1 +sudo systemctl enable lnd >> ${logFile} 2>&1 + +# finish setup (SWAP, Benus, Firewall, Update, ..) +./90finishSetup.sh >> ${logFile} 2>&1 + +# set the local network hostname +if [ ${#hostname} -gt 0 ]; then + echo "Setting new network hostname '$hostname'" >> ${logFile} + sudo raspi-config nonint do_hostname ${hostname} >> ${logFile} 2>&1 +else + echo "No hostname set." >> ${logFile} +fi + +########################## +# PROVISIONING SERVICES +########################## + + echo "### RUNNING PROVISIONING SERVICES ###" >> ${logFile} + +# TESTNET +if [ "${chain}" = "test" ]; then + echo "Provisioning TESTNET - run config script" >> ${logFile} + sudo sed -i "s/^message=.*/message='Provisioning Testnet'/g" ${infoFile} + sudo /home/admin/config.scripts/network.chain.sh testnet >> ${logFile} 2>&1 +else + echo "Provisioning TESTNET - keep default" >> ${logFile} +fi + +# AUTO PILOT +if [ "${autoPilot}" = "on" ]; then + echo "Provisioning AUTO PILOT - run config script" >> ${logFile} + sudo sed -i "s/^message=.*/message='Provisioning AutoPilot'/g" ${infoFile} + sudo /home/admin/config.scripts/lnd.autopilot.sh on >> ${logFile} 2>&1 +else + echo "Provisioning AUTO PILOT - keep default" >> ${logFile} +fi + +# AUTO NAT DISCOVERY +if [ "${autoNatDiscovery}" = "on" ]; then + echo "Provisioning AUTO NAT DISCOVERY - run config script" >> ${logFile} + sudo sed -i "s/^message=.*/message='Provisioning AutoNAT'/g" ${infoFile} + sudo /home/admin/config.scripts/lnd.autonat.sh on >> ${logFile} 2>&1 +else + echo "Provisioning AUTO NAT DISCOVERY - keep default" >> ${logFile} +fi + +# RTL +if [ "${rtlWebinterface}" = "on" ]; then + echo "Provisioning RTL - run config script" >> ${logFile} + sudo sed -i "s/^message=.*/message='Provisioning RTL'/g" ${infoFile} + sudo /home/admin/config.scripts/bonus.rtl.sh on >> ${logFile} 2>&1 +else + echo "Provisioning RTL - keep default" >> ${logFile} +fi + +# TOR +if [ "${runBehindTor}" = "on" ]; then + echo "Provisioning TOR - run config script" >> ${logFile} + sudo sed -i "s/^message=.*/message='Provisioning TOR'/g" ${infoFile} + sudo /home/admin/config.scripts/internet.tor.sh on >> ${logFile} 2>&1 +else + echo "Provisioning TOR - keep default" >> ${logFile} +fi + +echo "END Provisioning" >> ${logFile} \ No newline at end of file diff --git a/home.admin/_bootstrap.sh b/home.admin/_bootstrap.sh index 7f3cfe0..a458445 100644 --- a/home.admin/_bootstrap.sh +++ b/home.admin/_bootstrap.sh @@ -138,16 +138,23 @@ if [ ${hddIsAutoMounted} -eq 0 ]; then echo "OK - HDD available under /mnt/hdd" >> $logFile fi + # UPDATE MIGRATION & CONFIG PROVISIONING # check if HDD contains already a configuration echo "Check if HDD contains already a configuration .." >> $logFile configExists=$(ls ${configFile} | grep -c '.conf') if [ ${configExists} -eq 1 ]; then - // TODO: Migration and Recover - echo "Found existing configuration - TODO migration and recover!" >> $logFile + echo "Found existing configuration" >> $logFile echo "state=recovering" > $infoFile - echo "message='TODO: migration and recover'" >> $infoFile - # unmountig the HDD at the end of the process - sudo umount -l /mnt/hdd + echo "message='Starting Recover'" > $infoFile + echo "Calling Data Migration .." >> $logFile + sudo /home/admin/_bootstrap.migration.sh + echo "Calling Provisioning .." >> $logFile + sudo /home/admin/_bootstrap.provision.sh + echo "state=recovered" > $infoFile + echo "rebooting" >> $logFile + # save log file for inspection before reboot + cp $logFile /home/admin/raspiblitz.recover + sudo shutdown -r now exit 1 else echo "OK - No config file found: ${configFile}" >> $logFile