diff options
| -rwxr-xr-x | modules.d/slx-watchdog/hooks/s3-systemd-watchdog.sh | 37 | ||||
| -rwxr-xr-x | modules.d/slx-watchdog/hooks/s3-watchdog.sh | 46 | ||||
| -rwxr-xr-x | modules.d/slx-watchdog/module-setup.sh | 6 |
3 files changed, 56 insertions, 33 deletions
diff --git a/modules.d/slx-watchdog/hooks/s3-systemd-watchdog.sh b/modules.d/slx-watchdog/hooks/s3-systemd-watchdog.sh new file mode 100755 index 00000000..ae0a0e0c --- /dev/null +++ b/modules.d/slx-watchdog/hooks/s3-systemd-watchdog.sh @@ -0,0 +1,37 @@ +#!/bin/ash + +find_watchdog() { + dev= + for dir in /sys/class/watchdog/*; do + [ -f "$dir/identity" ] || continue + t=$( cat "$dir/identity" ) + # iamt can go nuts after entering/leaving standby a couple times + # https://github.com/systemd/systemd/issues/35405 + [ "$t" = "iamt_wdt" ] && continue + # Not properly enabled in some BIOSes, i.e. does nothing when it fires + # https://community.intel.com/t5/Processors/Using-linux-iTCO-wdt-driver-on-i3-7100/m-p/1126815 + # https://archive.is/YuHcc + [ "$t" = "iTCO_wdt" ] && continue + # First one not known to suck is fine + dev="${dir##*/}" + break + done +} + +find_watchdog +if [ -z "$dev" ]; then + modprobe softdog + find_watchdog +fi + +if [ -z "$dev" ]; then + echo "No suitable watchdog found, systemd will pick default" +else + echo "Selected watchdog $dev, identity '$( cat "/sys/class/watchdog/$dev/identity" )'" + { + echo "[Manager]" + echo "WatchdogDevice=/dev/$dev" + } > "${NEWROOT}/etc/systemd/system.conf.d/10-watchdog-dev.conf" +fi + +true diff --git a/modules.d/slx-watchdog/hooks/s3-watchdog.sh b/modules.d/slx-watchdog/hooks/s3-watchdog.sh index ae0a0e0c..2064ad97 100755 --- a/modules.d/slx-watchdog/hooks/s3-watchdog.sh +++ b/modules.d/slx-watchdog/hooks/s3-watchdog.sh @@ -1,37 +1,19 @@ -#!/bin/ash +#!/bin/sh -find_watchdog() { - dev= - for dir in /sys/class/watchdog/*; do - [ -f "$dir/identity" ] || continue - t=$( cat "$dir/identity" ) - # iamt can go nuts after entering/leaving standby a couple times - # https://github.com/systemd/systemd/issues/35405 - [ "$t" = "iamt_wdt" ] && continue - # Not properly enabled in some BIOSes, i.e. does nothing when it fires - # https://community.intel.com/t5/Processors/Using-linux-iTCO-wdt-driver-on-i3-7100/m-p/1126815 - # https://archive.is/YuHcc - [ "$t" = "iTCO_wdt" ] && continue - # First one not known to suck is fine - dev="${dir##*/}" - break - done -} +sleep 30 # Hopefully enough - usually takes 3-4 seconds from here -find_watchdog -if [ -z "$dev" ]; then - modprobe softdog - find_watchdog -fi +# We didn't get killed in time - send report +. /etc/openslx +[ -z "$SLX_REMOTE_LOG" ] && exit 1 + +echo "SLX-Watchdog timed out, sending debug report" +journalctl -b > /tmp/journal.txt -if [ -z "$dev" ]; then - echo "No suitable watchdog found, systemd will pick default" -else - echo "Selected watchdog $dev, identity '$( cat "/sys/class/watchdog/$dev/identity" )'" - { - echo "[Manager]" - echo "WatchdogDevice=/dev/$dev" - } > "${NEWROOT}/etc/systemd/system.conf.d/10-watchdog-dev.conf" +UUID= +if [ -s /run/system-uuid ]; then + UUID=$( cat /run/system-uuid ) fi -true +curl -sS --data-urlencode "uuid=$UUID" --data-urlencode "type=initrd-timeout" \ + --data-urlencode "description=Stuck in stage 3" --data-urlencode "longdesc@/tmp/journal.txt" \ + "$SLX_REMOTE_LOG" diff --git a/modules.d/slx-watchdog/module-setup.sh b/modules.d/slx-watchdog/module-setup.sh index 80587b0c..26df4a34 100755 --- a/modules.d/slx-watchdog/module-setup.sh +++ b/modules.d/slx-watchdog/module-setup.sh @@ -8,9 +8,13 @@ depends() { : } install() { - slx_service "s3-watchdog" "Pick preferred watchdog device for systemd" \ + slx_service "s3-systemd-watchdog" "Pick preferred watchdog device for systemd" \ --after "initrd-root-fs.target" \ --requires "initrd-root-fs.target" + slx_service "s3-watchdog" "Send error report to server if we stay in stage3 for too long" \ + --type "simple" \ + --after "s3-fetch-config.service" \ + --requires "s3-fetch-config.service" # Try to enforce nowayout for all watchdogs inst_simple "$moddir/data/slx-nowayout.conf" "/etc/modprobe.d/slx-nowayout.conf" } |
