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#") initrd=$(echo "$kernel" | sed "s#vmlinuz#initrd.img#")
if ! test -r "$initrd"; then if ! test -r "$initrd"; then
echo "$0: ERROR: Initrd File '$initrd' not found or not readable!" echo "$0: ERROR: Initrd File '$initrd' not found or not readable!"
exit 1 exit 1
fi fi
if ! test -r "$kernel"; then if ! test -r "$kernel"; then
echo "$0: ERROR: Kernel File '$kernel' not found or not readable!" echo "$0: ERROR: Kernel File '$kernel' not found or not readable!"
exit 1 exit 1
fi fi
if systemctl list-jobs | grep "poweroff.target" | grep -q "start"; then if systemctl list-jobs | grep "poweroff.target" | grep -q "start"; then
wiperamexit="yes" wiperamexit="yes"
wiperamaction="poweroff" wiperamaction="poweroff"
elif systemctl list-jobs | grep "reboot.target" | grep -q "start"; then elif systemctl list-jobs | grep "reboot.target" | grep -q "start"; then
wiperamexit="yes" wiperamexit="yes"
wiperamaction="reboot" wiperamaction="reboot"
elif systemctl list-jobs | grep "halt.target" | grep -q "start"; then elif systemctl list-jobs | grep "halt.target" | grep -q "start"; then
wiperamexit="yes" wiperamexit="yes"
wiperamaction="halt" wiperamaction="halt"
else else
echo "$0: INFO: No shutdown option found!" ## Could be kexec.target.
exit 0 echo "$0: INFO: Neither poweroff, reboot or halt. Therefore skipping kexec load, ok."
exit 0
fi fi
kexec -l "$kernel" --initrd="$initrd" --reuse-cmdline --append="wiperamexit=$wiperamexit wiperamaction=$wiperamaction" kexec -l "$kernel" --initrd="$initrd" --reuse-cmdline --append="wiperamexit=$wiperamexit wiperamaction=$wiperamaction"