Browse Source

Update & Provisioning

#146
rootzoll 6 years ago
parent
commit
1768323e0d
  1. 2
      README.md
  2. 3
      home.admin/00infoLCD.sh
  3. 9
      home.admin/00mainMenu.sh
  4. 4
      home.admin/10setupBlitz.sh
  5. 84
      home.admin/20recoverDialog.sh
  6. 0
      home.admin/20setupDialog.sh
  7. 63
      home.admin/40addHDD.sh
  8. 1
      home.admin/70initLND.sh
  9. 45
      home.admin/90finishSetup.sh
  10. 45
      home.admin/95finalSetup.sh
  11. 54
      home.admin/_bootstrap.migration.sh
  12. 5
      home.admin/_bootstrap.presync.sh
  13. 135
      home.admin/_bootstrap.provision.sh
  14. 17
      home.admin/_bootstrap.sh

2
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. 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: Then the user gets requested to write down 4 passwords:

3
home.admin/00infoLCD.sh

@ -21,7 +21,6 @@ while :
# get the local network IP to be displayed on the lCD # 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'/') localip=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
dhcpMissing=
if [ ${#localip} -eq 0 ]; then if [ ${#localip} -eq 0 ]; then
@ -34,7 +33,7 @@ while :
elif [ "${localip:0:4}" = "169." ]; then elif [ "${localip:0:4}" = "169." ]; then
# waiting for IP in general # waiting for DHCP in general
l1="Waiting for DHCP ...\n" l1="Waiting for DHCP ...\n"
l2="Not able to get local IP.\n" l2="Not able to get local IP.\n"
l3="Is Router working?\n" l3="Is Router working?\n"

9
home.admin/00mainMenu.sh

@ -32,12 +32,19 @@ if [ ${bootstrapInfoExists} -eq 1 ]; then
echo "device=${device}" >> $infoFile echo "device=${device}" >> $infoFile
fi fi
# signal if bootstrap is not ready yet # signal if bootstrap recover is not ready yet
if [ "${state}" = "recovering" ]; then if [ "${state}" = "recovering" ]; then
echo "WARNING: bootstrap is still updating - please close SSH and login later again" echo "WARNING: bootstrap is still updating - please close SSH and login later again"
exit 1 exit 1
fi 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 fi
## default menu settings ## default menu settings

4
home.admin/10setupBlitz.sh

@ -21,6 +21,7 @@ if [ ${setupStep} -gt 89 ];then
echo "FINISH by setupstep(${setupStep})" echo "FINISH by setupstep(${setupStep})"
sleep 3 sleep 3
./90finishSetup.sh ./90finishSetup.sh
./95finalSetup.sh
exit 0 exit 0
fi fi
@ -77,6 +78,7 @@ if [ ${lndRunning} -eq 1 ]; then
echo "FINSIH ... " echo "FINSIH ... "
sleep 3 sleep 3
./90finishSetup.sh ./90finishSetup.sh
./95finalSetup.sh
exit 0 exit 0
fi #end - when lighting is running fi #end - when lighting is running
@ -178,7 +180,7 @@ fi # end HDD is already auto-mountes
if [ ${setupStep} -eq 0 ]; then if [ ${setupStep} -eq 0 ]; then
# run initial user dialog # run initial user dialog
./20initDialog.sh ./20setupDialog.sh
# set SetupState # set SetupState
sudo sed -i "s/^setupStep=.*/setupStep=20/g" ${infoFile} sudo sed -i "s/^setupStep=.*/setupStep=20/g" ${infoFile}

84
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

0
home.admin/20initDialog.sh → home.admin/20setupDialog.sh

63
home.admin/40addHDD.sh

@ -5,6 +5,7 @@ echo ""
source /home/admin/raspiblitz.info 2>/dev/null source /home/admin/raspiblitz.info 2>/dev/null
echo "*** Adding HDD to the System ***" echo "*** Adding HDD to the System ***"
echo "started from state(${state})"
sleep 5 sleep 5
existsHDD=$(lsblk | grep -c sda) existsHDD=$(lsblk | grep -c sda)
if [ ${existsHDD} -gt 0 ]; then if [ ${existsHDD} -gt 0 ]; then
@ -34,39 +35,53 @@ if [ ${existsHDD} -gt 0 ]; then
fi fi
fstabOK=$(cat /etc/fstab | grep -c ${uuid}) fstabOK=$(cat /etc/fstab | grep -c ${uuid})
if [ ${fstabOK} -eq 1 ]; then if [ ${fstabOK} -eq 1 ]; then
echo "OK - HDD is listed in /etc/fstab" echo "OK - HDD is listed in /etc/fstab"
echo "" echo ""
echo "*** Mount HDD ***" echo "*** Mount HDD ***"
sudo mkdir /mnt/hdd sudo mkdir /mnt/hdd
sudo mount -a sudo mount -a
mountOK=$(df | grep -c /mnt/hdd) mountOK=$(df | grep -c /mnt/hdd)
if [ ${mountOK} -eq 1 ]; then if [ ${mountOK} -eq 1 ]; then
echo "OK - HDD is mounted" echo "OK - HDD is mounted"
echo "" echo ""
# set SetupState # set SetupState
sudo sed -i "s/^setupStep=.*/setupStep=40/g" /home/admin/raspiblitz.info sudo sed -i "s/^setupStep=.*/setupStep=40/g" /home/admin/raspiblitz.info
echo "*** Analysing HDD Content ***" echo "*** Analysing HDD Content ***"
if [ -d "/mnt/hdd/${network}" ]; then if [ -d "/mnt/hdd/${network}" ]; then
sudo chown -R bitcoin:bitcoin /mnt/hdd/bitcoin 2>/dev/null sudo chown -R bitcoin:bitcoin /mnt/hdd/bitcoin 2>/dev/null
sudo chown -R bitcoin:bitcoin /mnt/hdd/litecoin 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 "Looks like the HDD is prepared with the Blockchain."
echo "Continuing with finishing the system setup ..."
./60finishHDD.sh if [ "${state}" = "recovering" ]; then
else # when HDD got added on update/provisioning
# HDD is empty - let setupBlitz - display next options echo "OK HDD got added ... returning to provisioning"
./10setupBlitz.sh exit 1
fi else
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" echo "FAIL - was not able to mount"
fi fi # END Mount check
else else
echo "FAIL - was not able to edit /etc/fstab" echo "FAIL - was not able to edit /etc/fstab"
fi fi
else else
echo "FAIL - the HDD is not in ext4 format AND named 'BLOCKCHAIN'" echo "FAIL - the HDD is not in ext4 format AND named 'BLOCKCHAIN'"
fi fi
fi fi
else else
echo "FAIL - no HDD as device sda found" echo "FAIL - no HDD as device sda found"

1
home.admin/70initLND.sh

@ -238,3 +238,4 @@ sudo sed -i "s/^setupStep=.*/setupStep=80/g" /home/admin/raspiblitz.info
###### finishSetup ###### finishSetup
./90finishSetup.sh ./90finishSetup.sh
./95finalSetup.sh

45
home.admin/90finishSetup.sh

@ -4,12 +4,6 @@ echo ""
# add bonus scripts # add bonus scripts
./91addBonus.sh ./91addBonus.sh
# load setup config
source /home/admin/raspiblitz.info
# load version
source /home/admin/_version.info
###### SWAP & FS ###### SWAP & FS
echo "*** SWAP file ***" echo "*** SWAP file ***"
swapExists=$(swapon -s | grep -c /mnt/hdd/swapfile) 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" echo "OK - System is now up to date"
# mark setup is done # mark setup is done
sudo sed -i "s/^setupStep=.*/setupStep=90/g" /home/admin/raspiblitz.info 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

45
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

54
home.admin/_bootstrap.migration.sh

@ -1,14 +1,26 @@
#!/bin/bash #!/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" 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 # check if there is a config file
configExists=$(ls ${configFile} 2>/dev/null | grep -c '.conf') configExists=$(ls ${configFile} 2>/dev/null | grep -c '.conf')
if [ ${configExists} -eq 0 ]; then 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 exit 1
fi fi
@ -17,19 +29,22 @@ source ${configFile}
# check if config files contains basic: network # check if config files contains basic: network
if [ ${#network} -eq 0 ]; then if [ ${#network} -eq 0 ]; then
echo "FAIL see ${logFile}"
echo "FAIL: missing network in (${configFile})!" echo "FAIL: missing network in (${configFile})!"
exit 1 exit 1
fi fi
# check if config files contains basic: chain # check if config files contains basic: chain
if [ ${#chain} -eq 0 ]; then if [ ${#chain} -eq 0 ]; then
echo "FAIL: missing chain in (${configFile})!" echo "FAIL see ${logFile}"
echo "FAIL: missing chain in (${configFile})!" >> ${logFile}
exit 1 exit 1
fi fi
# check if config files contains basic: hostname # check if config files contains basic: hostname
if [ ${#hostname} -eq 0 ]; then if [ ${#hostname} -eq 0 ]; then
echo "FAIL: missing hostname in (${configFile})!" echo "FAIL see ${logFile}"
echo "FAIL: missing hostname in (${configFile})!" >> ${logFile}
exit 1 exit 1
fi fi
@ -38,16 +53,14 @@ source /home/admin/_version.info
# check if code version was loaded # check if code version was loaded
if [ ${#codeVersion} -eq 0 ]; then 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 exit 1
fi fi
# DEFAULT VALUES - MISSING data fields on init or upadte echo "prechecks OK" >> ${logFile}
echo "" # DEFAULT VALUES - MISSING data fields on init or upadte
echo "*****************************"
echo "Default Values"
echo "*****************************"
# AUTOPILOT # AUTOPILOT
# autoPilot=off|on # autoPilot=off|on
@ -73,24 +86,23 @@ if [ ${#rtlWebinterface} -eq 0 ]; then
echo "rtlWebinterface=off" >> $configFile echo "rtlWebinterface=off" >> $configFile
fi fi
echo "default values OK" >> ${logFile}
# MIGRATION - DATA CONVERSION when updating config # MIGRATION - DATA CONVERSION when updating config
# this is the place if on a future version change # this is the place if on a future version change
# a conversion of config data or app data is needed # a conversion of config data or app data is needed
echo "" echo "Version Code: ${codeVersion}" >> ${logFile}
echo "*****************************" echo "Version Data: ${raspiBlitzVersion}" >> ${logFile}
echo "Version Migration Steps"
echo "*****************************"
echo "Version Code: ${codeVersion}"
echo "Version Data: ${raspiBlitzVersion}"
if [ "${raspiBlitzVersion}" != "${codeVersion}" ]; then if [ "${raspiBlitzVersion}" != "${codeVersion}" ]; then
echo "detected version change ... starting migration script" echo "detected version change ... starting migration script" >> ${logFile}
echo "TODO: Update Migration check ... only needed after version 1.0" echo "TODO: Update Migration check ... only needed after version 1.0" >> ${logFile}
else else
echo "OK - version of config data is up to date" echo "OK - version of config data is up to date" >> ${logFile}
fi fi
echo "" echo "END Migration/Init" >> ${logFile}
exit 0 exit 0

5
home.admin/_bootstrap.presync.sh

@ -1,10 +1,5 @@
#!/bin/bash #!/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 # LOGFILE - store debug logs of bootstrap
# resets on every start # resets on every start
logFile="/home/admin/raspiblitz.log" logFile="/home/admin/raspiblitz.log"

135
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}

17
home.admin/_bootstrap.sh

@ -138,16 +138,23 @@ if [ ${hddIsAutoMounted} -eq 0 ]; then
echo "OK - HDD available under /mnt/hdd" >> $logFile echo "OK - HDD available under /mnt/hdd" >> $logFile
fi fi
# UPDATE MIGRATION & CONFIG PROVISIONING
# check if HDD contains already a configuration # check if HDD contains already a configuration
echo "Check if HDD contains already a configuration .." >> $logFile echo "Check if HDD contains already a configuration .." >> $logFile
configExists=$(ls ${configFile} | grep -c '.conf') configExists=$(ls ${configFile} | grep -c '.conf')
if [ ${configExists} -eq 1 ]; then if [ ${configExists} -eq 1 ]; then
// TODO: Migration and Recover echo "Found existing configuration" >> $logFile
echo "Found existing configuration - TODO migration and recover!" >> $logFile
echo "state=recovering" > $infoFile echo "state=recovering" > $infoFile
echo "message='TODO: migration and recover'" >> $infoFile echo "message='Starting Recover'" > $infoFile
# unmountig the HDD at the end of the process echo "Calling Data Migration .." >> $logFile
sudo umount -l /mnt/hdd 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 exit 1
else else
echo "OK - No config file found: ${configFile}" >> $logFile echo "OK - No config file found: ${configFile}" >> $logFile

Loading…
Cancel
Save