mirror of
https://github.com/raspiblitz/raspiblitz.git
synced 2025-04-12 05:39:22 +02:00
moved setup step into info file
This commit is contained in:
parent
cefd382390
commit
e4d9d8de81
@ -78,7 +78,7 @@ while :
|
||||
fi
|
||||
|
||||
# get the actual step number of setup process
|
||||
setupStep=$(sudo -u admin cat /home/admin/.setup 2>/dev/null)
|
||||
source /home/admin/raspiblitz.info
|
||||
if [ ${#setupStep} -eq 0 ]; then
|
||||
setupStep=0
|
||||
fi
|
||||
|
@ -117,16 +117,16 @@ waitUntilChainNetworkIsReady()
|
||||
done
|
||||
}
|
||||
|
||||
## get actual setup state
|
||||
setupState=0;
|
||||
if [ -f "/home/admin/.setup" ]; then
|
||||
setupState=$( cat /home/admin/.setup )
|
||||
## get actual setup info
|
||||
source /home/admin/raspiblitz.info
|
||||
if [ ${#setupStep} -eq 0 ]; then
|
||||
echo "WARN: no setup step found in raspiblitz.info"
|
||||
setupStep=0
|
||||
fi
|
||||
if [ ${setupState} -eq 0 ]; then
|
||||
if [ ${setupStep} -eq 0 ]; then
|
||||
|
||||
# check data from boostrap
|
||||
# TODO: when olddata --> CLEAN OR MANUAL-UPDATE-INFO
|
||||
source /home/admin/raspiblitz.info
|
||||
if [ "${state}" = "olddata" ]; then
|
||||
# old data setup
|
||||
BACKTITLE="RaspiBlitz - Manual Update"
|
||||
@ -147,10 +147,10 @@ if [ ${setupState} -eq 0 ]; then
|
||||
|
||||
|
||||
|
||||
elif [ ${setupState} -lt 100 ]; then
|
||||
elif [ ${setupStep} -lt 100 ]; then
|
||||
|
||||
# see function above
|
||||
if [ ${setupState} -gt 59 ]; then
|
||||
if [ ${setupStep} -gt 59 ]; then
|
||||
waitUntilChainNetworkIsReady
|
||||
fi
|
||||
|
||||
@ -365,7 +365,6 @@ case $CHOICE in
|
||||
;;
|
||||
DELETE)
|
||||
sudo ./XXcleanHDD.sh
|
||||
sudo rm -f .setup
|
||||
sudo shutdown -r now
|
||||
exit 0
|
||||
;;
|
||||
|
@ -1,19 +1,29 @@
|
||||
#!/bin/bash
|
||||
echo ""
|
||||
|
||||
# load network
|
||||
network=`cat .network`
|
||||
# CHECK WHAT IS ALREADY WORKING
|
||||
# check list from top down - so ./10setupBlitz.sh
|
||||
# and re-enters the setup process at the correct spot
|
||||
# in case it got interrupted
|
||||
echo "checking setup script"
|
||||
|
||||
# check chain
|
||||
chain="test"
|
||||
isMainChain=$(sudo cat /mnt/hdd/${network}/${network}.conf 2>/dev/null | grep "#testnet=1" -c)
|
||||
if [ ${isMainChain} -gt 0 ];then
|
||||
chain="main"
|
||||
# CONFIGFILE on HDD - configuration of RaspiBlitz
|
||||
configFile="/mnt/hdd/raspiblitz.conf"
|
||||
|
||||
# INFOFILE on SD - state data from bootstrap & setup
|
||||
infoFile="/home/admin/raspiblitz.info"
|
||||
|
||||
# try to load raspi config from HDD and
|
||||
# if not available yet (because HDD not mounted yet)
|
||||
# then try load info file from sd card
|
||||
source ${configFile} 2>/dev/null
|
||||
if [ ${#network} -eq 0 ]; then
|
||||
echo "HDD config not found - try SD info file"
|
||||
source ${infoFile} 2>/dev/null
|
||||
fi
|
||||
|
||||
# get setup progress
|
||||
setupStep=$(sudo -u admin cat /home/admin/.setup)
|
||||
# if no setup step in info file init with 0
|
||||
if [ ${#setupStep} -eq 0 ];then
|
||||
echo "setupStep=0" >> ${infoFile}
|
||||
setupStep=0
|
||||
fi
|
||||
|
||||
@ -25,11 +35,6 @@ if [ ${setupStep} -gt 89 ];then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# CHECK WHAT IS ALREADY WORKING
|
||||
# check list from top down - so ./10setupBlitz.sh
|
||||
# and re-enters the setup process at the correct spot
|
||||
# in case it got interrupted
|
||||
|
||||
# check if lightning is running
|
||||
lndRunning=$(systemctl status lnd.service 2>/dev/null | grep -c running)
|
||||
if [ ${lndRunning} -eq 1 ]; then
|
||||
@ -37,7 +42,7 @@ if [ ${lndRunning} -eq 1 ]; then
|
||||
echo "LND is running ..."
|
||||
sleep 1
|
||||
|
||||
# check if LND is locked
|
||||
# check if LND wallet exists and if locked
|
||||
walletExists=$(sudo ls /mnt/hdd/lnd/data/chain/${network}/${chain}net/wallet.db 2>/dev/null | grep wallet.db -c)
|
||||
locked=0
|
||||
# only when a wallet exists - it can be locked
|
||||
@ -85,7 +90,7 @@ if [ ${lndRunning} -eq 1 ]; then
|
||||
./90finishSetup.sh
|
||||
exit 0
|
||||
|
||||
fi
|
||||
fi #end - when lighting is running
|
||||
|
||||
# check if bitcoin is running
|
||||
bitcoinRunning=$(systemctl status ${network}d.service 2>/dev/null | grep -c running)
|
||||
@ -98,10 +103,10 @@ if [ ${bitcoinRunning} -eq 1 ]; then
|
||||
echo "Next step run Lightning"
|
||||
./70initLND.sh
|
||||
exit 1
|
||||
fi
|
||||
fi #end - when bitcoin is running
|
||||
|
||||
# check if HDD is mounted
|
||||
mountOK=$( df | grep -c /mnt/hdd )
|
||||
# check if HDD is auto-mounted
|
||||
mountOK=$( sudo cat /etc/fstab | grep -c '/mnt/hdd' )
|
||||
if [ ${mountOK} -eq 1 ]; then
|
||||
|
||||
# are there any signs of blockchain data
|
||||
@ -156,7 +161,7 @@ if [ ${mountOK} -eq 1 ]; then
|
||||
fi
|
||||
|
||||
# set SetupState
|
||||
echo "50" > /home/admin/.setup
|
||||
sudo sed -i "s/^setupStep=.*/setupStep=50/g" ${infoFile}
|
||||
|
||||
clear
|
||||
case $menuitem in
|
||||
@ -175,19 +180,19 @@ if [ ${mountOK} -eq 1 ]; then
|
||||
esac
|
||||
exit 1
|
||||
|
||||
fi
|
||||
fi # end HDD is already auto-mountes
|
||||
|
||||
|
||||
# the HDD is not mounted --> very early stage of setup
|
||||
# the HDD is not auto-mounted --> very early stage of setup
|
||||
|
||||
# if the script is called for the first time
|
||||
if [ ! -f "home/admin/.setup" ]; then
|
||||
if [ ${setupStep} -eq 0 ]; then
|
||||
|
||||
# run initial user dialog
|
||||
./20initDialog.sh
|
||||
|
||||
# set SetupState to 10
|
||||
echo "20" > /home/admin/.setup
|
||||
# set SetupState
|
||||
sudo sed -i "s/^setupStep=.*/setupStep=20/g" ${infoFile}
|
||||
|
||||
# update system
|
||||
echo ""
|
||||
|
@ -48,6 +48,7 @@ if [ ${existsHDD} -eq 1 ]; then
|
||||
|
||||
# set SetupState
|
||||
echo "30" > /home/admin/.setup
|
||||
sudo sed -i "s/^setupStep=.*/setupStep=30/g" ${infoFile}
|
||||
|
||||
# automatically now add the HDD to the system
|
||||
./40addHDD.sh
|
||||
|
@ -45,7 +45,7 @@ if [ ${existsHDD} -gt 0 ]; then
|
||||
echo ""
|
||||
|
||||
# set SetupState
|
||||
echo "40" > /home/admin/.setup
|
||||
sudo sed -i "s/^setupStep=.*/setupStep=40/g" /home/admin/raspiblitz.info
|
||||
|
||||
echo "*** Analysing HDD Content ***"
|
||||
if [ -d "/mnt/hdd/${network}" ]; then
|
||||
|
@ -94,7 +94,7 @@ echo ""
|
||||
echo "---> You can now disconnect the 2nd HDD"
|
||||
|
||||
# set SetupState
|
||||
echo "50" > /home/admin/.setup
|
||||
sudo sed -i "s/^setupStep=.*/setupStep=50/g" /home/admin/raspiblitz.info
|
||||
|
||||
sleep 5
|
||||
./60finishHDD.sh
|
||||
|
@ -29,7 +29,7 @@ sudo mkdir /mnt/hdd/${network}
|
||||
echo "OK - sync is activated"
|
||||
|
||||
# set SetupState
|
||||
echo "50" > /home/admin/.setup
|
||||
sudo sed -i "s/^setupStep=.*/setupStep=50/g" /home/admin/raspiblitz.info
|
||||
|
||||
# continue setup
|
||||
./60finishHDD.sh
|
||||
|
@ -50,7 +50,7 @@ if [ ${mountOK} -eq 1 ]; then
|
||||
sleep 2
|
||||
|
||||
# set SetupState
|
||||
echo "60" > /home/admin/.setup
|
||||
sudo sed -i "s/^setupStep=.*/setupStep=60/g" /home/admin/raspiblitz.info
|
||||
|
||||
./10setupBlitz.sh
|
||||
|
||||
|
@ -154,7 +154,7 @@ Press OK and follow the 'Helping Instructions'.
|
||||
echo "If you are ready. Press ENTER."
|
||||
read key
|
||||
|
||||
echo "65" > /home/admin/.setup
|
||||
sudo sed -i "s/^setupStep=.*/setupStep=65/g" /home/admin/raspiblitz.info
|
||||
fi
|
||||
|
||||
echo "--> lets wait 60 seconds for LND to get ready"
|
||||
@ -241,7 +241,7 @@ else
|
||||
fi
|
||||
|
||||
# set SetupState (scan is done - so its 80%)
|
||||
echo "80" > /home/admin/.setup
|
||||
sudo sed -i "s/^setupStep=.*/setupStep=80/g" /home/admin/raspiblitz.info
|
||||
|
||||
###### finishSetup
|
||||
./90finishSetup.sh
|
||||
|
@ -73,7 +73,7 @@ sudo ufw --force enable
|
||||
echo ""
|
||||
|
||||
# mark setup is done
|
||||
echo "90" > /home/admin/.setup
|
||||
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 "
|
||||
@ -89,7 +89,7 @@ echo "Setting new network hostname '$hostname'"
|
||||
sudo raspi-config nonint do_hostname ${hostname}
|
||||
|
||||
# mark setup is done (100%)
|
||||
echo "100" > /home/admin/.setup
|
||||
sudo sed -i "s/^setupStep=.*/setupStep=100/g" /home/admin/raspiblitz.info
|
||||
|
||||
clear
|
||||
echo "Setup done. Rebooting now."
|
||||
|
@ -115,7 +115,7 @@ if [ ${networkInstalled} -gt 0 ]; then
|
||||
sleep 120
|
||||
|
||||
# set setup info again
|
||||
echo "60" > /home/admin/.setup
|
||||
sudo sed -i "s/^setupStep=.*/setupStep=60/g" /home/admin/raspiblitz.info
|
||||
|
||||
# run again the complete LND init procedure
|
||||
./70initLND.sh
|
||||
|
@ -26,5 +26,5 @@ sudo rm -f -r /mnt/hdd/download
|
||||
sudo rm -f -r /mnt/hdd/tor
|
||||
sudo rm -f /mnt/hdd/raspiblitz.conf
|
||||
sudo chown admin:admin -R /mnt/hdd/${network}
|
||||
echo "1" > /home/admin/.setup
|
||||
sudo rm -f /home/admin/raspiblitz.info
|
||||
echo "OK - the HDD is now clean"
|
||||
|
@ -294,18 +294,9 @@ if [ ${#hostname} -eq 0 ]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
# SETUP STEP
|
||||
# SETUP STEP (ONLY DO ON SD CARD infofile - not configfile)
|
||||
# setupStep=0-100
|
||||
if [ ${#setupStep} -eq 0 ]; then
|
||||
oldValueExists=$(sudo ls /home/admin/.setup | grep -c '.setup')
|
||||
if [ ${oldValueExists} -eq 1 ]; then
|
||||
oldValue=`sudo cat /home/admin/.setup`
|
||||
echo "importing old setup value: ${oldValue}" >> $logFile
|
||||
echo "setupStep=${oldValue}" >> $configFile
|
||||
else
|
||||
echo "setupStep=0" >> $configFile
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# AUTOPILOT
|
||||
# autoPilot=off|on
|
||||
|
Loading…
x
Reference in New Issue
Block a user