Fix manual provisioning with stop file flag (#4485)

This commit is contained in:
/rootzoll 2024-03-18 15:59:02 +01:00 committed by GitHub
parent 588820ff13
commit f1342ebcfd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 45 additions and 19 deletions

View file

@ -218,6 +218,10 @@ Now to sync your branch namend BRANCH on your forked repo with your RaspiBlitz,
So your workflow can go like this: You write code on your local computer. Commit to your local repo, push it to your forked repo and use the sync-script above to get the code to your RaspiBlitz.
### How can I manual provision an image with updated code?
To boot an already build sd card image with your updated raspiblitz code base you can use the `stop` file flag. This will make the `_bootstrap.sh` script stop basically before making any setup or recovery changes to the system. You can SSH in an use the `github` command to update the raspiblitz code and then use `release` command. To set the `stop` file flag. Insert a fresh written sd card into your PC and on the root of `bootfs` drive with a file manager place a empty file simply called `stop` (with no file extension).
### How to add an app to the RaspiBlitz?
To add your app you can fork the raspiblitz repo, follow the `/home.admin/config.scripts/bonus.template.sh` script [see code](https://github.com/raspiblitz/raspiblitz/blob/dev/home.admin/config.scripts/bonus.template.sh), copy/adapt it, test it on your RaspiBlitz and make a PR back to the main repo.

View file

@ -86,7 +86,6 @@ while :
# get config info if already available (with state value)
source ${infoFile}
source <(/home/admin/_cache.sh get state message)
configExists=$(ls "${configFile}" 2>/dev/null | grep -c '.conf')
if [ ${configExists} -eq 1 ]; then

View file

@ -13,7 +13,6 @@ source /mnt/hdd/raspiblitz.conf 2>/dev/null
# INFOFILE - state data from bootstrap
infoFile="/home/admin/raspiblitz.info"
source ${infoFile}
source <(/home/admin/_cache.sh get state message)
# check that basic system phase/state information is available
if [ "${setupPhase}" == "" ] || [ "${state}" == "" ]; then

View file

@ -43,7 +43,6 @@ do
# source info & config file fresh on every loop
source ${infoFile} 2>/dev/null
source ${configFile} 2>/dev/null
source <(/home/admin/_cache.sh get state setupPhase)
####################################################
# SKIP BACKGROUND TASK LOOP ON CERTAIN SYSTEM STATES

View file

@ -90,15 +90,16 @@ ln_cl_signet_sync_initial_done=0
source ${infoFile} 2>/dev/null
# write fresh raspiblitz.info file
echo "baseimage=${baseimage}" > $infoFile
echo "state=starting" > $infoFile
echo "message=starting" >> $infoFile
echo "setupPhase=${setupPhase}" >> $infoFile
echo "setupStep=${setupStep}" >> $infoFile
echo "baseimage=${baseimage}" >> $infoFile
echo "cpu=${cpu}" >> $infoFile
echo "blitzapi=${blitzapi}" >> $infoFile
echo "displayClass=${displayClass}" >> $infoFile
echo "displayType=${displayType}" >> $infoFile
echo "setupPhase=${setupPhase}" >> $infoFile
echo "setupStep=${setupStep}" >> $infoFile
echo "fsexpanded=${fsexpanded}" >> $infoFile
echo "state=starting" >> $infoFile
echo "btc_mainnet_sync_initial_done=${btc_mainnet_sync_initial_done}" >> $infoFile
echo "btc_testnet_sync_initial_done=${btc_testnet_sync_initial_done}" >> $infoFile
echo "btc_signet_sync_initial_done=${btc_signet_sync_initial_done}" >> $infoFile
@ -114,6 +115,22 @@ chmod 664 ${infoFile}
# write content of raspiblitz.info to logs
cat $infoFile >> $logFile
######################################
# STOP file flag - for manual provision
# when a file 'stop' is on the sd card bootfs partition root - stop for manual provision
flagExists=$(ls /boot/firmware/stop | grep -c 'stop')
if [ "${flagExists}" == "1" ]; then
# remove flag
rm /boot/firmware/stop
# set state info
/home/admin/_cache.sh set state "stop"
/home/admin/_cache.sh set message "stopped for manual provision"
# log info
echo "INFO: 'bootstrap stopped - run release after manual provison'" >> ${logFile}
exit 0
fi
#########################
# INIT RaspiBlitz Cache
#########################
@ -155,16 +172,6 @@ source ${configFile} 2>/dev/null
######################################
# CHECK SD CARD STATE
# when a file 'stop' is on the sd card bootfs partition root - stop for manual provision
flagExists=$(ls /boot/firmware/stop | grep -c 'stop')
if [ "${flagExists}" == "1" ]; then
# remove flag
rm /boot/firmware/stop
# log info
echo "INFO: 'bootstrap stopped - run release after manual provison'" >> ${logFile}
exit 0
fi
# wifi config by file on sd card
wifiFileExists=$(ls /boot/firmware/wifi | grep -c 'wifi')
wpaFileExists=$(ls /boot/firmware/wpa_supplicant.conf | grep -c 'wpa_supplicant.conf')

View file

@ -148,6 +148,23 @@ elif [ "$1" = "set" ] || [ "$1" = "init" ]; then
exit 1
fi
# update certain values also in raspiblitz.info
if [ "${keystr}" = "state" ]; then
# change value in raspiblitz.info
sudo sed -i "s/^state=.*/state='${valuestr}'/g" ${infoFile}
fi
if [ "${keystr}" = "message" ]; then
# change value in raspiblitz.info
sudo sed -i "s/^message=.*/message='${valuestr}'/g" ${infoFile}
fi
if [ "${keystr}" = "setupPhase" ]; then
# change value in raspiblitz.info
sudo sed -i "s/^setupPhase=.*/setupPhase='${valuestr}'/g" ${infoFile}
fi
if [ "${keystr}" = "setupStep" ]; then
# change value in raspiblitz.info
sudo sed -i "s/^setupStep=.*/setupStep='${valuestr}'/g" ${infoFile}
fi
NX=""
if [ "$1" = "init" ]; then

View file

@ -17,7 +17,7 @@ echo "# RASPIBLITZ SETUP STATE" > $SETUPFILE
sudo chown admin:admin $SETUPFILE
sudo chmod 777 $SETUPFILE
source <(/home/admin/_cache.sh get setupPhase dnsworking)
source <(/home/admin/_cache.sh get dnsworking)
# remember original setupphase
orgSetupPhase="${setupPhase}"
@ -90,7 +90,8 @@ if [ "${setupPhase}" == "migration" ]; then
fi
source <(/home/admin/_cache.sh get setupPhase)
# fresh import setup values
source /home/admin/raspiblitz.info
############################################
# DEFAULT: Basic Setup menu