ops: rescue unit no longer disables itself on stop; watchdog loaded from a unit (Ubuntu deny-lists the module)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
7b037f6092
commit
8e8194dfeb
@@ -29,6 +29,7 @@ while [ $# -gt 0 ]; do
|
||||
--install) mode=install ;;
|
||||
--check) mode=check ;;
|
||||
--remove) mode=remove ;;
|
||||
--stop) mode=stop ;;
|
||||
--copytest) mode=copytest ;;
|
||||
--netconsole) mode=netconsole; laptop_ip=${2:?laptop ip}; shift ;;
|
||||
*) echo "unknown argument: $1" >&2; exit 2 ;;
|
||||
@@ -145,7 +146,7 @@ After=network-online.target
|
||||
Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
ExecStart=/usr/local/sbin/rescue-sshd.sh --build
|
||||
ExecStop=/usr/local/sbin/rescue-sshd.sh --remove
|
||||
ExecStop=/usr/local/sbin/rescue-sshd.sh --stop
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
@@ -165,6 +166,8 @@ EOF
|
||||
modprobe netconsole "netconsole=6665@$src/$ifc,6666@$laptop_ip/"
|
||||
echo "kernel messages now go by UDP to $laptop_ip:6666 (on the laptop: any UDP listener, e.g. python -c ... or ncat -ul 6666)"
|
||||
echo "to keep it after reboot: echo 'netconsole netconsole=6665@$src/$ifc,6666@$laptop_ip/' > /etc/modules-load.d/netconsole.conf" ;;
|
||||
stop) # used by the unit's ExecStop: only tear the chroot down; the unit must stay enabled for the next boot
|
||||
teardown ;;
|
||||
remove)
|
||||
systemctl disable --now leleka-rescue-sshd.service 2>/dev/null || true
|
||||
rm -f /etc/systemd/system/leleka-rescue-sshd.service; systemctl daemon-reload 2>/dev/null || true
|
||||
|
||||
@@ -12,12 +12,13 @@
|
||||
# file, so the machine is unusable until someone toggles the power.
|
||||
set -euo pipefail
|
||||
|
||||
want_auto=0; want_swap=0; want_nvme=0
|
||||
want_auto=0; want_swap=0; want_nvme=0; want_wd=0
|
||||
for a in "$@"; do
|
||||
case "$a" in
|
||||
--autoreboot) want_auto=1 ;;
|
||||
--swapoff) want_swap=1 ;;
|
||||
--nvme-params) want_nvme=1 ;;
|
||||
--watchdog-boot) want_wd=1 ;;
|
||||
*) echo "unknown argument: $a" >&2; exit 2 ;;
|
||||
esac
|
||||
done
|
||||
@@ -25,7 +26,7 @@ if [ "$(id -u)" -ne 0 ]; then echo "run as root (sudo)" >&2; exit 1; fi
|
||||
|
||||
say() { printf '%s\n' "$*"; }
|
||||
|
||||
if [ $((want_auto + want_swap + want_nvme)) -eq 0 ]; then
|
||||
if [ $((want_auto + want_swap + want_nvme + want_wd)) -eq 0 ]; then
|
||||
say "DRY RUN. Nothing is changed. Steps (run them in this order, one at a time):"
|
||||
say " --autoreboot /etc/sysctl.d/90-leleka-hang.conf: kernel.hung_task_panic=1, hung_task_timeout_secs=120, kernel.panic=10, kernel.panic_on_oops=1;"
|
||||
say " disables kdump-tools (a crash kernel writing a vmcore to the stalled disk would hang the reboot);"
|
||||
@@ -90,3 +91,27 @@ if [ "$want_nvme" -eq 1 ]; then
|
||||
update-grub
|
||||
say "grub updated (backup /etc/default/grub.pre-leleka-nvme). Reboot to apply; check: cat /proc/cmdline"
|
||||
fi
|
||||
|
||||
if [ "$want_wd" -eq 1 ]; then
|
||||
# Ubuntu deny-lists every watchdog module and systemd-modules-load honours that, so modules-load.d does nothing.
|
||||
# Load it from a unit instead (explicit modprobe works) and re-exec systemd so it opens /dev/watchdog0.
|
||||
rm -f /etc/modules-load.d/sp5100_tco.conf
|
||||
cat > /etc/systemd/system/leleka-watchdog-load.service <<'EOF2'
|
||||
[Unit]
|
||||
Description=Load the AMD SP5100 TCO hardware watchdog (Ubuntu deny-lists it) and hand it to systemd
|
||||
DefaultDependencies=no
|
||||
After=systemd-modules-load.service
|
||||
Before=sysinit.target
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
ExecStart=/sbin/modprobe sp5100_tco
|
||||
ExecStartPost=/bin/systemctl daemon-reexec
|
||||
[Install]
|
||||
WantedBy=sysinit.target
|
||||
EOF2
|
||||
systemctl daemon-reload
|
||||
systemctl enable leleka-watchdog-load.service
|
||||
if ! ls /dev/watchdog0 >/dev/null 2>&1; then systemctl start leleka-watchdog-load.service; fi
|
||||
say "watchdog loader enabled; /dev/watchdog0: $(ls /dev/watchdog0 2>&1)"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user