run background task from the begenning

This commit is contained in:
rootzoll
2021-05-26 09:21:42 -05:00
parent 2f71aaa244
commit f77f9bf2c4
2 changed files with 55 additions and 22 deletions

View File

@@ -39,15 +39,47 @@ do
# count up
counter=$(($counter+1))
# limit counter to max seconds per week:
# 604800 = 60sec * 60min * 24hours * 7days
if [ ${counter} -gt 604800 ]; then
counter=0
echo "counter zero reset"
fi
# gather the uptime seconds
upSeconds=$(cat /proc/uptime | grep -o '^[0-9]\+')
# prevent restart if COPY OVER LAN is running
# see: https://github.com/rootzoll/raspiblitz/issues/1179#issuecomment-646079467
source ${infoFile}
if [ "${state}" == "copysource" ]; then
echo "copysource mode: skipping background loop"
sleep 10
# source info file fresh on every loop
source ${infoFile} 2>/dev/null
####################################################
# SKIP BACKGROUND TASK LOOP ON CERTAIN SYSTEM STATES
# https://github.com/rootzoll/raspiblitz/issues/160
####################################################
if [ "${state}" == "" ] || [ "${state}" == "copysource" ]; then
echo "skipping background loop (${counter}) - state(${state})"
sleep 1
continue
fi
####################################################
# CHECK IF LOCAL IP CHANGED
####################################################
oldLocalIP="${localip}";
source <(/home/admin/config.scripts/internet.sh status)
if [ "${oldLocalIP}" != "${localip}" ]; then
echo "local IP changed old(${oldLocalIP}) new(${localip}) - updating in raspiblitz.info"
sed -i "s/^localip=.*/localip='${localip}'/g" ${infoFile}
fi
####################################################
# SKIP REST OF THE TASKS IF STILL IN SETUP PHASE
####################################################
if [ "${setupPhase}" != "done" ]; then
echo "skipping rest of tasks because still in setupPhase(${setupPhase})"
sleep 1
continue
fi
@@ -356,7 +388,6 @@ do
fi
###############################
# LND AUTO-UNLOCK
###############################
@@ -465,12 +496,5 @@ do
# sleep 1 sec
sleep 1
# limit counter to max seconds per week:
# 604800 = 60sec * 60min * 24hours * 7days
if [ ${counter} -gt 604800 ]; then
counter=0
echo "counter zero reset"
fi
done

View File

@@ -143,6 +143,23 @@ else
echo "No SSHRESET switch found. " >> $logFile
fi
################################
# BACKGROUND TASK RUN FROM BEGINNING
# on 1.7 sd card build background task runs after boostrap
# but bootstrap already needs background task running now
# REMOVE ON v1.8 release #2328
################################
backgroundNeedsEdit=$(sudo cat /etc/systemd/system/background.service 2>/dev/null | grep -c 'Wants=bootstrap.service')
if [ ${backgroundNeedsEdit} -eq 1 ]; then
echo "BACKGROUND EDIT needed ..." >> $logFile
sudo sed -i "s/^Wants=.*/Wants=network.target/g" /etc/systemd/system/background.service
sudo sed -i "s/^After=.*/After=network.target/g" /etc/systemd/system/background.service
systemInitReboot=1
else
echo "BACKGROUND EDIT already done. " >> $logFile
fi
################################
# FS EXPAND
# if a file called 'ssh.reset' gets
@@ -281,10 +298,6 @@ do
sed -i "s/^message=.*/message='>=1TB'/g" ${infoFile}
fi
# get latest network info & update raspiblitz.info (in case network changes)
source <(/home/admin/config.scripts/internet.sh status)
sed -i "s/^localip=.*/localip='${localip}'/g" ${infoFile}
# wait for next check
sleep 2
@@ -417,10 +430,6 @@ if [ ${isMounted} -eq 0 ]; then
until [ "${state}" == "waitprovision" ]
do
# get latest network info & update raspiblitz.info (in case network changes)
source <(/home/admin/config.scripts/internet.sh status)
sed -i "s/^localip=.*/localip='${localip}'/g" ${infoFile}
# get fresh info about data drive (in case the hdd gets disconnected)
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh status)
if [ "${hddCandidate}" == "" ]; then