Allow to pass extra flags into the kexec call via KEXEC_EXTRA_FLAGS

This commit is contained in:
Johannes Bornhold 2024-06-05 16:34:05 +02:00 committed by mergify[bot]
parent 75d8ee3810
commit e2fd329c3a

25
nix/kexec-installer/kexec-run.sh Normal file → Executable file
View file

@ -1,6 +1,19 @@
#!/bin/sh #!/bin/sh
set -ex set -ex
kexec_extra_flags=""
while [ $# -gt 0 ]; do
case "$1" in
--kexec-extra-flags)
kexec_extra_flags="$2"
shift
;;
esac
shift
done
# provided by nix # provided by nix
init="@init@" init="@init@"
kernelParams="@kernelParams@" kernelParams="@kernelParams@"
@ -65,10 +78,12 @@ if printf "%s\n" "6.1" "$(uname -r)" | sort -c -V 2>&1; then
kexecSyscallFlags="--kexec-syscall-auto" kexecSyscallFlags="--kexec-syscall-auto"
fi fi
if ! "$SCRIPT_DIR/kexec" --load "$SCRIPT_DIR/bzImage" \ if ! sh -c "'$SCRIPT_DIR/kexec' --load '$SCRIPT_DIR/bzImage' \
"$kexecSyscallFlags" \ $kexecSyscallFlags \
--initrd="$SCRIPT_DIR/initrd" --no-checks \ $kexec_extra_flags \
--command-line "init=$init $kernelParams"; then --initrd='$SCRIPT_DIR/initrd' --no-checks \
--command-line 'init=$init $kernelParams'"
then
echo "kexec failed, dumping dmesg" echo "kexec failed, dumping dmesg"
dmesg | tail -n 100 dmesg | tail -n 100
exit 1 exit 1
@ -84,4 +99,4 @@ else
fi fi
# We will kexec in background so we can cleanly finish the script before the hosts go down. # We will kexec in background so we can cleanly finish the script before the hosts go down.
# This makes integration with tools like terraform easier. # This makes integration with tools like terraform easier.
nohup sh -c "sleep 6 && '$SCRIPT_DIR/kexec' -e" & nohup sh -c "sleep 6 && '$SCRIPT_DIR/kexec' -e ${kexec_extra_flags}" &