1 |
#!/bin/bash |
#!/bin/bash |
2 |
|
# $Id$ |
3 |
# |
# |
4 |
# new-kernel-pkg |
# new-kernel-pkg |
5 |
# Invoked upon installation or removal of a kernel package, the following |
# Invoked upon installation or removal of a kernel package, the following |
25 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
26 |
# |
# |
27 |
|
|
28 |
|
read_os_release() |
29 |
|
{ |
30 |
|
local NAME |
31 |
|
local ID |
32 |
|
local Version |
33 |
|
local Version_ID |
34 |
|
local PRETTY_NAME |
35 |
|
local ANSI_COLOR |
36 |
|
local CPE_NAME |
37 |
|
|
38 |
|
if [[ -f /etc/os-release ]] |
39 |
|
then |
40 |
|
source /etc/os-release |
41 |
|
|
42 |
|
case $1 in |
43 |
|
name) echo "${NAME}" ;; |
44 |
|
id) echo "${ID}" ;; |
45 |
|
version) echo "${Version}" ;; |
46 |
|
version_id) echo "${Version_ID}" ;; |
47 |
|
pretty_name) echo "${PRETTY_NAME}" ;; |
48 |
|
ansi_color) echo "${ANSI_COLOR}" ;; |
49 |
|
cpe_name) echo "${CPE_NAME}" ;; |
50 |
|
esac |
51 |
|
fi |
52 |
|
} |
53 |
|
|
54 |
PATH=/sbin:/bin:$PATH |
PATH=/sbin:/bin:$PATH |
55 |
|
|
56 |
lilo=/sbin/lilo |
lilo=/sbin/lilo |
58 |
# some defaults that are sane for most arches |
# some defaults that are sane for most arches |
59 |
kernelName=kernel |
kernelName=kernel |
60 |
|
|
61 |
if [ -x ./grubby ]; then |
if [ -x ./grubby ] |
62 |
grubby=./grubby |
then |
63 |
|
grubby=./grubby |
64 |
else |
else |
65 |
grubby=/sbin/grubby |
grubby=/sbin/grubby |
66 |
fi |
fi |
67 |
|
|
68 |
[ -f /etc/sysconfig/kernel ] && . /etc/sysconfig/kernel |
[ -f /etc/conf.d/grubby ] && . /etc/conf.d/grubby |
69 |
|
[ -f /etc/conf.d/grubby-uboot ] && . /etc/conf.d/grubby-uboot |
70 |
|
|
71 |
|
cfgGrub2="" |
72 |
|
cfgGrub2Efi="" |
73 |
cfgGrub="" |
cfgGrub="" |
74 |
cfgLilo="" |
cfgLilo="" |
75 |
|
cfgExtlinux="" |
76 |
|
cfguBoot="" |
77 |
runLilo="" |
runLilo="" |
78 |
grubConfig="" |
grubConfig="" |
79 |
|
grub2Config="" |
80 |
|
grub2EfiConfig="" |
81 |
|
extlinuxConfig="" |
82 |
|
|
83 |
ARCH=$(uname -m) |
ARCH=$(uname -m) |
84 |
|
|
85 |
if [ $ARCH = 'ia64' ]; then |
if [[ ${ARCH} = ia64 ]] |
86 |
liloConfig=/boot/efi/EFI/redhat/elilo.conf |
then |
87 |
bootPrefix=/boot/efi/EFI/redhat |
liloConfig=/boot/efi/EFI/redhat/elilo.conf |
88 |
liloFlag=elilo |
bootPrefix=/boot/efi/EFI/redhat |
89 |
isx86="" |
liloFlag=elilo |
90 |
elif [ $ARCH = 'ppc64' -o $ARCH = 'ppc' ]; then |
isx86="" |
91 |
liloConfig=/etc/yaboot.conf |
elif [[ ${ARCH} = ppc64 ]] || [[ ${ARCH} = ppc ]] |
92 |
bootPrefix=/boot |
then |
93 |
lilo=/sbin/ybin |
liloConfig=/etc/yaboot.conf |
94 |
liloFlag=yaboot |
grub2Config=/boot/grub/grub.cfg |
95 |
runLilo="yes" |
bootPrefix=/boot |
96 |
isx86="" |
lilo=/sbin/ybin |
97 |
elif [ $ARCH = 'sparc' -o $ARCH = 'sparc64' ]; then |
liloFlag=yaboot |
98 |
liloConfig=/etc/silo.conf |
runLilo="yes" |
99 |
bootPrefix=/boot |
isx86="" |
100 |
liloFlag=silo |
elif [[ ${ARCH} = sparc ]] || [[ ${ARCH} = sparc64 ]] |
101 |
lilo=/sbin/silo |
then |
102 |
isx86="" |
liloConfig=/etc/silo.conf |
103 |
elif [ $ARCH = 's390' -o $ARCH = 's390x' ]; then |
bootPrefix=/boot |
104 |
liloConfig=/etc/zipl.conf |
liloFlag=silo |
105 |
bootPrefix=/boot |
lilo=/sbin/silo |
106 |
liloFlag=zipl |
isx86="" |
107 |
lilo=/sbin/zipl |
elif [[ ${ARCH} = s390 ]] || [[ ${ARCH} = s390x ]] |
108 |
runLilo="yes" |
then |
109 |
isx86="" |
liloConfig=/etc/zipl.conf |
110 |
|
bootPrefix=/boot |
111 |
|
liloFlag=zipl |
112 |
|
lilo=/sbin/zipl |
113 |
|
runLilo="yes" |
114 |
|
isx86="" |
115 |
|
elif [[ ${ARCH} = armv7l ]] || [[ ${ARCH} = armv7hl ]] || [[ ${ARCH} = armv5tel ]] |
116 |
|
then |
117 |
|
liloConfig="" |
118 |
|
bootPrefix=/boot |
119 |
|
ubootDir=${UBOOT_DIR:-"/boot/uboot"} |
120 |
|
ubootScript=$ubootDir/${UBOOT_SCR:-"boot.scr"} |
121 |
|
ubootKList=${UBOOT_KLIST:-"klist.txt"} |
122 |
|
ubootDevice=/dev/${UBOOT_DEVICE:-"mmcblk0p1"} |
123 |
|
ubootDefaultImage=${UBOOT_UIMAGE:-"uImage"} |
124 |
|
ubootDefaultInitrd=${UBOOT_UINITRD:-"uInitrd"} |
125 |
|
mounted="" |
126 |
|
liloFlag="" |
127 |
|
isx86="" |
128 |
|
if [[ -z ${UBOOT_IMGADDR} ]] |
129 |
|
then |
130 |
|
machine=$(grep "^Hardware" /proc/cpuinfo | sed 's/Hardware\s*:\s*//') |
131 |
|
if [ "${machine}" == "OMAP3 Beagle Board" ] || [ "${machine}" == "OMAP4 Panda board" ] |
132 |
|
then |
133 |
|
ubootAddress=0x80008000 |
134 |
|
else |
135 |
|
ubootAddress=0x00008000 |
136 |
|
fi |
137 |
|
else |
138 |
|
ubootAddress="${UBOOT_IMGADDR}" |
139 |
|
fi |
140 |
else |
else |
141 |
# this leaves i?86 and x86_64 |
# this leaves i?86 and x86_64 |
142 |
liloConfig=/etc/lilo.conf |
liloConfig=/etc/lilo.conf |
143 |
grubConfig=/boot/grub/grub.conf |
grubConfig=/boot/grub/grub.conf |
144 |
bootPrefix=/boot |
grub2Config=/boot/grub/grub.cfg |
145 |
liloFlag=lilo |
grub2EfiConfig=/boot/grub/grub-efi.cfg |
146 |
isx86="yes" |
extlinuxConfig=/boot/extlinux/extlinux.conf |
147 |
|
bootPrefix=/boot |
148 |
|
liloFlag=lilo |
149 |
|
isx86="yes" |
150 |
fi |
fi |
151 |
|
|
152 |
mode="" |
mode="" |
153 |
version="" |
version="" |
154 |
initrd="" |
initrd="" |
155 |
|
dracut="" |
156 |
|
dracuthostonly="" |
157 |
initrdfile="" |
initrdfile="" |
158 |
moddep="" |
moddep="" |
159 |
verbose="" |
verbose="" |
160 |
makedefault="" |
makedefault="" |
161 |
package="" |
package="" |
162 |
mbkernel="" |
mbkernel="${HYPERVISOR}" |
163 |
mbargs="" |
mbargs="${HYPERVISOR_ARGS}" |
164 |
|
adddracutargs="" |
165 |
usage() { |
addplymouthinitrd="" |
166 |
echo "Usage: `basename $0` [-v] [--mkinitrd] [--rminitrd]" >&2 |
|
167 |
echo " [--initrdfile=<initrd-image>] [--depmod] [--rmmoddep]" >&2 |
usage() |
168 |
echo " [--kernel-args=<args>] [--remove-args=<args>]" >&2 |
{ |
169 |
echo " [--banner=<banner>] [--multiboot=multiboot]" >&2 |
echo "Usage: $(basename $0) [-v] [--mkinitrd] [--rminitrd] [--dracut]" >&2 |
170 |
echo " [--mbargs=mbargs] [--make-default]" >&2 |
echo " [--initrdfile=<initrd-image>] [--depmod] [--rmmoddep]" >&2 |
171 |
echo " <--install | --remove | --update> <kernel-version>" >&2 |
echo " [--kernel-args=<args>] [--remove-args=<args>]" >&2 |
172 |
echo " (ex: `basename $0` --mkinitrd --depmod --install 2.4.7-2)" >&2 |
echo " [--banner=<banner>] [--multiboot=multiboot]" >&2 |
173 |
exit 1 |
echo " [--mbargs=mbargs] [--make-default] [--add-dracut-args]" >&2 |
174 |
|
echo " [--add-plymouth-initrd]" >&2 |
175 |
|
echo " [--host-only]" >&2 |
176 |
|
echo " <--install | --remove | --update> <kernel-version>" >&2 |
177 |
|
echo " (ex: $(basename $0) --mkinitrd --depmod --install 2.4.7-2)" >&2 |
178 |
|
exit 1 |
179 |
} |
} |
180 |
|
|
181 |
install() { |
install() |
182 |
# XXX kernel should be able to be specified also (or work right on ia64) |
{ |
183 |
if [ ! -f $bootPrefix/$kernelName-$version ] ; then |
# XXX kernel should be able to be specified also (or work right on ia64) |
184 |
[ -n "$verbose" ] && echo "kernel for $version does not exist, not running grubby" |
if [ ! -f ${bootPrefix}/${kernelName}-${version} ] |
185 |
return |
then |
186 |
fi |
[[ -n ${verbose} ]] && echo "kernel for ${version} does not exist, not running grubby" |
187 |
|
return |
188 |
INITRD="" |
fi |
189 |
if [ -f $initrdfile ]; then |
|
190 |
[ -n "$verbose" ] && echo "found $initrdfile and using it with grubby" |
INITRD="" |
191 |
INITRD="--initrd $initrdfile" |
if [ -f ${initrdfile} ] |
192 |
fi |
then |
193 |
|
[[ -n ${verbose} ]] && echo "found ${initrdfile} and using it with grubby" |
194 |
# FIXME: is this a good heuristic to find out if we're on iSeries? |
INITRD="--initrd ${initrdfile}" |
195 |
if [ -d /proc/iSeries ]; then |
|
196 |
[ -n "$verbose" ] && echo "On an iSeries, just making img file" |
if [[ -n ${addplymouthinitrd} ]] |
197 |
if [ -z $initrdfile ]; then |
then |
198 |
[ -n "$verbose" ] && echo "No initrd, just adding system map" |
INITRD="${INITRD} --extra-initrd ${bootPrefix}/initrd-plymouth.img" |
199 |
/sbin/addSystemMap $bootPrefix/System.map-$version $bootPrefix/$kernelName-$version $bootPrefix/vmlinitrd-$version |
fi |
200 |
else |
fi |
201 |
/sbin/addSystemMap $bootPrefix/System.map-$version $bootPrefix/$kernelName-$version $bootPrefix/vmlinux.sm-$version |
|
202 |
/sbin/addRamDisk $initrdfile $bootPrefix/System.map-$version $bootPrefix/vmlinux.sm-$version $bootPrefix/vmlinitrd-$version 2>/dev/null |
# FIXME: is this a good heuristic to find out if we're on iSeries? |
203 |
rm $bootPrefix/vmlinux.sm-$version |
if [ -d /proc/iSeries ] |
204 |
fi |
then |
205 |
return |
[[ -n ${verbose} ]] && echo "On an iSeries, just making img file" |
206 |
fi |
if [[ -z ${initrdfile} ]] |
207 |
|
then |
208 |
# get the root filesystem to use |
[[ -n ${verbose} ]] && echo "No initrd, just adding system map" |
209 |
rootdevice=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $1; }}' /etc/fstab) |
/sbin/addSystemMap ${bootPrefix}/System.map-${version} ${bootPrefix}/${kernelName}-${version} ${bootPrefix}/vmlinitrd-${version} |
210 |
|
else |
211 |
if [ -n "$mbkernel" -a -n "$cfgLilo" -a "$liloFlag" != "elilo" ]; then |
/sbin/addSystemMap ${bootPrefix}/System.map-${version} ${bootPrefix}/${kernelName}-${version} ${bootPrefix}/vmlinux.sm-${version} |
212 |
[ -n "$verbose" ] && echo "multiboot specified, not updating lilo.conf" |
/sbin/addRamDisk ${initrdfile} ${bootPrefix}/System.map-${version} ${bootPrefix}/vmlinux.sm-${version} ${bootPrefix}/vmlinitrd-${version} 2>/dev/null |
213 |
cfgLilo="" |
rm ${bootPrefix}/vmlinux.sm-${version} |
214 |
fi |
fi |
215 |
|
return |
216 |
if [ -n "$cfgGrub" ]; then |
fi |
217 |
[ -n "$verbose" ] && echo "adding $version to $grubConfig" |
|
218 |
|
# get the root filesystem to use |
219 |
if [ -n "$banner" ]; then |
rootdevice=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $1; }}' /etc/fstab) |
220 |
title="$banner ($version)" |
|
221 |
elif [ -f /etc/mageversion ]; then |
if [[ -n ${mbkernel} ]] && [[ -n ${cfgLilo} ]] && [[ ${liloFlag} != elilo ]] |
222 |
title="Magellan Linux $(< /etc/mageversion) ($version)" |
then |
223 |
else |
[[ -n ${verbose} ]] && echo "multiboot specified, not updating lilo.conf" |
224 |
title="Magellan Linux ($version)" |
cfgLilo="" |
225 |
fi |
fi |
226 |
$grubby --add-kernel=$bootPrefix/$kernelName-$version \ |
|
227 |
$INITRD --copy-default $makedefault --title "$title" \ |
if [[ -n ${cfgGrub} ]] |
228 |
${mbkernel:+--add-multiboot="$mbkernel"} ${mbargs:+--mbargs="$mbargs"} \ |
then |
229 |
--args="root=$rootdevice $kernargs" --remove-kernel="TITLE=$title" |
[[ -n ${verbose} ]] && echo "adding ${version} to ${grubConfig}" |
230 |
else |
|
231 |
[ -n "$verbose" ] && echo "$grubConfig does not exist, not running grubby" |
if [[ -n ${banner} ]] |
232 |
fi |
then |
233 |
|
title="${banner} [ ${version} ]" |
234 |
if [ -n "$cfgLilo" ]; then |
elif [ -f /etc/mageversion ] |
235 |
[ -n "$verbose" ] && echo "adding $version to $liloConfig" |
then |
236 |
|
title="Magellan Linux $(< /etc/mageversion) [ ${version} ]" |
237 |
$grubby --add-kernel=$bootPrefix/$kernelName-$version $INITRD \ |
elif [[ $(read_os_release id) = magellan ]] |
238 |
--copy-default $makedefault --title $version \ |
then |
239 |
${mbkernel:+--add-multiboot="$mbkernel"} ${mbargs:+--mbargs="$mbargs"} \ |
title="$(read_os_release name) $(read_os_release version_id) [ ${version} ]" |
240 |
--args="root=$rootdevice $kernargs" --remove-kernel="TITLE=$version" \ |
else |
241 |
--$liloFlag |
title="Magellan Linux [ ${version} ]" |
242 |
|
fi |
243 |
if [ -n "$runLilo" ]; then |
${grubby} --grub -c ${grubConfig} \ |
244 |
[ -n "$verbose" ] && echo "running $lilo" |
--add-kernel=${bootPrefix}/${kernelName}-${version} \ |
245 |
if [ ! -x $lilo ] ; then |
${INITRD} --copy-default ${makedefault} --title "${title}" \ |
246 |
[ -n "$verbose" ] && echo "$lilo does not exist" |
${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \ |
247 |
else |
--args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}" |
248 |
$lilo > /dev/null |
else |
249 |
fi |
[[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby for grub 0.97" |
250 |
fi |
fi |
251 |
else |
if [[ -n ${cfgGrub2} ]] |
252 |
[ -n "$verbose" ] && echo "$liloConfig does not exist, not running grubby" |
then |
253 |
fi |
[[ -n ${verbose} ]] && echo "adding ${version} to ${grub2Config}" |
254 |
|
|
255 |
|
if [[ -n ${banner} ]] |
256 |
|
then |
257 |
|
title="${banner} [ ${version} ]" |
258 |
|
elif [ -f /etc/mageversion ] |
259 |
|
then |
260 |
|
title="Magellan Linux $(< /etc/mageversion) [ ${version} ]" |
261 |
|
elif [[ $(read_os_release id) = magellan ]] |
262 |
|
then |
263 |
|
title="$(read_os_release name) $(read_os_release version_id) [ ${version} ]" |
264 |
|
else |
265 |
|
title="Magellan Linux [ ${version} ]" |
266 |
|
fi |
267 |
|
${grubby} --grub2 -c ${grub2Config} \ |
268 |
|
--add-kernel=${bootPrefix}/${kernelName}-${version} \ |
269 |
|
${INITRD} --copy-default ${makedefault} --title "${title}" \ |
270 |
|
${mbkernel:+--add-multiboot="${mbkernel}"} \ |
271 |
|
${mbargs:+--mbargs="${mbargs}"} \ |
272 |
|
--args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}" |
273 |
|
else |
274 |
|
[[ -n ${verbose} ]] && echo "${grub2Config} does not exist, not running grubby for grub 2" |
275 |
|
fi |
276 |
|
if [[ -n ${cfgGrub2Efi} ]] |
277 |
|
then |
278 |
|
[[ -n ${verbose} ]] && echo "adding ${version} to ${grub2EfiConfig}" |
279 |
|
|
280 |
|
if [[ -n ${banner} ]] |
281 |
|
then |
282 |
|
title="${banner} [ ${version} ]" |
283 |
|
elif [ -f /etc/mageversion ] |
284 |
|
then |
285 |
|
title="Magellan Linux $(< /etc/mageversion) [ ${version} ]" |
286 |
|
elif [[ $(read_os_release id) = magellan ]] |
287 |
|
then |
288 |
|
title="$(read_os_release name) $(read_os_release version_id) [ ${version} ]" |
289 |
|
else |
290 |
|
title="Magellan Linux [ ${version} ]" |
291 |
|
fi |
292 |
|
${grubby} --grub2 -c ${grub2EfiConfig} \ |
293 |
|
--add-kernel=${bootPrefix}/${kernelName}-${version} \ |
294 |
|
${INITRD} --copy-default ${makedefault} --title "${title}" \ |
295 |
|
${mbkernel:+--add-multiboot="${mbkernel}"} \ |
296 |
|
${mbargs:+--mbargs="${mbargs}"} \ |
297 |
|
--args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}" |
298 |
|
else |
299 |
|
[[ -n ${verbose} ]] && echo "${grub2EfiConfig} does not exist, not running grubby for grub 2 with UEFI" |
300 |
|
fi |
301 |
|
|
302 |
|
if [[ -n ${cfgLilo} ]] |
303 |
|
then |
304 |
|
[[ -n ${verbose} ]] && echo "adding ${version} to ${liloConfig}" |
305 |
|
|
306 |
|
${grubby} --add-kernel=${bootPrefix}/${kernelName}-${version} ${INITRD} \ |
307 |
|
--copy-default ${makedefault} --title ${version} \ |
308 |
|
${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \ |
309 |
|
--args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${version}" \ |
310 |
|
--${liloFlag} |
311 |
|
|
312 |
|
if [[ -n ${runLilo} ]] |
313 |
|
then |
314 |
|
[[ -n ${verbose} ]] && echo "running ${lilo}" |
315 |
|
if [ ! -x ${lilo} ] |
316 |
|
then |
317 |
|
[[ -n ${verbose} ]] && echo "${lilo} does not exist" |
318 |
|
else |
319 |
|
${lilo} > /dev/null |
320 |
|
fi |
321 |
|
fi |
322 |
|
else |
323 |
|
[[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby" |
324 |
|
fi |
325 |
|
|
326 |
|
if [[ -n ${cfgExtlinux} ]] |
327 |
|
then |
328 |
|
[[ -n ${verbose} ]] && echo "adding ${version} to ${extlinuxConfig}" |
329 |
|
|
330 |
|
if [[ -n ${banner} ]] |
331 |
|
then |
332 |
|
title="${banner} [ ${version} ]" |
333 |
|
elif [ -f /etc/mageversion ] |
334 |
|
then |
335 |
|
title="Magellan Linux $(< /etc/mageversion) [ ${version} ]" |
336 |
|
elif [[ $(read_os_release id) = magellan ]] |
337 |
|
then |
338 |
|
title="$(read_os_release name) $(read_os_release version_id) [ ${version} ]" |
339 |
|
else |
340 |
|
title="Magellan Linux [ ${version} ]" |
341 |
|
fi |
342 |
|
${grubby} --extlinux -c ${extlinuxConfig} \ |
343 |
|
--add-kernel=${bootPrefix}/${kernelName}-${version} \ |
344 |
|
${INITRD} --copy-default ${makedefault} --title "${title}" \ |
345 |
|
${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \ |
346 |
|
--args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}" |
347 |
|
else |
348 |
|
[[ -n ${verbose} ]] && echo "${extlinuxConfig} does not exist, not running grubby for extlinux" |
349 |
|
fi |
350 |
} |
} |
351 |
|
|
352 |
remove() { |
remove() |
353 |
# FIXME: is this a good heuristic to find out if we're on iSeries? |
{ |
354 |
if [ -d /proc/iSeries ]; then |
# FIXME: is this a good heuristic to find out if we're on iSeries? |
355 |
[ -n "$verbose" ] && echo "On an iSeries, remove img file" |
if [ -d /proc/iSeries ] |
356 |
rm -f $bootPrefix/$kernelName-$version.img 2>/dev/null |
then |
357 |
return |
[[ -n ${verbose} ]] && echo "On an iSeries, remove img file" |
358 |
fi |
rm -f ${bootPrefix}/${kernelName}-${version}.img 2>/dev/null |
359 |
|
return |
360 |
if [ -n "$cfgGrub" ]; then |
fi |
361 |
[ -n "$verbose" ] && echo "removing $version from $grubConfig" |
|
362 |
$grubby --remove-kernel=$bootPrefix/$kernelName-$version |
if [[ -n ${cfgGrub} ]] |
363 |
else |
then |
364 |
[ -n "$verbose" ] && echo "$grubConfig does not exist, not running grubby" |
[[ -n ${verbose} ]] && echo "removing ${version} from ${grubConfig}" |
365 |
fi |
${grubby} --grub -c ${grubConfig} \ |
366 |
|
--remove-kernel=${bootPrefix}/${kernelName}-${version} |
367 |
if [ -n "$cfgLilo" ]; then |
else |
368 |
[ -n "$verbose" ] && echo "removing $version from $liloConfig" |
[[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby for grub 0.97" |
369 |
$grubby --remove-kernel=$bootPrefix/$kernelName-$version \ |
fi |
370 |
--$liloFlag |
if [[ -n ${cfgGrub2} ]] |
371 |
|
then |
372 |
if [ -n "$runLilo" ]; then |
[[ -n ${verbose} ]] && echo "removing ${version} from ${grub2Config}" |
373 |
[ -n "$verbose" ] && echo "running $lilo" |
${grubby} --grub2 -c ${grub2Config} \ |
374 |
if [ ! -x $lilo ] ; then |
--remove-kernel=${bootPrefix}/${kernelName}-${version} |
375 |
[ -n "$verbose" ] && echo "$lilo does not exist" |
else |
376 |
else |
[[ -n ${verbose} ]] && echo "${grub2Config} does not exist, not running grubby for grub 2" |
377 |
$lilo > /dev/null |
fi |
378 |
fi |
if [[ -n ${cfgGrub2Efi} ]] |
379 |
fi |
then |
380 |
else |
[[ -n ${verbose} ]] && echo "removing ${version} from ${grub2EfiConfig}" |
381 |
[ -n "$verbose" ] && echo "$liloConfig does not exist, not running grubby" |
${grubby} --grub2 -c ${grub2EfiConfig} \ |
382 |
fi |
--remove-kernel=${bootPrefix}/${kernelName}-${version} |
383 |
|
else |
384 |
|
[[ -n ${verbose} ]] && echo "${grub2EfiConfig} does not exist, not running grubby grub 2 with UEFI" |
385 |
|
fi |
386 |
|
|
387 |
|
if [[ -n ${cfgLilo} ]] |
388 |
|
then |
389 |
|
[[ -n ${verbose} ]] && echo "removing ${version} from ${liloConfig}" |
390 |
|
${grubby} --remove-kernel=${bootPrefix}/${kernelName}-${version} --${liloFlag} |
391 |
|
|
392 |
|
if [[ -n ${runLilo} ]] |
393 |
|
then |
394 |
|
[[ -n ${verbose} ]] && echo "running ${lilo}" |
395 |
|
if [ ! -x ${lilo} ] |
396 |
|
then |
397 |
|
[[ -n ${verbose} ]] && echo "${lilo} does not exist" |
398 |
|
else |
399 |
|
${lilo} > /dev/null |
400 |
|
fi |
401 |
|
fi |
402 |
|
else |
403 |
|
[[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby" |
404 |
|
fi |
405 |
|
|
406 |
|
if [[ -n ${cfguBoot} ]] |
407 |
|
then |
408 |
|
[[ -n ${verbose} ]] && echo "removing ${version} from ${ubootDir}..." |
409 |
|
|
410 |
|
if [ -f ${ubootDir}/${ubootKList} ] |
411 |
|
then |
412 |
|
tmpKList=$(mktemp ${ubootDir}/${ubootKList}.XXXX) |
413 |
|
curversion=$(tail -n1 ${ubootDir}/${ubootKList}) |
414 |
|
sed "/${version}/d" ${ubootDir}/${ubootKList} > ${tmpKList} |
415 |
|
newversion=$(tail -n1 ${tmpKList}) |
416 |
|
if [ -f ${ubootDir}/uImage-${newversion} ] && [ -f ${ubootDir}/uInitrd-${newversion} ] |
417 |
|
then |
418 |
|
if [[ ${curversion} != ${newversion} ]] |
419 |
|
then |
420 |
|
cp -fp ${ubootDir}/uImage-${newversion} ${ubootDir}/${ubootDefaultImage} |
421 |
|
if [ $? -ne 0 ] |
422 |
|
then |
423 |
|
[[ -n ${verbose} ]] && echo "copy uImage-${newversion} error, default kernel not replaced!" && exit |
424 |
|
fi |
425 |
|
cp -fp ${ubootDir}/uInitrd-${newversion} ${ubootDir}/${ubootDefaultInitrd} |
426 |
|
if [ $? -ne 0 ] |
427 |
|
then |
428 |
|
[[ -n ${verbose} ]] && echo "copy uInitrd-${newversion} error, default Initrd not replaced!" && exit |
429 |
|
fi |
430 |
|
fi |
431 |
|
|
432 |
|
[[ -n ${verbose} ]] && echo "removing uImage-${version}" |
433 |
|
if [ -f ${ubootDir}/uImage-${version} ] |
434 |
|
then |
435 |
|
rm -f ${ubootDir}/uImage-${version} |
436 |
|
else |
437 |
|
[[ -n ${verbose} ]] && echo "uImage-${version} did not exist!" |
438 |
|
fi |
439 |
|
|
440 |
|
[[ -n ${verbose} ]] && echo "removing uInitrd-${version}" |
441 |
|
if [ -f ${ubootDir}/uInitrd-${version} ] |
442 |
|
then |
443 |
|
rm -f ${ubootDir}/uInitrd-${version} |
444 |
|
else |
445 |
|
[[ -n ${verbose} ]] && echo "uInitrd-${version} did not exist!" |
446 |
|
fi |
447 |
|
|
448 |
|
mv ${tmpKList} ${ubootDir}/${ubootKList} |
449 |
|
else |
450 |
|
[[ -n ${verbose} ]] && echo "uImage ${newversion} does not exist!" |
451 |
|
[ -f ${tmpKList} ] && rm -f ${tmpKList} |
452 |
|
fi |
453 |
|
else |
454 |
|
[[ -n ${verbose} ]] && echo "No previous kernel version. U-Boot images not removed!" |
455 |
|
fi |
456 |
|
else |
457 |
|
[[ -n ${verbose} ]] && echo "${ubootScript} does not exist, not modifying ${ubootDir}" |
458 |
|
fi |
459 |
|
|
460 |
|
if [[ -n ${cfgExtlinux} ]] |
461 |
|
then |
462 |
|
[[ -n ${verbose} ]] && echo "removing ${version} from ${extlinuxConfig}" |
463 |
|
${grubby} --extlinux -c ${extlinuxConfig} \ |
464 |
|
--remove-kernel=${bootPrefix}/${kernelName}-${version} |
465 |
|
else |
466 |
|
[[ -n ${verbose} ]] && echo "${extlinuxConfig} does not exist, not running grubby for extlinux" |
467 |
|
fi |
468 |
} |
} |
469 |
|
|
470 |
update() { |
update() |
471 |
if [ -n "$cfgGrub" ]; then |
{ |
472 |
[ -n "$verbose" ] && echo "updating $version from $grubConfig" |
if [ ! -f ${bootPrefix}/${kernelName}-${version} ] |
473 |
$grubby --update-kernel=$bootPrefix/$kernelName-$version \ |
then |
474 |
${kernargs:+--args="$kernargs"} \ |
[[ -n ${verbose} ]] && echo "kernel for ${version} does not exist, not running grubby" |
475 |
${removeargs:+--remove-args="$removeargs"} |
return |
476 |
else |
fi |
477 |
[ -n "$verbose" ] && echo "$grubConfig does not exist, not running grubby" |
|
478 |
fi |
INITRD="" |
479 |
|
if [ -f ${initrdfile} ] |
480 |
if [ -n "$cfgLilo" ]; then |
then |
481 |
[ -n "$verbose" ] && echo "updating $version from $liloConfig" |
[[ -n ${verbose} ]] && echo "found ${initrdfile} and using it with grubby" |
482 |
$grubby --update-kernel=$bootPrefix/$kernelName-$version \ |
INITRD="--initrd ${initrdfile}" |
483 |
${kernargs:+--args="$kernargs"} \ |
|
484 |
${removeargs:+--remove-args="$removeargs"} \ |
if [[ -n ${addplymouthinitrd} ]] |
485 |
--$liloFlag |
then |
486 |
|
INITRD="${INITRD} --extra-initrd ${bootPrefix}/initrd-plymouth.img" |
487 |
if [ -n "$runLilo" ]; then |
fi |
488 |
[ -n "$verbose" ] && echo "running $lilo" |
fi |
489 |
if [ ! -x $lilo ] ; then |
|
490 |
[ -n "$verbose" ] && echo "$lilo does not exist" |
if [[ -n ${cfgGrub} ]] |
491 |
else |
then |
492 |
$lilo > /dev/null |
[[ -n ${verbose} ]] && echo "updating ${version} from ${grubConfig}" |
493 |
fi |
${grubby} --grub -c ${grubConfig} \ |
494 |
fi |
--update-kernel=${bootPrefix}/${kernelName}-${version} \ |
495 |
else |
${INITRD} \ |
496 |
[ -n "$verbose" ] && echo "$liloConfig does not exist, not running grubby" |
${kernargs:+--args="${kernargs}"} \ |
497 |
fi |
${removeargs:+--remove-args="${removeargs}"} |
498 |
|
else |
499 |
|
[[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby" |
500 |
|
fi |
501 |
|
|
502 |
|
if [[ -n ${cfgGrub2} ]] |
503 |
|
then |
504 |
|
[[ -n ${verbose} ]] && echo "updating ${version} from ${grub2Config}" |
505 |
|
${grubby} --grub2 -c ${grub2Config} \ |
506 |
|
--update-kernel=${bootPrefix}/${kernelName}-${version} \ |
507 |
|
${INITRD} \ |
508 |
|
${kernargs:+--args="${kernargs}"} \ |
509 |
|
${removeargs:+--remove-args="${removeargs}"} |
510 |
|
else |
511 |
|
[[ -n ${verbose} ]] && echo "${grub2Config} does not exist, not running grubby" |
512 |
|
fi |
513 |
|
|
514 |
|
if [[ -n ${cfgGrub2Efi} ]] |
515 |
|
then |
516 |
|
[[ -n ${verbose} ]] && echo "updating ${version} from ${grub2EfiConfig}" |
517 |
|
${grubby} --grub2 -c ${grub2EfiConfig} \ |
518 |
|
--update-kernel=${bootPrefix}/${kernelName}-${version} \ |
519 |
|
${INITRD} \ |
520 |
|
${kernargs:+--args="${kernargs}"} \ |
521 |
|
${removeargs:+--remove-args="${removeargs}"} |
522 |
|
else |
523 |
|
[[ -n ${verbose} ]] && echo "${grub2EfiConfig} does not exist, not running grubby" |
524 |
|
fi |
525 |
|
|
526 |
|
if [[ -n ${cfgLilo} ]] |
527 |
|
then |
528 |
|
[[ -n ${verbose} ]] && echo "updating ${version} from ${liloConfig}" |
529 |
|
${grubby} --update-kernel=${bootPrefix}/${kernelName}-${version} \ |
530 |
|
${INITRD} \ |
531 |
|
${kernargs:+--args="${kernargs}"} \ |
532 |
|
${removeargs:+--remove-args="${removeargs}"} \ |
533 |
|
--${liloFlag} |
534 |
|
|
535 |
|
if [[ -n ${runLilo} ]] |
536 |
|
then |
537 |
|
[[ -n ${verbose} ]] && echo "running ${lilo}" |
538 |
|
if [ ! -x ${lilo} ] |
539 |
|
then |
540 |
|
[[ -n ${verbose} ]] && echo "${lilo} does not exist" |
541 |
|
else |
542 |
|
${lilo} > /dev/null |
543 |
|
fi |
544 |
|
fi |
545 |
|
else |
546 |
|
[[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby" |
547 |
|
fi |
548 |
|
|
549 |
|
if [[ -n ${cfguBoot} ]] |
550 |
|
then |
551 |
|
[[ -n ${verbose} ]] && echo "adding $version to ${ubootDir}..." |
552 |
|
|
553 |
|
[[ -n ${verbose} ]] && echo "creating uImage-${version}" |
554 |
|
mkimage -A arm -O linux -T kernel -C none -a ${ubootAddress} \ |
555 |
|
-e ${ubootAddress} -n ${version} \ |
556 |
|
-d ${bootPrefix}/${kernelName}-${version} ${ubootDir}/uImage-${version} |
557 |
|
|
558 |
|
[[ -n ${verbose} ]] && echo "creating uInitrd-${version}" |
559 |
|
mkimage -A arm -O linux -T ramdisk -C none -a 0 -e 0 \ |
560 |
|
-n initramfs -d ${initrdfile} ${ubootDir}/uInitrd-${version} |
561 |
|
|
562 |
|
if [ -f ${ubootDir}/uImage-${version} ] && [ -f ${ubootDir}/uInitrd-${version} ] |
563 |
|
then |
564 |
|
cp -fp ${ubootDir}/uImage-${version} ${ubootDir}/${ubootDefaultImage} |
565 |
|
if [ $? -ne 0 ] |
566 |
|
then |
567 |
|
[[ -n ${verbose} ]] && echo "copy uImage-${version} error, kernel not installed!" && exit |
568 |
|
fi |
569 |
|
cp -fp ${ubootDir}/uInitrd-${version} ${ubootDir}/${ubootDefaultInitrd} |
570 |
|
if [ $? -ne 0 ] |
571 |
|
then |
572 |
|
[[ -n ${verbose} ]] && echo "copy uInitrd-${version} error, kernel not installed!" && exit |
573 |
|
fi |
574 |
|
echo ${version} >> ${ubootDir}/${ubootKList} |
575 |
|
else |
576 |
|
[[ -n ${verbose} ]] && echo "cannot make ${version} the default" |
577 |
|
fi |
578 |
|
else |
579 |
|
[[ -n ${verbose} ]] && echo "${ubootScript} does not exist, not setting up ${ubootDir}" |
580 |
|
fi |
581 |
|
|
582 |
|
if [[ -n ${cfgExtlinux} ]] |
583 |
|
then |
584 |
|
[[ -n ${verbose} ]] && echo "updating ${version} from ${extlinuxConfig}" |
585 |
|
${grubby} --extlinux -c ${extlinuxConfig} \ |
586 |
|
--update-kernel=${bootPrefix}/${kernelName}-${version} \ |
587 |
|
${INITRD} \ |
588 |
|
${kernargs:+--args="${kernargs}"} \ |
589 |
|
${removeargs:+--remove-args="${removeargs}"} |
590 |
|
else |
591 |
|
[[ -n ${verbose} ]] && echo "${extlinuxConfig} does not exist, not running grubby" |
592 |
|
fi |
593 |
} |
} |
594 |
|
|
595 |
mkinitrd() { |
makeinitrd() |
596 |
[ -n "$verbose" ] && echo "creating initrd $initrdfile using $version" |
{ |
597 |
/sbin/mkinitrd --allow-missing -f $initrdfile $version |
if [[ -n ${dracut} ]] |
598 |
rc=$? |
then |
599 |
if [ $rc != 0 ]; then |
tool="dracut ${dracuthostonly} -f ${initrdfile} ${version}" |
600 |
echo "mkinitrd failed" >&2 |
else |
601 |
exit 1 |
tool="mkinitrd --allow-missing -f ${initrdfile} ${version}" |
602 |
fi |
fi |
603 |
|
[[ -n ${verbose} ]] && echo "creating initrd ${initrdfile} using ${version}" |
604 |
|
${tool} |
605 |
|
rc=$? |
606 |
|
if [ ${rc} != 0 ] |
607 |
|
then |
608 |
|
echo "mkinitrd failed" >&2 |
609 |
|
exit 1 |
610 |
|
fi |
611 |
} |
} |
612 |
|
|
613 |
rminitrd() { |
rminitrd() |
614 |
[ -n "$verbose" ] && echo "removing initrd $initrdfile" |
{ |
615 |
[ -f $initrdfile ] && rm -f $initrdfile |
[[ -n ${verbose} ]] && echo "removing initrd ${initrdfile}" |
616 |
|
[ -f ${initrdfile} ] && rm -f ${initrdfile} |
617 |
} |
} |
618 |
|
|
619 |
doDepmod() { |
doDepmod() |
620 |
[ -n "$verbose" ] && echo "running depmod for $version" |
{ |
621 |
depmod -ae -F /boot/System.map-$version $version |
[[ -n ${verbose} ]] && echo "running depmod for ${version}" |
622 |
|
depmod -ae -F /boot/System.map-${version} ${version} |
623 |
} |
} |
624 |
|
|
625 |
doRmmoddep() { |
doRmmoddep() |
626 |
[ -n "$verbose" ] && echo "removing modules.dep info for $version" |
{ |
627 |
[ -d /lib/modules/$version ] && rm -f /lib/modules/$version/modules.* |
[[ -n ${verbose} ]] && echo "removing modules.dep info for ${version}" |
628 |
|
[ -d /lib/modules/${version} ] && rm -f /lib/modules/${version}/modules.* |
629 |
} |
} |
630 |
|
|
631 |
|
|
632 |
while [ $# -gt 0 ]; do |
while [ $# -gt 0 ] |
633 |
case $1 in |
do |
634 |
--mkinitrd) |
case $1 in |
635 |
initrd="make" |
--mkinitrd) |
636 |
;; |
initrd="make" |
637 |
|
;; |
638 |
--rminitrd) |
|
639 |
initrd="remove" |
--rminitrd) |
640 |
;; |
initrd="remove" |
641 |
|
;; |
642 |
--initrdfile*) |
|
643 |
if echo $1 | grep '=' >/dev/null ; then |
--dracut) |
644 |
initrdfile=`echo $1 | sed 's/^--initrdfile=//'` |
dracut=--dracut |
645 |
else |
;; |
646 |
initrdfile=$2 |
|
647 |
shift |
--host-only) |
648 |
fi |
dracuthostonly=-H |
649 |
;; |
;; |
650 |
|
|
651 |
--kernel-args*) |
--initrdfile*) |
652 |
if echo $1 | grep '=' >/dev/null ; then |
if echo $1 | grep '=' >/dev/null |
653 |
kernargs=`echo $1 | sed 's/^--kernel-args=//'` |
then |
654 |
else |
initrdfile=$(echo $1 | sed 's/^--initrdfile=//') |
655 |
kernargs=$2 |
else |
656 |
shift |
initrdfile=$2 |
657 |
fi |
shift |
658 |
;; |
fi |
659 |
|
;; |
660 |
--remove-args*) |
|
661 |
if echo $1 | grep '=' >/dev/null ; then |
--kernel-args*) |
662 |
removeargs=`echo $1 | sed 's/^--remove-args=//'` |
if echo $1 | grep '=' >/dev/null |
663 |
else |
then |
664 |
removeargs=$2 |
kernargs=$(echo $1 | sed 's/^--kernel-args=//') |
665 |
shift |
else |
666 |
fi |
kernargs=$2 |
667 |
;; |
shift |
668 |
|
fi |
669 |
--banner*) |
;; |
670 |
if echo $1 | grep '=' >/dev/null ; then |
|
671 |
banner=`echo $1 | sed 's/^--banner=//'` |
--remove-args*) |
672 |
else |
if echo $1 | grep '=' >/dev/null |
673 |
banner=$2 |
then |
674 |
shift |
removeargs=$(echo $1 | sed 's/^--remove-args=//') |
675 |
fi |
else |
676 |
;; |
removeargs=$2 |
677 |
|
shift |
678 |
--multiboot*) |
fi |
679 |
if echo $1 |grep '=' >/dev/null; then |
;; |
680 |
mbkernel=`echo $1 | sed 's/^--multiboot=//'` |
|
681 |
else |
--banner*) |
682 |
# can't really support having an optional second arg here |
if echo $1 | grep '=' >/dev/null |
683 |
# sorry! |
then |
684 |
mbkernel="/boot/xen.gz" |
banner=$(echo $1 | sed 's/^--banner=//') |
685 |
fi |
else |
686 |
;; |
banner=$2 |
687 |
|
shift |
688 |
--mbargs*) |
fi |
689 |
if echo $1 |grep '=' >/dev/null; then |
;; |
690 |
mbargs=`echo $1 | sed 's/^--mbargs=//'` |
|
691 |
else |
--multiboot*) |
692 |
mbargs="$2" |
if echo $1 |grep '=' >/dev/null |
693 |
shift |
then |
694 |
fi |
mbkernel=$(echo $1 | sed 's/^--multiboot=//') |
695 |
;; |
else |
696 |
|
# can't really support having an optional second arg here |
697 |
--depmod) |
# sorry! |
698 |
moddep="make" |
mbkernel="/boot/xen.gz" |
699 |
;; |
fi |
700 |
|
;; |
701 |
--rmmoddep) |
|
702 |
moddep="remove" |
--mbargs*) |
703 |
;; |
if echo $1 |grep '=' >/dev/null |
704 |
|
then |
705 |
--make-default) |
mbargs=$(echo $1 | sed 's/^--mbargs=//') |
706 |
makedefault="--make-default" |
else |
707 |
;; |
mbargs="$2" |
708 |
|
shift |
709 |
--package) |
fi |
710 |
if echo $1 | grep '=' >/dev/null ; then |
;; |
711 |
package=`echo $1 | sed 's/^--package=//'` |
|
712 |
else |
--depmod) |
713 |
package=$2 |
moddep="make" |
714 |
shift |
;; |
715 |
fi |
|
716 |
;; |
--rmmoddep) |
717 |
|
moddep="remove" |
718 |
-v) |
;; |
719 |
verbose=-v |
|
720 |
;; |
--make-default) |
721 |
|
makedefault="--make-default" |
722 |
*) |
;; |
723 |
if [ -z "$mode" ]; then |
|
724 |
mode=$1 |
--package) |
725 |
elif [ -z "$version" ]; then |
if echo $1 | grep '=' >/dev/null |
726 |
version=$1 |
then |
727 |
else |
package=$(echo $1 | sed 's/^--package=//') |
728 |
usage |
else |
729 |
fi |
package=$2 |
730 |
;; |
shift |
731 |
esac |
fi |
732 |
|
;; |
733 |
|
|
734 |
|
--add-dracut-args) |
735 |
|
adddracutargs=--add-dracut-args |
736 |
|
;; |
737 |
|
|
738 |
|
--add-plymouth-initrd) |
739 |
|
addplymouthinitrd=--add-plymouth-initrd |
740 |
|
;; |
741 |
|
|
742 |
|
-v) |
743 |
|
verbose=-v |
744 |
|
;; |
745 |
|
|
746 |
|
*) |
747 |
|
if [[ -z ${mode} ]] |
748 |
|
then |
749 |
|
mode=$1 |
750 |
|
elif [[ -z ${version} ]] |
751 |
|
then |
752 |
|
version=$1 |
753 |
|
else |
754 |
|
usage |
755 |
|
fi |
756 |
|
;; |
757 |
|
esac |
758 |
|
|
759 |
shift |
shift |
760 |
done |
done |
761 |
|
|
762 |
# make sure the mode is valid |
# make sure the mode is valid |
763 |
if [ "$mode" != "--install" -a "$mode" != "--remove" -a "$mode" != "--update" ] ; then |
if [[ ${mode} != --install ]] && [[ ${mode} != --remove ]] && [[ ${mode} != --update ]] |
764 |
usage |
then |
765 |
|
usage |
766 |
fi |
fi |
767 |
|
|
768 |
if [ -z "$version" ]; then |
if [[ -z ${version} ]] |
769 |
usage |
then |
770 |
|
usage |
771 |
fi |
fi |
772 |
|
|
773 |
if [ "$mode" != "--install" -a "$makedefault" ]; then |
if [ "${mode}" != "--install" -a "${makedefault}" ] |
774 |
usage |
then |
775 |
|
usage |
776 |
fi |
fi |
777 |
|
|
778 |
kernelmajor=`echo $kernel | cut -d . -f 1,2` |
kernelmajor=$(echo ${kernel} | cut -d . -f 1,2) |
779 |
|
|
780 |
# kernel image for 2.4 is vmlinux |
# kernel image for 2.4 is kernel |
781 |
if [ $ARCH = 'ppc64' -o $ARCH = 'ppc' ]; then |
if [[ ${ARCH} = ppc64 ]] || [[ ${ARCH} = ppc ]] |
782 |
if [ "$kernelmajor" == "2.4" ]; then |
then |
783 |
kernelName=kernel |
if [[ ${kernelmajor} = 2.4 ]] |
784 |
fi |
then |
785 |
|
kernelName=kernel |
786 |
|
fi |
787 |
fi |
fi |
788 |
|
|
|
|
|
789 |
# set the initrd file based on arch; ia64 is the only currently known oddball |
# set the initrd file based on arch; ia64 is the only currently known oddball |
790 |
if [ -z "$initrdfile" ]; then |
if [[ -z ${initrdfile} ]] |
791 |
INITRD_NAME_PREFIX="initrd" |
then |
792 |
|
INITRD_NAME_PREFIX="initrd" |
793 |
if [ `uname -m` = "ia64" ]; then |
if [[ -n ${dracut} ]] |
794 |
initrdfile="/boot/efi/EFI/redhat/$INITRD_NAME_PREFIX-$version.img" |
then |
795 |
else |
INITRD_NAME_PREFIX="initramfs" |
796 |
initrdfile="/boot/$INITRD_NAME_PREFIX-$version.img" |
fi |
|
fi |
|
|
|
|
|
fi |
|
|
[ -n "$verbose" ] && echo "initrdfile is $initrdfile" |
|
797 |
|
|
798 |
# set this as the default if we have the package and it matches |
if [[ $(uname -m) = ia64 ]] |
799 |
if [ "$mode" == "--install" -a "$UPDATEDEFAULT" == "yes" -a -n "$package" -a -n "$DEFAULTKERNEL" -a "$package" == "$DEFAULTKERNEL" ]; then |
then |
800 |
makedefault="--make-default" |
initrdfile="/boot/efi/EFI/redhat/${INITRD_NAME_PREFIX}-${version}.img" |
801 |
[ -n "$verbose" ] && echo "making it the default based on config" |
else |
802 |
|
initrdfile="/boot/${INITRD_NAME_PREFIX}-${version}.img" |
803 |
|
fi |
804 |
fi |
fi |
805 |
|
[[ -n ${verbose} ]] && echo "initrdfile is ${initrdfile}" |
806 |
|
|
807 |
if [ "$moddep" == "make" ]; then |
# add dracut i18n, keyboard and plymouth kernel args if requested |
808 |
doDepmod |
if [[ -n ${dracut} ]] || [[ -n ${adddracutargs} ]] |
809 |
elif [ "$moddep" == "remove" ]; then |
then |
810 |
doRmmoddep |
[ -r /etc/conf.d/keymap ] && . /etc/conf.d/keymap |
811 |
fi |
[ -r /etc/conf.d/consolefont ] && . /etc/conf.d/consolefont |
812 |
|
|
813 |
|
if [[ -n ${KEYMAP} ]] |
814 |
|
then |
815 |
|
kernargs="${kernargs} KEYTABLE=${KEYMAP}" |
816 |
|
fi |
817 |
|
|
818 |
if [ "$initrd" == "make" ]; then |
if [[ -n ${CONSOLEFONT} ]] |
819 |
mkinitrd |
then |
820 |
elif [ "$initrd" == "remove" ]; then |
kernargs="${kernargs} SYSFONT=${CONSOLEFONT}" |
821 |
rminitrd |
fi |
822 |
fi |
fi |
823 |
|
|
824 |
if [ ! -x $grubby ] ; then |
# set this as the default if we have the package and it matches |
825 |
[ -n "$verbose" ] && echo "$grubby does not exist" |
if [[ ${mode} = --install ]] && [[ ${UPDATEDEFAULT} = yes ]] && [[ -n ${package} ]] && |
826 |
exit 0 |
[[ -n ${DEFAULTKERNEL} ]] && [[ ${package} = ${DEFAULTKERNEL} ]] |
827 |
|
then |
828 |
|
makedefault="--make-default" |
829 |
|
[[ -n ${verbose} ]] && echo "making it the default based on config" |
830 |
|
fi |
831 |
|
|
832 |
|
if [[ ${moddep} = make ]] |
833 |
|
then |
834 |
|
doDepmod |
835 |
|
elif [[ ${moddep} = remove ]] |
836 |
|
then |
837 |
|
doRmmoddep |
838 |
|
fi |
839 |
|
|
840 |
|
if [[ ${initrd} = make ]] |
841 |
|
then |
842 |
|
makeinitrd |
843 |
|
elif [[ ${initrd} = remove ]] |
844 |
|
then |
845 |
|
rminitrd |
846 |
|
fi |
847 |
|
|
848 |
|
if [ ! -x ${grubby} ] |
849 |
|
then |
850 |
|
[[ -n ${verbose} ]] && echo "${grubby} does not exist" |
851 |
|
exit 0 |
852 |
|
fi |
853 |
|
|
854 |
|
[[ -n ${grubConfig} ]] && [ -f ${grubConfig} ] && cfgGrub=1 |
855 |
|
[[ -n ${grub2Config} ]] && [ -f ${grub2Config} ] && cfgGrub2=1 |
856 |
|
[[ -n ${grub2EfiConfig} ]] && [ -f ${grub2EfiConfig} ] && cfgGrub2Efi=1 |
857 |
|
[[ -n ${liloConfig} ]] && [ -f ${liloConfig} ] && cfgLilo=1 |
858 |
|
[[ -n ${extlinuxConfig} ]] && [ -f ${extlinuxConfig} ] && cfgExtlinux=1 |
859 |
|
|
860 |
|
# if we have a U-Boot directory, but no boot script, check if the directory |
861 |
|
# is mounted. If not, mount it, and then check if a boot script exists. |
862 |
|
if [[ -n ${ubootDir} ]] |
863 |
|
then |
864 |
|
if [ -f ${ubootScript} ] |
865 |
|
then |
866 |
|
cfguBoot=1 |
867 |
|
else |
868 |
|
mountEntry=$(mount | grep ${ubootDir}) |
869 |
|
if [[ -z ${mountEntry} ]] |
870 |
|
then |
871 |
|
mount ${ubootDevice} ${ubootDir} |
872 |
|
mounted=1 |
873 |
|
fi |
874 |
|
[ -f ${ubootScript} ] && cfguBoot=1 |
875 |
|
fi |
876 |
fi |
fi |
877 |
|
|
|
[ -n "$grubConfig" ] && [ -f "$grubConfig" ] && cfgGrub=1; |
|
|
[ -n "$liloConfig" ] && [ -f "$liloConfig" ] && cfgLilo=1; |
|
|
|
|
878 |
# if we have a lilo config on an x86 box, see if the default boot loader |
# if we have a lilo config on an x86 box, see if the default boot loader |
879 |
# is lilo to determine if it should be run |
# is lilo to determine if it should be run |
880 |
if [ -n "$cfgLilo" -a -n "$isx86" ]; then |
if [[ -n ${cfgLilo} ]] && [[ -n ${isx86} ]] |
881 |
runLilo=$($grubby --bootloader-probe | grep lilo) |
then |
882 |
|
runLilo=$(${grubby} --bootloader-probe | grep lilo) |
883 |
|
fi |
884 |
|
|
885 |
|
if [[ ${mode} = --install ]] |
886 |
|
then |
887 |
|
install |
888 |
|
elif [[ ${mode} = --remove ]] |
889 |
|
then |
890 |
|
remove |
891 |
|
elif [[ ${mode} = --update ]] |
892 |
|
then |
893 |
|
update |
894 |
fi |
fi |
895 |
|
|
896 |
if [ "$mode" == "--install" ]; then |
# if we mounted the U-Boot directory, unmount it. |
897 |
install |
[[ -n ${mounted} ]] && umount ${ubootDir} |
|
elif [ "$mode" == "--remove" ]; then |
|
|
remove |
|
|
elif [ "$mode" == "--update" ]; then |
|
|
update |
|
|
fi |
|
898 |
|
|
899 |
exit 0 |
exit 0 |