Skip to content

Instantly share code, notes, and snippets.

@rany2
Last active December 9, 2022 17:48
Show Gist options
  • Save rany2/c54df61cd3d7871e06cc92c1dd35a16a to your computer and use it in GitHub Desktop.
Save rany2/c54df61cd3d7871e06cc92c1dd35a16a to your computer and use it in GitHub Desktop.
Fast reboots for X86 OpenWRT machines
#!/bin/sh
unset TERM
export LC_ALL=C
if [ "$__KEXEC_REBOOT_NOHUP" != "1" ]
then
SCRIPTPATH=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
__KEXEC_REBOOT_NOHUP=1 nohup "$SCRIPTPATH/$(basename -- "$0")" "$@" > /dev/null 2>&1 </dev/null &
exit "$?"
fi
kexec --load /boot/vmlinuz --reuse-cmdline
for i in /etc/rc.d/K*; do
if [ -x "$i" ]
then
"$i" stop > /dev/null 2>&1 </dev/null
fi
done
kexec --exec
exit "$?"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment