1 |
jlec 13/12/28 20:27:31 |
2 |
|
3 |
Modified: kexec.init-9999 |
4 |
Log: |
5 |
sys-apps/kexec-tools: Propagate changes to live ebuild |
6 |
|
7 |
(Portage version: 2.2.7/cvs/Linux x86_64, signed Manifest commit with key B9D4F231BD1558AB!) |
8 |
|
9 |
Revision Changes Path |
10 |
1.2 sys-apps/kexec-tools/files/kexec.init-9999 |
11 |
|
12 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-apps/kexec-tools/files/kexec.init-9999?rev=1.2&view=markup |
13 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-apps/kexec-tools/files/kexec.init-9999?rev=1.2&content-type=text/plain |
14 |
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/sys-apps/kexec-tools/files/kexec.init-9999?r1=1.1&r2=1.2 |
15 |
|
16 |
Index: kexec.init-9999 |
17 |
=================================================================== |
18 |
RCS file: /var/cvsroot/gentoo-x86/sys-apps/kexec-tools/files/kexec.init-9999,v |
19 |
retrieving revision 1.1 |
20 |
retrieving revision 1.2 |
21 |
diff -u -r1.1 -r1.2 |
22 |
--- kexec.init-9999 21 Sep 2013 11:35:53 -0000 1.1 |
23 |
+++ kexec.init-9999 28 Dec 2013 20:27:31 -0000 1.2 |
24 |
@@ -1,17 +1,25 @@ |
25 |
#!/sbin/runscript |
26 |
# Copyright 1999-2013 Gentoo Foundation |
27 |
# Distributed under the terms of the GNU General Public License v2 |
28 |
-# $Header: /var/cvsroot/gentoo-x86/sys-apps/kexec-tools/files/kexec.init-9999,v 1.1 2013/09/21 11:35:53 jlec Exp $ |
29 |
+# $Header: /var/cvsroot/gentoo-x86/sys-apps/kexec-tools/files/kexec.init-9999,v 1.2 2013/12/28 20:27:31 jlec Exp $ |
30 |
|
31 |
depend() { |
32 |
need localmount |
33 |
} |
34 |
|
35 |
image_path() { |
36 |
- local x= kver=$(uname -r) |
37 |
- for x in "${KNAME:-bzImage}" vmlinuz \ |
38 |
- bzImage-"${kver}" vmlinuz-"${kver}" ; do |
39 |
- if [ -e "${BOOTPART}/${x}" ] ; then |
40 |
+ local x= kver=$(uname -r) karch=$(uname -m) |
41 |
+ BOOTPART="${BOOTPART:-/boot}" |
42 |
+ KNAME="${KNAME:-bzImage}" |
43 |
+ if [ -e "${KNAME}" ]; then |
44 |
+ echo "${KNAME}" |
45 |
+ return 0 |
46 |
+ fi |
47 |
+ for x in "${KNAME#${BOOTPART}}" vmlinuz \ |
48 |
+ bzImage-${kver} vmlinuz-${kver} \ |
49 |
+ kernel-genkernel-${karch}-${kver} \ |
50 |
+ kernel-${kver} kernel-${karch}; do |
51 |
+ if [ -e "${BOOTPART}/${x}" ]; then |
52 |
echo "${BOOTPART}/${x}" |
53 |
return 0 |
54 |
fi |
55 |
@@ -20,50 +28,89 @@ |
56 |
return 1 |
57 |
} |
58 |
|
59 |
+initrd_path() { |
60 |
+ local x= kver=$(uname -r) karch=$(uname -m) |
61 |
+ BOOTPART="${BOOTPART:-/boot}" |
62 |
+ INITRD="${INITRD:-initrd}" |
63 |
+ if [ -e "${INITRD}" ]; then |
64 |
+ echo "${INITRD}" |
65 |
+ return 0 |
66 |
+ fi |
67 |
+ for x in "${INITRD#${BOOTPART}}" \ |
68 |
+ initrd.img-${kver} initrd-${kver}.img \ |
69 |
+ initrd-${kver} initramfs-${kver}.img \ |
70 |
+ initramfs-genkernel-${karch}-${kver} ; do |
71 |
+ if [ -e "${BOOTPART}/${x}" ]; then |
72 |
+ echo "${BOOTPART}/${x}" |
73 |
+ return 0 |
74 |
+ fi |
75 |
+ done |
76 |
+ |
77 |
+ return 1 |
78 |
+} |
79 |
+ |
80 |
+mount_boot(){ |
81 |
+ local ret |
82 |
+ |
83 |
+ [ -n "${DONT_MOUNT_BOOT}" ] && return 1 |
84 |
+ grep -q " ${BOOTPART:-/boot} " /proc/mounts && return 1 |
85 |
+ |
86 |
+ BOOTPART="${BOOTPART:-/boot}" |
87 |
+ ebegin "Mounting ${BOOTPART}" |
88 |
+ mount "${BOOTPART}"; ret=$? |
89 |
+ eend ${ret} |
90 |
+ return ${ret} |
91 |
+} |
92 |
+ |
93 |
load_image() { |
94 |
- if [ "${KNAME}" = "-" ] ; then |
95 |
+ local ret |
96 |
+ if [ "${KNAME}" = "-" ]; then |
97 |
ebegin "Disabling kexec" |
98 |
- kexec -u |
99 |
- eend $? |
100 |
- return $? |
101 |
+ kexec -u; ret=$? |
102 |
+ eend ${ret} |
103 |
+ return ${ret} |
104 |
fi |
105 |
|
106 |
BOOTPART="${BOOTPART:-/boot}" |
107 |
- local img="$(image_path)" mounted=false initrdopt= |
108 |
+ local img= initrd="$(initrd_path)" mounted=false initrdopt= |
109 |
|
110 |
- if [ -z "${img}" ] ; then |
111 |
- # If we cannot find our image, try mounting ${BOOTPART} |
112 |
- if ! grep -q " ${BOOTPART} " /proc/mounts ; then |
113 |
- ebegin "Mounting ${BOOTPART}" |
114 |
- mount "${BOOTPART}" && mounted=true |
115 |
- eend $? || return $? |
116 |
- img="$(image_path)" |
117 |
+ if ! img="$(image_path)"; then |
118 |
+ if mount_boot; then |
119 |
+ if img="$(image_path)"; then |
120 |
+ mounted=true |
121 |
+ initrd="$(initrd_path)" |
122 |
+ else |
123 |
+ eerror "No kernel image found in ${BOOTPART}!" |
124 |
+ umount "${BOOTPART}" |
125 |
+ return 1 |
126 |
+ fi |
127 |
+ else |
128 |
+ eerror "No kernel image found in ${BOOTPART}!" |
129 |
+ return 1 |
130 |
fi |
131 |
fi |
132 |
|
133 |
- if [ -z "${img}" ] ; then |
134 |
- eerror "No kernel image found in ${BOOTPART}!" |
135 |
- ${mounted} && umount "${BOOTPART}" |
136 |
+ if [ -n "${INITRD}" ] && \ |
137 |
+ ! [ "${BOOTPART}/${INITRD#${BOOTPART}}" = "${initrd}" ]; then |
138 |
+ eerror "Requested initrd: ${INITRD#${BOOTPART}}" |
139 |
+ eerror "could not be found" |
140 |
return 1 |
141 |
fi |
142 |
|
143 |
- ebegin "Loading kernel image ${img} for kexec" |
144 |
- if [ -z "${ROOTPART}" ] ; then |
145 |
- ROOTPART="$(readlink -f "$(sed -n '/^\/[^ ]* \/ / s,^\([^ ]*\).*,\1,p' /etc/mtab)")" |
146 |
- fi |
147 |
- if [ -z "${KPARAM}" ] ; then |
148 |
- KPARAM="$(sed -e 's/ /\n/g' /proc/cmdline | grep -v -e "^root=" | tr '\n' ' ')" |
149 |
- fi |
150 |
+ [ -n "${ROOTPART}" ] || \ |
151 |
+ ROOTPART="$(readlink -f "$(sed -n '/^\/[^ ]* \/ / s,^\([^ ]*\).*,\1,p' /proc/mounts)")" |
152 |
|
153 |
- # Use the default initrd if it exists and none other given |
154 |
- if [ -z "${INITRD}" -a -e "${BOOTPART}"/initrd ] ; then |
155 |
- INITRD="${BOOTPART}/initrd" |
156 |
- fi |
157 |
- if [ -e "${INITRD}" ] ; then |
158 |
- initrdopt="--initrd=${INITRD}" |
159 |
- fi |
160 |
+ [ -n "${KPARAM}" ] || KEXEC_OPT_ARGS="${KEXEC_OPT_ARGS} --reuse-cmdline" |
161 |
+ |
162 |
+ [ -n "${initrd}" ] && [ -e "${initrd}" ] && initrdopt="--initrd=${initrd}" |
163 |
+ |
164 |
+ local msg= |
165 |
+ [ -n "${initrd}" ] && \ |
166 |
+ msg="with ${initrd}" |
167 |
+ einfo "Using kernel image ${img} ${msg} for kexec" |
168 |
|
169 |
- kexec -l "${img}" --append="root=${ROOTPART} ${KPARAM}" ${initrdopt} |
170 |
+ ebegin "Setting kexec with ${KEXEC_OPT_ARGS} -l ${img} root=${ROOTPART} ${KPARAM} ${initrdopt}" |
171 |
+ kexec ${KEXEC_OPT_ARGS} -l "${img}" --append="root=${ROOTPART} ${KPARAM}" ${initrdopt} |
172 |
local res=$? |
173 |
|
174 |
${mounted} && umount "${BOOTPART}" |
175 |
@@ -72,23 +119,47 @@ |
176 |
} |
177 |
|
178 |
start() { |
179 |
- [ "${LOAD_DURING_SHUTDOWN:-yes}" = "yes" ] && return 0 |
180 |
- |
181 |
- ebegin "Configuring kexec" |
182 |
- load_image |
183 |
- eend 0 |
184 |
+ if [ "${LOAD_DURING_SHUTDOWN:-yes}" = "yes" ]; then |
185 |
+ local ret=0 |
186 |
+ BOOTPART="${BOOTPART:-/boot}" |
187 |
+ if mount_boot; then |
188 |
+ mounted=true |
189 |
+ fi |
190 |
+ if ! image_path > /dev/null; then |
191 |
+ ewarn "Cannot find kernel image!" |
192 |
+ ewarn "Please make sure a valid kernel image is present before reboot." |
193 |
+ return 0 |
194 |
+ fi |
195 |
+ if [ -n "${mounted}" ]; then |
196 |
+ ebegin "Unmounting ${BOOTPART}" |
197 |
+ umount "${BOOTPART}"; ret=$? |
198 |
+ eend ${ret} |
199 |
+ fi |
200 |
+ return ${ret} |
201 |
+ else |
202 |
+ ebegin "Configuring kexec" |
203 |
+ load_image |
204 |
+ eend $? |
205 |
+ fi |
206 |
} |
207 |
|
208 |
stop() { |
209 |
[ "${LOAD_DURING_SHUTDOWN:-yes}" != "yes" ] && return 0 |
210 |
|
211 |
- ebegin "Configuring kexec" |
212 |
- if [ "`/sbin/runlevel|/bin/cut -c 3`" != "6" ]; then |
213 |
+ if ! yesno $RC_REBOOT; then |
214 |
einfo "Not rebooting, so disabling" |
215 |
kexec -u |
216 |
return 0 |
217 |
fi |
218 |
|
219 |
+ if [ -f /nokexec ]; then |
220 |
+ einfo "Not using kexec during reboot" |
221 |
+ rm -f /nokexec |
222 |
+ kexec -u |
223 |
+ return 0 |
224 |
+ fi |
225 |
+ |
226 |
+ ebegin "Configuring kexec" |
227 |
load_image |
228 |
eend $? |
229 |
} |