summaryrefslogtreecommitdiffstats
path: root/modules.d/kexec-reboot/scripts/kexec-reboot.sh
diff options
context:
space:
mode:
Diffstat (limited to 'modules.d/kexec-reboot/scripts/kexec-reboot.sh')
-rwxr-xr-xmodules.d/kexec-reboot/scripts/kexec-reboot.sh39
1 files changed, 39 insertions, 0 deletions
diff --git a/modules.d/kexec-reboot/scripts/kexec-reboot.sh b/modules.d/kexec-reboot/scripts/kexec-reboot.sh
new file mode 100755
index 00000000..68fa73b9
--- /dev/null
+++ b/modules.d/kexec-reboot/scripts/kexec-reboot.sh
@@ -0,0 +1,39 @@
+#!/bin/bash
+
+kexec_load() {
+ . /lib/dracut-lib.sh
+
+ local SLXSRV="$(getarg slxsrv)"
+ local SLXBASE="$(getarg slxbase)"
+ local DIR="$(mktemp -d)"
+
+ if [ -z "$SLXSRV" -o -z "$SLXBASE" -o -z "$DIR" ]; then
+ echo "Failed to construct download URL..."
+ return 1
+ fi
+ for FILE in kernel initramfs-stage31; do
+ if ! slx-tools download_retry "http://${SLXSRV}/${SLXBASE}/${FILE}" > "${DIR}/${FILE}" ; then
+ echo "Failed to download ${FILE}."
+ return 1
+ fi
+ done
+
+ if ! kexec --load "${DIR}/kernel" \
+ --initrd "${DIR}/initramfs-stage31" \
+ --reuse-cmdline "${1:+--append "$@"}"; then
+ echo "Failed to load kernel/initrd from ${DIR}"
+ return 1
+ fi
+ return 0
+}
+
+if ! hash kexec; then
+ echo "kexec binary not found, aborting..."
+ exit 1
+fi
+if kexec_load $@; then
+ kexec -e
+else
+ echo "Failed to execute kexec --load"
+ exit 1
+fi