#!/bin/bash # run-step.sh "" [expect-kernel] # Runs the pre-command, reboots, waits for a NEW boot id (≤ 6 min), records the result. Exit 1 if the box did not return. B=$1 L=$2 TGT=$3 PRE=$4 EXP=${5:-} D=/mnt/5_hdd/felhom.eu/git/felhom.eu/documentation/audits/kernel-spike-2026-10-07/$B/$L; mkdir -p $D q() { ssh -o BatchMode=yes -o ConnectTimeout=5 $TGT "export LC_ALL=C; $1" 2>/dev/null; } q "$PRE" > $D/pre.txt q 'cat /proc/sys/kernel/random/boot_id' > $D/bootid.before { q 'uname -r; grub-editenv /boot/efi/EFI/proxmox/felhom-oneshot.env list; efibootmgr | grep -E "BootNext|BootOrder"'; date -u +%FT%TZ; } > $D/before.txt q 'systemctl reboot'; t0=$(date +%s); up="" while [ $(( $(date +%s) - t0 )) -lt 360 ]; do b=$(q 'cat /proc/sys/kernel/random/boot_id'); s=$(( $(date +%s) - t0 )) if [ -n "$b" ] && [ "$b" != "$(cat $D/bootid.before)" ]; then up=$s; break; fi; sleep 3 done if [ -z "$up" ]; then echo "$L: NOT BACK after 360 s" | tee $D/result.txt; exit 1; fi q 'uname -r; cat /proc/cmdline; echo "env: $(grub-editenv /boot/efi/EFI/proxmox/felhom-oneshot.env list)"; efibootmgr | grep -E "BootCurrent|BootNext|BootOrder"; journalctl --list-boots | tail -2' > $D/after.txt K=$(head -1 $D/after.txt) gap=$(tail -2 $D/after.txt | python3 -c " import sys,re,datetime L=[l for l in sys.stdin.read().split('\n') if l.strip()] f=lambda l: re.findall(r'\w{3} (\d{4}-\d\d-\d\d \d\d:\d\d:\d\d)',l) try: end=datetime.datetime.strptime(f(L[0])[1],'%Y-%m-%d %H:%M:%S'); st=datetime.datetime.strptime(f(L[1])[0],'%Y-%m-%d %H:%M:%S'); print(int((st-end).total_seconds())) except Exception: print('?')") v="kernel=$K back=${up}s gap-between-boots=${gap}s"; [ -n "$EXP" ] && { [ "$K" = "$EXP" ] && v="PASS $v" || v="FAIL (want $EXP) $v"; } echo "$L: $v" | tee $D/result.txt