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