-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathkexec-bootloader
executable file
·70 lines (54 loc) · 1.35 KB
/
kexec-bootloader
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#! /usr/bin/sh
# Print help text and exit.
#
usage () {
cat <<EOF
Usage: kexec-bootloader [OPTIONS]
Loads kexec kernel from bootloader configuration.
Options:
-D, --debug Print debugging information.
--dry-run Do everything but don't actually run kexec.
-h, --help Show this help message.
kexec-bootloader gets the default kernel, initrd, and boot options and
prepares a kexec() system call with it.
You then can run 'kexec --exec' to boot with this configuration.
EOF
exit "$1"
}
while true ; do
case $1 in
-D|--debug) opt_debug=1 ; shift ; continue ;;
--dry-run) opt_dry_run=1; shift ; continue ;;
-h|--help) usage 0 ;;
esac
break
done
[ "$#" != 0 ] && usage 1
. <(pbl --default-settings) || {
echo "pbl failed to provide settings" >&2
exit 1
}
for i in $(cat /proc/cmdline) ; do
case $i in
root=*) root=$i ; break ;;
esac
done
if [ -z "$root" ] ; then
echo "Could not determine no 'root' option." >&2
exit 1
fi
kexec="kexec --kexec-syscall-auto --load '$kernel' --initrd='$initrd' --append='$root $append'"
if [ "$opt_debug" = 1 ] ; then
echo "Image : $kernel"
echo "Initrd : $initrd"
echo "Append : $append"
echo "Root : $root"
echo "Kexec call: $kexec"
fi
if [ "$opt_dry_run" != 1 ] ; then
sh -c "$kexec" || {
echo "kexec failed." >&2
exit 1
}
fi
exit 0