Skip to content

Commit

Permalink
Update late.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
flatsiedatsie authored Aug 24, 2022
1 parent d9e04db commit c4479e8
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions home/pi/candle/late.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ then
#echo "current hostname: $(hostname -I)"
if [ "$(hostname -I)" = "" ]
then
echo "Candle: rc.local doing post_bootup_actions: no network yet $i" >> /dev/kmsg
echo "Candle: late.sh doing post_bootup_actions: no network yet $i" >> /dev/kmsg
echo "no network yet $i"
sleep 1
else
echo "Candle: rc.local doing post_bootup_actions: IP address detected: $(hostname -I)" >> /dev/kmsg
echo "Candle: late.sh doing post_bootup_actions: IP address detected: $(hostname -I)" >> /dev/kmsg
break
fi
done
Expand All @@ -53,7 +53,7 @@ then
# Force a synchronisation with a time server to avoid certificate issues
if [ -f /boot/candle_hardware_clock.txt ]
then
echo "Candle: rc.local doing post_bootup_actions: hardware clock detected, forcing sync with NTP server" >> /dev/kmsg
echo "Candle: late.sh doing post_bootup_actions: hardware clock detected, forcing sync with NTP server" >> /dev/kmsg
rm /boot/candle_hardware_clock.txt
sudo systemctl start systemd-timesyncd
fi
Expand All @@ -74,29 +74,34 @@ fi


# Do aditional checks for missing files, and restore them if possible.
# Do aditional checks for missing files, and restore them if possible. late.sh does this too, as a fallback.
if [ -d /home/pi/candle/configuration-files-backup ]; then
if rsync --ignore-existing --dry-run -vri /home/pi/candle/configuration-files-backup/* / | grep -q +++++; then
if rsync --ignore-existing --dry-run --inplace -vri /home/pi/candle/configuration-files-backup/* / | grep -q +++++; then
echo "Candle: ERROR, late.sh detected missing files. Attempting to fix" >> /dev/kmsg
echo "$(date) - ERROR, late.sh detected missing files. Attempting to fix." >> /boot/candle_log.txt
if [ -d /ro ]; then
if [ -d /ro/home/pi/candle/configuration-files-backup ]; then
sudo mount -o remount,ro /rw
rsync --ignore-existing -vr /ro/home/pi/candle/configuration-files-backup/* /ro >> /dev/kmsg
rsync --ignore-existing --inplace -vri /ro/home/pi/candle/configuration-files-backup/* /ro > /boot/candle_fix.txt
sudo mount -o remount,ro /ro
fi
else
rsync --ignore-existing -vr /home/pi/candle/configuration-files-backup/* / >> /dev/kmsg
rsync -vr --ignore-existing --inplace /home/pi/candle/configuration-files-backup/* / >> /dev/kmsg
fi

sleep 2
if rsync --ignore-existing --dry-run -vri /home/pi/candle/configuration-files-backup/* / | grep -q +++++; then
if rsync --ignore-existing --inplace --dry-run -vri /home/pi/candle/configuration-files-backup/* / | grep -q +++++; then
echo "Candle: ERROR, late.sh: missing files fix failed" >> /dev/kmsg
echo "$(date) - ERROR, late.sh: missing files fix failed" >> /boot/candle_log.txt
echo "$(date) - ERROR, late.sh: missing files fix failed. See candle_fix_failed.txt" >> /boot/candle_log.txt
rsync --ignore-existing --inplace --dry-run -vri /home/pi/candle/configuration-files-backup/* / > /boot/candle_fix_failed.txt
else
echo "Candle: late.sh: missing files fix succeeded" >> /dev/kmsg
echo "$(date) - late.sh: missing files fix succeeded" >> /boot/candle_log.txt
if [ -f /boot/candle_failed_fix.txt ]; then
rm /boot/candle_failed_fix.txt
fi
fi
fi
else
echo "Candle: warning, configuration files backup dir does not exist" >> /dev/kmsg
echo "Candle: late.sh: warning, configuration files backup dir does not exist" >> /dev/kmsg
fi

0 comments on commit c4479e8

Please sign in to comment.