diff --git a/home/pi/candle/late.sh b/home/pi/candle/late.sh index c8a907a..4860394 100644 --- a/home/pi/candle/late.sh +++ b/home/pi/candle/late.sh @@ -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 @@ -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 @@ -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