Backup scripts read device/UUID/target from the host config

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-23 14:36:46 -04:00
co-authored by Claude Sonnet 5
parent 83974f731d
commit 3d117e714c
3 changed files with 34 additions and 7 deletions
+6 -1
View File
@@ -19,9 +19,14 @@
# The bootloader in the SD's first sectors (idbloader/u-boot) is not touched. # The bootloader in the SD's first sectors (idbloader/u-boot) is not touched.
set -euo pipefail set -euo pipefail
# Backup settings come from the host config (see hosts/vanlink.conf.example).
# shellcheck disable=SC1090
. "${VANLINK_CONF:-/etc/vanlink.conf}"
: "${SD_BACKUP_UUID:?set SD_BACKUP_UUID in /etc/vanlink.conf}"
[ "$(id -u)" -eq 0 ] || { echo "Run as root (sudo)." >&2; exit 1; } [ "$(id -u)" -eq 0 ] || { echo "Run as root (sudo)." >&2; exit 1; }
SD_UUID=39118305-4927-47a4-acc7-ba022f37af22 SD_UUID=$SD_BACKUP_UUID
SD_ROOT_PART=/dev/disk/by-uuid/$SD_UUID SD_ROOT_PART=/dev/disk/by-uuid/$SD_UUID
MOUNT_POINT=/mnt/sd-backup-root MOUNT_POINT=/mnt/sd-backup-root
FAILSAFE='boot-failesafe-rename-to:boot.scr' FAILSAFE='boot-failesafe-rename-to:boot.scr'
+10 -6
View File
@@ -11,15 +11,19 @@
# memory "sd-fallback-fstab-clobber" for what breaks if those leak across. # memory "sd-fallback-fstab-clobber" for what breaks if those leak across.
set -euo pipefail set -euo pipefail
# Backup settings come from the host config (see hosts/vanlink.conf.example).
# shellcheck disable=SC1090
. "${VANLINK_CONF:-/etc/vanlink.conf}"
: "${USB_BACKUP_ROOT_PART:?set USB_BACKUP_ROOT_PART in /etc/vanlink.conf}"
: "${USB_BACKUP_MOUNT:?set USB_BACKUP_MOUNT in /etc/vanlink.conf}"
[ "$(id -u)" -eq 0 ] || { echo "Run as root (sudo)." >&2; exit 1; } [ "$(id -u)" -eq 0 ] || { echo "Run as root (sudo)." >&2; exit 1; }
USB_ROOT_PART=/dev/sda2 USB_ROOT_PART=$USB_BACKUP_ROOT_PART
MOUNT_POINT=/mnt/usb-backup-root MOUNT_POINT=$USB_BACKUP_MOUNT
MOUNT_POINT=10.42.1.44:/media/andreas/writable-nvme
# host:/path means an already-exported NFS target: nothing to mount locally.
[[ "$MOUNT_POINT" == *":"* ]] if [[ "$MOUNT_POINT" == *":"* ]]; then LOCAL_MOUNT=0; else LOCAL_MOUNT=1; fi
LOCAL_MOUNT=$?
root_src=$(findmnt -no SOURCE /) root_src=$(findmnt -no SOURCE /)
if [ "$root_src" = "$USB_ROOT_PART" ]; then if [ "$root_src" = "$USB_ROOT_PART" ]; then
+18
View File
@@ -90,6 +90,24 @@ if awk '
END { exit bad } END { exit bad }
' deploy.sh; then ok "flagged units are only touched inside their ENABLE_* guard"; else bad "flag gating"; fi ' deploy.sh; then ok "flagged units are only touched inside their ENABLE_* guard"; else bad "flag gating"; fi
# 7. backup scripts take their settings from the host config and say what is missing
empty=$(mktemp); trap 'rm -f "$empty"' EXIT
for pair in "failover/sync-usb-backup.sh:USB_BACKUP_ROOT_PART" "failover/sync-sd-backup.sh:SD_BACKUP_UUID"; do
s=${pair%%:*}; v=${pair##*:}
if out=$(VANLINK_CONF="$empty" "./$s" 2>&1); then
bad "$s should fail when $v is not set"
elif echo "$out" | grep -q "$v"; then
ok "$s names missing $v"
else
bad "$s failed but did not mention $v"; echo "$out" | sed 's/^/ /'
fi
done
if grep -nE '/dev/sda2|10\.42\.[01]\.44|39118305-4927' failover/sync-*-backup.sh; then
bad "hardcoded host values remain in the backup scripts"
else
ok "no hardcoded devices/UUIDs/addresses in the backup scripts"
fi
# 8. ./deploy.sh --diff runs (no root) and lists rendered files # 8. ./deploy.sh --diff runs (no root) and lists rendered files
if out=$(./deploy.sh --diff hosts/van.conf 2>&1) && echo "$out" | grep -qE '^(NEW|CHANGED) '; then if out=$(./deploy.sh --diff hosts/van.conf 2>&1) && echo "$out" | grep -qE '^(NEW|CHANGED) '; then
ok "deploy.sh --diff hosts/van.conf" ok "deploy.sh --diff hosts/van.conf"