summaryrefslogtreecommitdiffstats
path: root/core/modules/kexec-reboot/data/opt/openslx/scripts/systemd-kexec_load
blob: 5907bc0bd3942d5629af0941565509a0bfc4a901 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/ash

kexec=$(which kexec 2>/dev/null)
if [ -z "$kexec" ]; then
	echo "Failed to find kexec binary in PATH. Exiting."
	exit 1
fi

. /opt/openslx/bin/slx-tools

kexec_load() {
	. /opt/openslx/config
	local DIR="$(mktemp -d)"

	for FILE in kernel initramfs-stage31; do
		if ! download_retry "http://${SLX_KCL_SERVERS}/${SLX_BASE_PATH}/${FILE}" > "${DIR}/${FILE}" ; then
			echo "Failed to download ${FILE}."
			exit 1
		fi
	done
	if download_retry "http://${SLX_KCL_SERVERS}/tftp/bwlp.cpio" > "${DIR}/bwlp.cpio"; then
		cat "${DIR}/initramfs-stage31" "${DIR}/bwlp.cpio" > "${DIR}/initramfs-tmp"
		mv -f -- "${DIR}/initramfs-tmp" "${DIR}/initramfs-stage31"
	fi
	if ! kexec -l "${DIR}/kernel" --initrd "${DIR}/initramfs-stage31" --reuse-cmdline; then
		echo "Failed to load kernel/initrd from ${DIR}"
		exit 1
	fi
}

kexec_load