The following is the GNU All-permissive License as recommended in https://www.gnu.org/licenses/license-recommendations.en.html

Copyright (C) 2024 Free Software Foundation sysadmin@fsf.org

Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. This file is offered as-is, without any warranty.

Contributions are welcome. See https://savannah.gnu.org/maintenance/fsf/.

using sysrq to reboot when systemd is broken

This script comes from Bob Proulx:

#!/bin/sh
echo 1 >/proc/sys/kernel/sysrq
echo s >/proc/sysrq-trigger
echo b >/proc/sysrq-trigger

It may also be worth trying to manually kill important processes first, so they have a chance to write out any state to disk before the system halts and immediately reboots.