This commit is contained in:
Patrick Schleizer 2023-01-07 15:13:36 -05:00
parent bb2f0a3c44
commit 822cf64618
No known key found for this signature in database
GPG Key ID: CB8D50BB77BB3C48

View File

@ -15,27 +15,28 @@ kernel=$(echo "$cmdline" | grep -o 'BOOT_IMAGE=\S*' | cut -d '=' -f 2)
initrd=$(echo "$kernel" | sed "s#vmlinuz#initrd.img#")
if ! test -r "$initrd"; then
echo "$0: ERROR: Initrd File '$initrd' not found or not readable!"
exit 1
echo "$0: ERROR: Initrd File '$initrd' not found or not readable!"
exit 1
fi
if ! test -r "$kernel"; then
echo "$0: ERROR: Kernel File '$kernel' not found or not readable!"
exit 1
echo "$0: ERROR: Kernel File '$kernel' not found or not readable!"
exit 1
fi
if systemctl list-jobs | grep "poweroff.target" | grep -q "start"; then
wiperamexit="yes"
wiperamaction="poweroff"
wiperamexit="yes"
wiperamaction="poweroff"
elif systemctl list-jobs | grep "reboot.target" | grep -q "start"; then
wiperamexit="yes"
wiperamaction="reboot"
wiperamexit="yes"
wiperamaction="reboot"
elif systemctl list-jobs | grep "halt.target" | grep -q "start"; then
wiperamexit="yes"
wiperamaction="halt"
wiperamexit="yes"
wiperamaction="halt"
else
echo "$0: INFO: No shutdown option found!"
exit 0
## Could be kexec.target.
echo "$0: INFO: Neither poweroff, reboot or halt. Therefore skipping kexec load, ok."
exit 0
fi
kexec -l "$kernel" --initrd="$initrd" --reuse-cmdline --append="wiperamexit=$wiperamexit wiperamaction=$wiperamaction"