1 |
#!/bin/bash |
#!/bin/bash |
2 |
|
# $Id$ |
3 |
# |
# |
4 |
|
# 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 |
6 |
# tasks are/can be done here: |
# tasks are/can be done here: |
7 |
# creation/removal of initrd |
# creation/removal of initrd |
8 |
# run of depmod/removal of depmod generated files |
# run of depmod/removal of depmod generated files |
9 |
# addition/removal of kernel images from grub/lilo configuration (via grubby) |
# addition/removal of kernel images from grub/lilo configuration (via grubby) |
10 |
# |
# |
11 |
# Copyright (C) 2002-2005 Red Hat, Inc. |
# Copyright 2002-2008 Red Hat, Inc. All rights reserved. |
|
# |
|
12 |
# modified for Magellan-Linux by Niels Rogalla <niro@magellan-linux.de> |
# modified for Magellan-Linux by Niels Rogalla <niro@magellan-linux.de> |
13 |
# |
# |
14 |
|
# This program is free software; you can redistribute it and/or modify |
15 |
|
# it under the terms of the GNU General Public License as published by |
16 |
|
# the Free Software Foundation; either version 2 of the License, or |
17 |
|
# (at your option) any later version. |
18 |
|
# |
19 |
|
# This program is distributed in the hope that it will be useful, |
20 |
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
21 |
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22 |
|
# GNU General Public License for more details. |
23 |
|
# |
24 |
|
# You should have received a copy of the GNU General Public License |
25 |
|
# 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 |
|
|
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} =~ armv[5|7].*l ]] |
116 |
|
then |
117 |
|
liloConfig="" |
118 |
|
bootPrefix=/boot |
119 |
|
extlinuxConfig=$(readlink -f /etc/extlinux.conf 2>/dev/null) |
120 |
|
ubootDir=${UBOOT_DIR:-"/boot"} |
121 |
|
ubootScript=$ubootDir/${UBOOT_SCR:-"boot.scr"} |
122 |
|
ubootKList=${UBOOT_KLIST:-"klist.txt"} |
123 |
|
ubootDevice=/dev/${UBOOT_DEVICE:-"mmcblk0p1"} |
124 |
|
ubootDefaultImage=${UBOOT_UIMAGE:-"uImage"} |
125 |
|
ubootDefaultInitrd=${UBOOT_UINITRD:-"uInitrd"} |
126 |
|
ubootAddress=${UBOOT_IMGADDR:-"0x00008000"} |
127 |
|
mounted="" |
128 |
|
liloFlag="" |
129 |
|
isx86="" |
130 |
else |
else |
131 |
# this leaves i?86 and x86_64 |
# this leaves i?86 and x86_64 |
132 |
liloConfig=/etc/lilo.conf |
liloConfig=/etc/lilo.conf |
133 |
grubConfig=/boot/grub/grub.conf |
grubConfig=/boot/grub/grub.conf |
134 |
bootPrefix=/boot |
grub2Config=/boot/grub/grub.cfg |
135 |
liloFlag=lilo |
grub2EfiConfig=/boot/grub/grub-efi.cfg |
136 |
isx86="yes" |
extlinuxConfig=/boot/extlinux/extlinux.conf |
137 |
|
bootPrefix=/boot |
138 |
|
liloFlag=lilo |
139 |
|
isx86="yes" |
140 |
fi |
fi |
141 |
|
|
142 |
mode="" |
mode="" |
143 |
version="" |
version="" |
144 |
initrd="" |
initrd="" |
145 |
|
dracut="" |
146 |
|
dracuthostonly="" |
147 |
initrdfile="" |
initrdfile="" |
148 |
moddep="" |
moddep="" |
149 |
verbose="" |
verbose="" |
150 |
makedefault="" |
makedefault="" |
151 |
package="" |
package="" |
152 |
mbkernel="" |
mbkernel="${HYPERVISOR}" |
153 |
mbargs="" |
mbargs="${HYPERVISOR_ARGS}" |
154 |
|
adddracutargs="" |
155 |
|
addplymouthinitrd="" |
156 |
|
|
157 |
|
usage() |
158 |
|
{ |
159 |
|
echo "Usage: $(basename $0) [-v] [--mkinitrd] [--rminitrd] [--dracut]" >&2 |
160 |
|
echo " [--initrdfile=<initrd-image>] [--depmod] [--rmmoddep]" >&2 |
161 |
|
echo " [--kernel-args=<args>] [--remove-args=<args>]" >&2 |
162 |
|
echo " [--banner=<banner>] [--multiboot=multiboot]" >&2 |
163 |
|
echo " [--mbargs=mbargs] [--make-default] [--add-dracut-args]" >&2 |
164 |
|
echo " [--add-plymouth-initrd]" >&2 |
165 |
|
echo " [--host-only]" >&2 |
166 |
|
echo " <--install | --remove | --update> <kernel-version>" >&2 |
167 |
|
echo " (ex: $(basename $0) --mkinitrd --depmod --install 2.4.7-2)" >&2 |
168 |
|
exit 1 |
169 |
|
} |
170 |
|
|
171 |
|
install() |
172 |
|
{ |
173 |
|
# XXX kernel should be able to be specified also (or work right on ia64) |
174 |
|
if [ ! -f ${kernelImage} ] |
175 |
|
then |
176 |
|
[[ -n ${verbose} ]] && echo "kernel for ${version} does not exist, not running grubby" |
177 |
|
return |
178 |
|
fi |
179 |
|
|
180 |
|
INITRD="" |
181 |
|
if [ -f ${initrdfile} ] |
182 |
|
then |
183 |
|
[[ -n ${verbose} ]] && echo "found ${initrdfile} and using it with grubby" |
184 |
|
INITRD="--initrd ${initrdfile}" |
185 |
|
|
186 |
|
if [[ -n ${addplymouthinitrd} ]] |
187 |
|
then |
188 |
|
INITRD="${INITRD} --extra-initrd ${bootPrefix}/initrd-plymouth.img" |
189 |
|
fi |
190 |
|
fi |
191 |
|
|
192 |
|
# FIXME: is this a good heuristic to find out if we're on iSeries? |
193 |
|
if [ -d /proc/iSeries ] |
194 |
|
then |
195 |
|
[[ -n ${verbose} ]] && echo "On an iSeries, just making img file" |
196 |
|
if [[ -z ${initrdfile} ]] |
197 |
|
then |
198 |
|
[[ -n ${verbose} ]] && echo "No initrd, just adding system map" |
199 |
|
/sbin/addSystemMap ${bootPrefix}/System.map-${version} ${kernelImage} ${bootPrefix}/vmlinitrd-${version} |
200 |
|
else |
201 |
|
/sbin/addSystemMap ${bootPrefix}/System.map-${version} ${kernelImage} ${bootPrefix}/vmlinux.sm-${version} |
202 |
|
/sbin/addRamDisk ${initrdfile} ${bootPrefix}/System.map-${version} ${bootPrefix}/vmlinux.sm-${version} ${bootPrefix}/vmlinitrd-${version} 2>/dev/null |
203 |
|
rm ${bootPrefix}/vmlinux.sm-${version} |
204 |
|
fi |
205 |
|
return |
206 |
|
fi |
207 |
|
|
208 |
|
# get the root filesystem to use |
209 |
|
rootdevice=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $1; }}' /etc/fstab 2>/dev/null) |
210 |
|
if [[ -z $rootdevice ]] |
211 |
|
then |
212 |
|
rootdevice=$(grep -o -P "(?<=root=)\S+" /proc/cmdline) |
213 |
|
fi |
214 |
|
|
215 |
|
if [[ -n ${mbkernel} ]] && [[ -n ${cfgLilo} ]] && [[ ${liloFlag} != elilo ]] |
216 |
|
then |
217 |
|
[[ -n ${verbose} ]] && echo "multiboot specified, not updating lilo.conf" |
218 |
|
cfgLilo="" |
219 |
|
fi |
220 |
|
|
221 |
|
if [[ -n ${banner} ]] |
222 |
|
then |
223 |
|
title="${banner} [ ${version} ]" |
224 |
|
elif [[ $(read_os_release id) = magellan ]] |
225 |
|
then |
226 |
|
title="$(read_os_release name) $(read_os_release version_id) [ ${version} ]" |
227 |
|
elif [ -f /etc/mageversion ] |
228 |
|
then |
229 |
|
title="Magellan Linux $(< /etc/mageversion) [ ${version} ]" |
230 |
|
else |
231 |
|
title="Magellan Linux [ ${version} ]" |
232 |
|
fi |
233 |
|
|
234 |
|
if [[ -n ${cfgGrub} ]] |
235 |
|
then |
236 |
|
[[ -n ${verbose} ]] && echo "adding ${version} to ${grubConfig}" |
237 |
|
|
238 |
|
${grubby} --grub -c ${grubConfig} \ |
239 |
|
--add-kernel=${kernelImage} \ |
240 |
|
${INITRD} --copy-default ${makedefault} --title "${title}" \ |
241 |
|
${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \ |
242 |
|
--args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}" |
243 |
|
else |
244 |
|
[[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby for grub 0.97" |
245 |
|
fi |
246 |
|
if [[ -n ${cfgGrub2} ]] |
247 |
|
then |
248 |
|
[[ -n ${verbose} ]] && echo "adding ${version} to ${grub2Config}" |
249 |
|
|
250 |
|
${grubby} --grub2 -c ${grub2Config} \ |
251 |
|
--add-kernel=${kernelImage} \ |
252 |
|
${INITRD} --copy-default ${makedefault} --title "${title}" \ |
253 |
|
${mbkernel:+--add-multiboot="${mbkernel}"} \ |
254 |
|
${mbargs:+--mbargs="${mbargs}"} \ |
255 |
|
--args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}" |
256 |
|
else |
257 |
|
[[ -n ${verbose} ]] && echo "${grub2Config} does not exist, not running grubby for grub 2" |
258 |
|
fi |
259 |
|
if [[ -n ${cfgGrub2Efi} ]] |
260 |
|
then |
261 |
|
[[ -n ${verbose} ]] && echo "adding ${version} to ${grub2EfiConfig}" |
262 |
|
|
263 |
|
${grubby} --grub2 -c ${grub2EfiConfig} --efi \ |
264 |
|
--add-kernel=${kernelImage} \ |
265 |
|
${INITRD} --copy-default ${makedefault} --title "${title}" \ |
266 |
|
${mbkernel:+--add-multiboot="${mbkernel}"} \ |
267 |
|
${mbargs:+--mbargs="${mbargs}"} \ |
268 |
|
--args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}" |
269 |
|
else |
270 |
|
[[ -n ${verbose} ]] && echo "${grub2EfiConfig} does not exist, not running grubby for grub 2 with UEFI" |
271 |
|
fi |
272 |
|
|
273 |
|
if [[ -n ${cfgLilo} ]] |
274 |
|
then |
275 |
|
[[ -n ${verbose} ]] && echo "adding ${version} to ${liloConfig}" |
276 |
|
|
277 |
|
${grubby} --add-kernel=${kernelImage} ${INITRD} \ |
278 |
|
--copy-default ${makedefault} --title ${version} \ |
279 |
|
${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \ |
280 |
|
--args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${version}" \ |
281 |
|
--${liloFlag} |
282 |
|
|
283 |
|
if [[ -n ${runLilo} ]] |
284 |
|
then |
285 |
|
[[ -n ${verbose} ]] && echo "running ${lilo}" |
286 |
|
if [ ! -x ${lilo} ] |
287 |
|
then |
288 |
|
[[ -n ${verbose} ]] && echo "${lilo} does not exist" |
289 |
|
else |
290 |
|
${lilo} > /dev/null |
291 |
|
fi |
292 |
|
fi |
293 |
|
else |
294 |
|
[[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby" |
295 |
|
fi |
296 |
|
|
297 |
usage() { |
if [[ -n ${cfgExtlinux} ]] |
298 |
echo "Usage: `basename $0` [-v] [--mkinitrd] [--rminitrd]" >&2 |
then |
299 |
echo " [--initrdfile=<initrd-image>] [--depmod] [--rmmoddep]" >&2 |
[[ -n ${verbose} ]] && echo "adding ${version} to ${extlinuxConfig}" |
300 |
echo " [--kernel-args=<args>] [--banner=<banner>]" >&2 |
|
301 |
echo " [--multiboot=multiboot] [--mbargs=mbargs]" >&2 |
${grubby} --extlinux -c ${extlinuxConfig} \ |
302 |
echo " [--make-default] <--install | --remove> <kernel-version>" >&2 |
--add-kernel=${kernelImage} \ |
303 |
echo " (ex: `basename $0` --mkinitrd --depmod --install 2.4.7-2)" >&2 |
${INITRD} --copy-default ${makedefault} --title "${title}" \ |
304 |
exit 1 |
${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \ |
305 |
|
--args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}" |
306 |
|
else |
307 |
|
[[ -n ${verbose} ]] && echo "${extlinuxConfig} does not exist, not running grubby for extlinux" |
308 |
|
fi |
309 |
} |
} |
310 |
|
|
311 |
install() { |
remove() |
312 |
# XXX kernel should be able to be specified also (or work right on ia64) |
{ |
313 |
if [ ! -f $bootPrefix/$kernelName-$version ] ; then |
# FIXME: is this a good heuristic to find out if we're on iSeries? |
314 |
[ -n "$verbose" ] && echo "kernel for $version does not exist, not running grubby" |
if [ -d /proc/iSeries ] |
315 |
return |
then |
316 |
fi |
[[ -n ${verbose} ]] && echo "On an iSeries, remove img file" |
317 |
|
rm -f ${kernelImage}.img 2>/dev/null |
318 |
INITRD="" |
return |
319 |
if [ -f $initrdfile ]; then |
fi |
|
[ -n "$verbose" ] && echo "found $initrdfile and using it with grubby" |
|
|
INITRD="--initrd $initrdfile" |
|
|
fi |
|
|
|
|
|
# FIXME: is this a good heuristic to find out if we're on iSeries? |
|
|
if [ -d /proc/iSeries ]; then |
|
|
[ -n "$verbose" ] && echo "On an iSeries, just making img file" |
|
|
if [ -z $initrdfile ]; then |
|
|
[ -n "$verbose" ] && echo "No initrd, just adding system map" |
|
|
/sbin/addSystemMap $bootPrefix/System.map-$version $bootPrefix/$kernelName-$version $bootPrefix/vmlinitrd-$version |
|
|
else |
|
|
/sbin/addSystemMap $bootPrefix/System.map-$version $bootPrefix/$kernelName-$version $bootPrefix/vmlinux.sm-$version |
|
|
/sbin/addRamDisk $initrdfile $bootPrefix/System.map-$version $bootPrefix/vmlinux.sm-$version $bootPrefix/vmlinitrd-$version 2>/dev/null |
|
|
rm $bootPrefix/vmlinux.sm-$version |
|
|
fi |
|
|
return |
|
|
fi |
|
|
|
|
|
# get the root filesystem to use; if it's on a label make sure it's |
|
|
# been configured. if not, get the root device from mount |
|
|
rootdevice=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $1; }}' /etc/fstab) |
|
|
short=$(echo $rootdevice | cut -d= -f1) |
|
|
if [ "$short" == "LABEL" ]; then |
|
|
label=$(echo $rootdevice | cut -d= -f2 |head -n 1) |
|
|
device=$(echo "showlabels" | /sbin/nash --force --quiet | |
|
|
awk '$2 == "'$label'" {print $1}') |
|
|
if [ -z "$device" ]; then |
|
|
rootdevice=$(mount | awk '$3 == "/" { print $1 }') |
|
|
fi |
|
|
fi |
|
|
|
|
|
if [ -n "$mbkernel" ]; then |
|
|
mb="--add-multiboot=$mbkernel" |
|
|
if [ -n "$mbargs" ]; then |
|
|
mb="$mb --mbargs=$mbargs" |
|
|
fi |
|
|
[ -n "$verbose" ] && echo "multiboot specified, not updating lilo.conf" |
|
|
cfgLilo="" |
|
|
fi |
|
|
|
|
|
if [ -n "$cfgGrub" ]; then |
|
|
[ -n "$verbose" ] && echo "adding $version to $grubConfig" |
|
|
|
|
|
if [ -n "$banner" ]; then |
|
|
title="$banner ($version)" |
|
|
elif [ -f /etc/mageversion ]; then |
|
|
title="Magellan Linux $(< /etc/mageversion) ($version)" |
|
|
else |
|
|
title="Magellan Linux ($version)" |
|
|
fi |
|
|
/sbin/grubby --add-kernel=$bootPrefix/$kernelName-$version $INITRD \ |
|
|
--copy-default $makedefault $mb --title "$title" \ |
|
|
--args="root=$rootdevice $kernargs" \ |
|
|
--remove-kernel="TITLE=$title" |
|
|
else |
|
|
[ -n "$verbose" ] && echo "$grubConfig does not exist, not running grubby" |
|
|
fi |
|
|
|
|
|
if [ -n "$cfgLilo" ]; then |
|
|
[ -n "$verbose" ] && echo "adding $version to $liloConfig" |
|
|
|
|
|
/sbin/grubby --add-kernel=$bootPrefix/$kernelName-$version $INITRD \ |
|
|
--copy-default $makedefault --title $version \ |
|
|
--args="root=$rootdevice $kernargs" \ |
|
|
--remove-kernel="TITLE=$version" \ |
|
|
--$liloFlag |
|
|
|
|
|
if [ -n "$runLilo" ]; then |
|
|
[ -n "$verbose" ] && echo "running $lilo" |
|
|
if [ ! -x $lilo ] ; then |
|
|
[ -n "$verbose" ] && echo "$lilo does not exist" |
|
|
else |
|
|
$lilo > /dev/null |
|
|
fi |
|
|
fi |
|
|
else |
|
|
[ -n "$verbose" ] && echo "$liloConfig does not exist, not running grubby" |
|
|
fi |
|
320 |
|
|
321 |
|
if [[ -n ${cfgGrub} ]] |
322 |
|
then |
323 |
|
[[ -n ${verbose} ]] && echo "removing ${version} from ${grubConfig}" |
324 |
|
${grubby} --grub -c ${grubConfig} \ |
325 |
|
--remove-kernel=${kernelImage} |
326 |
|
else |
327 |
|
[[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby for grub 0.97" |
328 |
|
fi |
329 |
|
if [[ -n ${cfgGrub2} ]] |
330 |
|
then |
331 |
|
[[ -n ${verbose} ]] && echo "removing ${version} from ${grub2Config}" |
332 |
|
${grubby} --grub2 -c ${grub2Config} \ |
333 |
|
--remove-kernel=${kernelImage} |
334 |
|
else |
335 |
|
[[ -n ${verbose} ]] && echo "${grub2Config} does not exist, not running grubby for grub 2" |
336 |
|
fi |
337 |
|
if [[ -n ${cfgGrub2Efi} ]] |
338 |
|
then |
339 |
|
[[ -n ${verbose} ]] && echo "removing ${version} from ${grub2EfiConfig}" |
340 |
|
${grubby} --grub2 -c ${grub2EfiConfig} --efi \ |
341 |
|
--remove-kernel=${kernelImage} |
342 |
|
else |
343 |
|
[[ -n ${verbose} ]] && echo "${grub2EfiConfig} does not exist, not running grubby grub 2 with UEFI" |
344 |
|
fi |
345 |
|
|
346 |
|
if [[ -n ${cfgLilo} ]] |
347 |
|
then |
348 |
|
[[ -n ${verbose} ]] && echo "removing ${version} from ${liloConfig}" |
349 |
|
${grubby} --remove-kernel=${kernelImage} --${liloFlag} |
350 |
|
|
351 |
|
if [[ -n ${runLilo} ]] |
352 |
|
then |
353 |
|
[[ -n ${verbose} ]] && echo "running ${lilo}" |
354 |
|
if [ ! -x ${lilo} ] |
355 |
|
then |
356 |
|
[[ -n ${verbose} ]] && echo "${lilo} does not exist" |
357 |
|
else |
358 |
|
${lilo} > /dev/null |
359 |
|
fi |
360 |
|
fi |
361 |
|
else |
362 |
|
[[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby" |
363 |
|
fi |
364 |
|
|
365 |
|
if [[ -n ${cfguBoot} ]] |
366 |
|
then |
367 |
|
[[ -n ${verbose} ]] && echo "removing ${version} from ${ubootDir}..." |
368 |
|
|
369 |
|
if [ -f ${ubootDir}/${ubootKList} ] |
370 |
|
then |
371 |
|
tmpKList=$(mktemp ${ubootDir}/${ubootKList}.XXXX) |
372 |
|
curversion=$(tail -n1 ${ubootDir}/${ubootKList}) |
373 |
|
sed "/$version$/d" ${ubootDir}/${ubootKList} > ${tmpKList} |
374 |
|
newversion=$(tail -n1 ${tmpKList}) |
375 |
|
if [ -f ${ubootDir}/uImage-${newversion} ] && [ -f ${ubootDir}/uInitrd-${newversion} ] |
376 |
|
then |
377 |
|
if [[ ${curversion} != ${newversion} ]] |
378 |
|
then |
379 |
|
cp -fp ${ubootDir}/uImage-${newversion} ${ubootDir}/${ubootDefaultImage} |
380 |
|
if [ $? -ne 0 ] |
381 |
|
then |
382 |
|
[[ -n ${verbose} ]] && echo "copy uImage-${newversion} error, default kernel not replaced!" && exit |
383 |
|
fi |
384 |
|
cp -fp ${ubootDir}/uInitrd-${newversion} ${ubootDir}/${ubootDefaultInitrd} |
385 |
|
if [ $? -ne 0 ] |
386 |
|
then |
387 |
|
[[ -n ${verbose} ]] && echo "copy uInitrd-${newversion} error, default Initrd not replaced!" && exit |
388 |
|
fi |
389 |
|
fi |
390 |
|
|
391 |
|
[[ -n ${verbose} ]] && echo "removing uImage-${version}" |
392 |
|
if [ -f ${ubootDir}/uImage-${version} ] |
393 |
|
then |
394 |
|
rm -f ${ubootDir}/uImage-${version} |
395 |
|
else |
396 |
|
[[ -n ${verbose} ]] && echo "uImage-${version} did not exist!" |
397 |
|
fi |
398 |
|
|
399 |
|
[[ -n ${verbose} ]] && echo "removing uInitrd-${version}" |
400 |
|
if [ -f ${ubootDir}/uInitrd-${version} ] |
401 |
|
then |
402 |
|
rm -f ${ubootDir}/uInitrd-${version} |
403 |
|
else |
404 |
|
[[ -n ${verbose} ]] && echo "uInitrd-${version} did not exist!" |
405 |
|
fi |
406 |
|
|
407 |
|
mv ${tmpKList} ${ubootDir}/${ubootKList} |
408 |
|
[ -x /sbin/a-b-c ] && /sbin/a-b-c |
409 |
|
else |
410 |
|
[[ -n ${verbose} ]] && echo "uImage ${newversion} does not exist!" |
411 |
|
[ -f ${tmpKList} ] && rm -f ${tmpKList} |
412 |
|
fi |
413 |
|
else |
414 |
|
[[ -n ${verbose} ]] && echo "No previous kernel version. U-Boot images not removed!" |
415 |
|
fi |
416 |
|
else |
417 |
|
[[ -n ${verbose} ]] && echo "${ubootScript} does not exist, not modifying ${ubootDir}" |
418 |
|
fi |
419 |
|
|
420 |
|
if [[ -n ${cfgExtlinux} ]] |
421 |
|
then |
422 |
|
[[ -n ${verbose} ]] && echo "removing ${version} from ${extlinuxConfig}" |
423 |
|
${grubby} --extlinux -c ${extlinuxConfig} \ |
424 |
|
--remove-kernel=${kernelImage} |
425 |
|
else |
426 |
|
[[ -n ${verbose} ]] && echo "${extlinuxConfig} does not exist, not running grubby for extlinux" |
427 |
|
fi |
428 |
} |
} |
429 |
|
|
430 |
remove() { |
update() |
431 |
# FIXME: is this a good heuristic to find out if we're on iSeries? |
{ |
432 |
if [ -d /proc/iSeries ]; then |
if [ ! -f ${kernelImage} ] |
433 |
[ -n "$verbose" ] && echo "On an iSeries, remove img file" |
then |
434 |
rm -f $bootPrefix/$kernelName-$version.img 2>/dev/null |
[[ -n ${verbose} ]] && echo "kernel for ${version} does not exist, not running grubby" |
435 |
return |
return |
436 |
fi |
fi |
437 |
|
|
438 |
if [ -n "$cfgGrub" ]; then |
INITRD="" |
439 |
[ -n "$verbose" ] && echo "removing $version from $grubConfig" |
if [ -f ${initrdfile} ] |
440 |
/sbin/grubby --remove-kernel=$bootPrefix/$kernelName-$version |
then |
441 |
else |
[[ -n ${verbose} ]] && echo "found ${initrdfile} and using it with grubby" |
442 |
[ -n "$verbose" ] && echo "$grubConfig does not exist, not running grubby" |
INITRD="--initrd ${initrdfile}" |
443 |
fi |
|
444 |
|
if [[ -n ${addplymouthinitrd} ]] |
445 |
if [ -n "$cfgLilo" ]; then |
then |
446 |
[ -n "$verbose" ] && echo "removing $version from $liloConfig" |
INITRD="${INITRD} --extra-initrd ${bootPrefix}/initrd-plymouth.img" |
447 |
/sbin/grubby --remove-kernel=$bootPrefix/$kernelName-$version \ |
fi |
448 |
--$liloFlag |
fi |
449 |
|
|
450 |
if [ -n "$runLilo" ]; then |
if [[ -n ${cfgGrub} ]] |
451 |
[ -n "$verbose" ] && echo "running $lilo" |
then |
452 |
if [ ! -x $lilo ] ; then |
[[ -n ${verbose} ]] && echo "updating ${version} from ${grubConfig}" |
453 |
[ -n "$verbose" ] && echo "$lilo does not exist" |
${grubby} --grub -c ${grubConfig} \ |
454 |
else |
--update-kernel=${kernelImage} \ |
455 |
$lilo > /dev/null |
${INITRD} \ |
456 |
fi |
${kernargs:+--args="${kernargs}"} \ |
457 |
fi |
${removeargs:+--remove-args="${removeargs}"} |
458 |
else |
else |
459 |
[ -n "$verbose" ] && echo "$liloConfig does not exist, not running grubby" |
[[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby" |
460 |
fi |
fi |
461 |
|
|
462 |
|
if [[ -n ${cfgGrub2} ]] |
463 |
|
then |
464 |
|
[[ -n ${verbose} ]] && echo "updating ${version} from ${grub2Config}" |
465 |
|
${grubby} --grub2 -c ${grub2Config} \ |
466 |
|
--update-kernel=${kernelImage} \ |
467 |
|
${INITRD} \ |
468 |
|
${kernargs:+--args="${kernargs}"} \ |
469 |
|
${removeargs:+--remove-args="${removeargs}"} |
470 |
|
else |
471 |
|
[[ -n ${verbose} ]] && echo "${grub2Config} does not exist, not running grubby" |
472 |
|
fi |
473 |
|
|
474 |
|
if [[ -n ${cfgGrub2Efi} ]] |
475 |
|
then |
476 |
|
[[ -n ${verbose} ]] && echo "updating ${version} from ${grub2EfiConfig}" |
477 |
|
${grubby} --grub2 -c ${grub2EfiConfig} --efi \ |
478 |
|
--update-kernel=${kernelImage} \ |
479 |
|
${INITRD} \ |
480 |
|
${kernargs:+--args="${kernargs}"} \ |
481 |
|
${removeargs:+--remove-args="${removeargs}"} |
482 |
|
else |
483 |
|
[[ -n ${verbose} ]] && echo "${grub2EfiConfig} does not exist, not running grubby" |
484 |
|
fi |
485 |
|
|
486 |
|
if [[ -n ${cfgLilo} ]] |
487 |
|
then |
488 |
|
[[ -n ${verbose} ]] && echo "updating ${version} from ${liloConfig}" |
489 |
|
${grubby} --update-kernel=${kernelImage} \ |
490 |
|
${INITRD} \ |
491 |
|
${kernargs:+--args="${kernargs}"} \ |
492 |
|
${removeargs:+--remove-args="${removeargs}"} \ |
493 |
|
--${liloFlag} |
494 |
|
|
495 |
|
if [[ -n ${runLilo} ]] |
496 |
|
then |
497 |
|
[[ -n ${verbose} ]] && echo "running ${lilo}" |
498 |
|
if [ ! -x ${lilo} ] |
499 |
|
then |
500 |
|
[[ -n ${verbose} ]] && echo "${lilo} does not exist" |
501 |
|
else |
502 |
|
${lilo} > /dev/null |
503 |
|
fi |
504 |
|
fi |
505 |
|
else |
506 |
|
[[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby" |
507 |
|
fi |
508 |
|
|
509 |
|
if [[ -n ${cfguBoot} ]] |
510 |
|
then |
511 |
|
[[ -n ${verbose} ]] && echo "adding $version to ${ubootDir}..." |
512 |
|
|
513 |
|
[[ -n ${verbose} ]] && echo "creating uImage-${version}" |
514 |
|
mkimage -A arm -O linux -T kernel -C none -a ${ubootAddress} \ |
515 |
|
-e ${ubootAddress} -n ${version} \ |
516 |
|
-d ${kernelImage} ${ubootDir}/uImage-${version} |
517 |
|
|
518 |
|
[[ -n ${verbose} ]] && echo "creating uInitrd-${version}" |
519 |
|
mkimage -A arm -O linux -T ramdisk -C none -a 0 -e 0 \ |
520 |
|
-n initramfs -d ${initrdfile} ${ubootDir}/uInitrd-${version} |
521 |
|
|
522 |
|
if [ -f ${ubootDir}/uImage-${version} ] && [ -f ${ubootDir}/uInitrd-${version} ] |
523 |
|
then |
524 |
|
cp -fp ${ubootDir}/uImage-${version} ${ubootDir}/${ubootDefaultImage} |
525 |
|
if [ $? -ne 0 ] |
526 |
|
then |
527 |
|
[[ -n ${verbose} ]] && echo "copy uImage-${version} error, kernel not installed!" && exit |
528 |
|
fi |
529 |
|
cp -fp ${ubootDir}/uInitrd-${version} ${ubootDir}/${ubootDefaultInitrd} |
530 |
|
if [ $? -ne 0 ] |
531 |
|
then |
532 |
|
[[ -n ${verbose} ]] && echo "copy uInitrd-${version} error, kernel not installed!" && exit |
533 |
|
fi |
534 |
|
echo ${version} >> ${ubootDir}/${ubootKList} |
535 |
|
[ -x /sbin/a-b-c ] && /sbin/a-b-c |
536 |
|
else |
537 |
|
[[ -n ${verbose} ]] && echo "cannot make ${version} the default" |
538 |
|
fi |
539 |
|
else |
540 |
|
[[ -n ${verbose} ]] && echo "${ubootScript} does not exist, not setting up ${ubootDir}" |
541 |
|
fi |
542 |
|
|
543 |
|
if [[ -n ${cfgExtlinux} ]] |
544 |
|
then |
545 |
|
[[ -n ${verbose} ]] && echo "updating ${version} from ${extlinuxConfig}" |
546 |
|
${grubby} --extlinux -c ${extlinuxConfig} \ |
547 |
|
--update-kernel=${kernelImage} \ |
548 |
|
${INITRD} \ |
549 |
|
${kernargs:+--args="${kernargs}"} \ |
550 |
|
${removeargs:+--remove-args="${removeargs}"} |
551 |
|
else |
552 |
|
[[ -n ${verbose} ]] && echo "${extlinuxConfig} does not exist, not running grubby" |
553 |
|
fi |
554 |
} |
} |
555 |
|
|
556 |
mkinitrd() { |
makeinitrd() |
557 |
[ -n "$verbose" ] && echo "creating initrd $initrdfile using $version" |
{ |
558 |
/sbin/mkinitrd --allow-missing -f $initrdfile $version |
if [[ -n ${dracut} ]] |
559 |
rc=$? |
then |
560 |
if [ $rc != 0 ]; then |
tool="dracut ${dracuthostonly} -f ${initrdfile} ${version}" |
561 |
echo "mkinitrd failed" >&2 |
else |
562 |
exit 1 |
tool="mkinitrd --allow-missing -f ${initrdfile} ${version}" |
563 |
fi |
fi |
564 |
|
[[ -n ${verbose} ]] && echo "creating initrd ${initrdfile} using ${version}" |
565 |
|
${tool} |
566 |
|
rc=$? |
567 |
|
if [ ${rc} != 0 ] |
568 |
|
then |
569 |
|
echo "mkinitrd failed" >&2 |
570 |
|
exit 1 |
571 |
|
fi |
572 |
} |
} |
573 |
|
|
574 |
rminitrd() { |
rminitrd() |
575 |
[ -n "$verbose" ] && echo "removing initrd $initrdfile" |
{ |
576 |
[ -f $initrdfile ] && rm -f $initrdfile |
[[ -n ${verbose} ]] && echo "removing initrd ${initrdfile}" |
577 |
|
[ -f ${initrdfile} ] && rm -f ${initrdfile} |
578 |
} |
} |
579 |
|
|
580 |
doDepmod() { |
doDepmod() |
581 |
[ -n "$verbose" ] && echo "running depmod for $version" |
{ |
582 |
depmod -ae -F /boot/System.map-$version $version |
[[ -n ${verbose} ]] && echo "running depmod for ${version}" |
583 |
|
depmod -ae -F /boot/System.map-${version} ${version} |
584 |
} |
} |
585 |
|
|
586 |
doRmmoddep() { |
doRmmoddep() |
587 |
[ -n "$verbose" ] && echo "removing modules.dep info for $version" |
{ |
588 |
[ -d /lib/modules/$version ] && rm -f /lib/modules/$version/modules.* |
[[ -n ${verbose} ]] && echo "removing modules.dep info for ${version}" |
589 |
|
if [ -d /lib/modules/${version} ] |
590 |
|
then |
591 |
|
rm -f /lib/modules/${version}/modules.*.bin \ |
592 |
|
/lib/modules/${version}/modules.{alias,dep,devname,symbols,softdep} |
593 |
|
fi |
594 |
} |
} |
595 |
|
|
596 |
|
|
597 |
while [ $# -gt 0 ]; do |
while [ $# -gt 0 ] |
598 |
case $1 in |
do |
599 |
--mkinitrd) |
case $1 in |
600 |
initrd="make" |
--mkinitrd) |
601 |
;; |
initrd="make" |
602 |
|
;; |
603 |
--rminitrd) |
|
604 |
initrd="remove" |
--rminitrd) |
605 |
;; |
initrd="remove" |
606 |
|
;; |
607 |
--initrdfile*) |
|
608 |
if echo $1 | grep '=' >/dev/null ; then |
--dracut) |
609 |
initrdfile=`echo $1 | sed 's/^--initrdfile=//'` |
dracut=--dracut |
610 |
else |
;; |
611 |
initrdfile=$2 |
|
612 |
shift |
--host-only) |
613 |
fi |
dracuthostonly=-H |
614 |
;; |
;; |
615 |
|
|
616 |
--kernel-args*) |
--initrdfile*) |
617 |
if echo $1 | grep '=' >/dev/null ; then |
if [[ $1 == --initrdfile\=* ]] |
618 |
kernargs=`echo $1 | sed 's/^--kernel-args=//'` |
then |
619 |
else |
initrdfile=${1#--initrdfile=} |
620 |
kernargs=$2 |
else |
621 |
shift |
initrdfile=$2 |
622 |
fi |
shift |
623 |
;; |
fi |
624 |
|
;; |
625 |
--banner*) |
|
626 |
if echo $1 | grep '=' >/dev/null ; then |
--kernel-args*) |
627 |
banner=`echo $1 | sed 's/^--banner=//'` |
if [[ $1 == --kernel-args\=* ]] |
628 |
else |
then |
629 |
banner=$2 |
kernargs=${1#--kernel-args=} |
630 |
shift |
else |
631 |
fi |
kernargs=$2 |
632 |
;; |
shift |
633 |
|
fi |
634 |
--multiboot*) |
;; |
635 |
if echo $1 |grep '=' >/dev/null; then |
|
636 |
mbkernel=`echo $1 | sed 's/^--multiboot=//'` |
--remove-args*) |
637 |
else |
if [[ $1 == --remove-args\=* ]] |
638 |
# can't really support having an optional second arg here |
then |
639 |
# sorry! |
removeargs=${1#--remove-args=} |
640 |
mbkernel="/boot/xen.gz" |
else |
641 |
fi |
removeargs=$2 |
642 |
;; |
shift |
643 |
|
fi |
644 |
--mbargs*) |
;; |
645 |
if echo $1 |grep '=' >/dev/null; then |
|
646 |
mbargs=`echo $1 | sed 's/^--mbargs=//'` |
--banner*) |
647 |
else |
if [[ $1 == --banner\=* ]] |
648 |
mbargs=$2 |
then |
649 |
shift |
banner=${1#--banner=} |
650 |
fi |
else |
651 |
;; |
banner=$2 |
652 |
|
shift |
653 |
--depmod) |
fi |
654 |
moddep="make" |
;; |
655 |
;; |
|
656 |
|
--multiboot*) |
657 |
--rmmoddep) |
if [[ $1 == --multiboot\=* ]] |
658 |
moddep="remove" |
then |
659 |
;; |
mbkernel=${1#--multiboot=} |
660 |
|
else |
661 |
--make-default) |
# can't really support having an optional second arg here |
662 |
makedefault="--make-default" |
# sorry! |
663 |
;; |
mbkernel="/boot/xen.gz" |
664 |
|
fi |
665 |
--package) |
;; |
666 |
if echo $1 | grep '=' >/dev/null ; then |
|
667 |
package=`echo $1 | sed 's/^--package=//'` |
--mbargs*) |
668 |
else |
if [[ $1 == --mbargs\=* ]] |
669 |
package=$2 |
then |
670 |
shift |
mbargs=${1#--mbargs=} |
671 |
fi |
else |
672 |
;; |
mbargs="$2" |
673 |
|
shift |
674 |
-v) |
fi |
675 |
verbose=-v |
;; |
676 |
;; |
|
677 |
|
--depmod) |
678 |
*) |
moddep="make" |
679 |
if [ -z "$mode" ]; then |
;; |
680 |
mode=$1 |
|
681 |
elif [ -z "$version" ]; then |
--rmmoddep) |
682 |
version=$1 |
moddep="remove" |
683 |
else |
;; |
684 |
usage |
|
685 |
fi |
--make-default) |
686 |
;; |
makedefault="--make-default" |
687 |
esac |
;; |
688 |
|
|
689 |
|
--package*) |
690 |
|
if [[ $1 == --package\=* ]] |
691 |
|
then |
692 |
|
package=${1#--package=} |
693 |
|
else |
694 |
|
package=$2 |
695 |
|
shift |
696 |
|
fi |
697 |
|
;; |
698 |
|
|
699 |
|
--add-dracut-args) |
700 |
|
adddracutargs=--add-dracut-args |
701 |
|
;; |
702 |
|
|
703 |
|
--add-plymouth-initrd) |
704 |
|
addplymouthinitrd=--add-plymouth-initrd |
705 |
|
;; |
706 |
|
|
707 |
|
--kernel-image*) |
708 |
|
if [[ $1 == --kernel-image\=* ]] |
709 |
|
then |
710 |
|
kernelImage=${1#--kernel-image=} |
711 |
|
else |
712 |
|
kernelImage="$2" |
713 |
|
shift |
714 |
|
fi |
715 |
|
if ! [[ -f ${kernelImage} ]] |
716 |
|
then |
717 |
|
echo "Can't find kernel image '${kernelImage}'" >&2 |
718 |
|
usage |
719 |
|
exit 1 |
720 |
|
fi |
721 |
|
;; |
722 |
|
|
723 |
|
-v) |
724 |
|
verbose=-v |
725 |
|
;; |
726 |
|
|
727 |
|
*) |
728 |
|
if [[ -z ${mode} ]] |
729 |
|
then |
730 |
|
mode=$1 |
731 |
|
elif [[ -z ${version} ]] |
732 |
|
then |
733 |
|
version=$1 |
734 |
|
else |
735 |
|
usage |
736 |
|
fi |
737 |
|
;; |
738 |
|
esac |
739 |
|
|
740 |
shift |
shift |
741 |
done |
done |
742 |
|
|
743 |
# make sure the mode is valid |
# make sure the mode is valid |
744 |
if [ "$mode" != "--install" -a "$mode" != "--remove" ] ; then |
if [[ ${mode} != --install ]] && [[ ${mode} != --remove ]] && [[ ${mode} != --update ]] |
745 |
usage |
then |
746 |
|
usage |
747 |
fi |
fi |
748 |
|
|
749 |
if [ -z "$version" ]; then |
if [[ -z ${version} ]] |
750 |
usage |
then |
751 |
|
usage |
752 |
fi |
fi |
753 |
|
|
754 |
if [ "$mode" != "--install" -a "$makedefault" ]; then |
if [ "${mode}" != "--install" -a "${makedefault}" ] |
755 |
usage |
then |
756 |
|
usage |
757 |
fi |
fi |
758 |
|
|
759 |
# make sure that /dev/loop exist |
kernelmajor=$(echo ${kernel} | cut -d . -f 1,2) |
|
[[ ! -e /dev/loop ]] && modprobe loop |
|
|
|
|
|
kernelmajor=`echo $kernel | cut -d . -f 1,2` |
|
760 |
|
|
761 |
# kernel image for 2.4 is vmlinux |
# kernel image for 2.4 is kernel |
762 |
if [ $ARCH = 'ppc64' -o $ARCH = 'ppc' ]; then |
if [[ ${ARCH} = ppc64 ]] || [[ ${ARCH} = ppc ]] |
763 |
if [ "$kernelmajor" == "2.4" ]; then |
then |
764 |
kernelName=vmlinux |
if [[ ${kernelmajor} = 2.4 ]] |
765 |
fi |
then |
766 |
|
kernelName=kernel |
767 |
|
fi |
768 |
fi |
fi |
769 |
|
|
770 |
|
[[ ${kernelImage} ]] || kernelImage="${bootPrefix}/${kernelName}-${version}" |
771 |
|
|
772 |
# 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 |
773 |
if [ -z "$initrdfile" ]; then |
if [[ -z ${initrdfile} ]] |
774 |
if [ `uname -m` = "ia64" ]; then |
then |
775 |
initrdfile="/boot/efi/EFI/redhat/initrd-$version.img" |
INITRD_NAME_PREFIX="initrd" |
776 |
else |
if [[ -n ${dracut} ]] |
777 |
initrdfile="/boot/initrd-$version.img" |
then |
778 |
fi |
INITRD_NAME_PREFIX="initramfs" |
779 |
|
fi |
780 |
|
|
781 |
|
if [[ $(uname -m) = ia64 ]] |
782 |
|
then |
783 |
|
initrdfile="/boot/efi/EFI/redhat/${INITRD_NAME_PREFIX}-${version}.img" |
784 |
|
else |
785 |
|
initrdfile="/boot/${INITRD_NAME_PREFIX}-${version}.img" |
786 |
|
fi |
787 |
fi |
fi |
788 |
[ -n "$verbose" ] && echo "initrdfile is $initrdfile" |
[[ -n ${verbose} ]] && echo "initrdfile is ${initrdfile}" |
789 |
|
|
790 |
# set this as the default if we have the package and it matches |
# add dracut i18n, keyboard and plymouth kernel args if requested |
791 |
if [ "$mode" == "--install" -a "$UPDATEDEFAULT" == "yes" -a -n "$package" -a -n "$DEFAULTKERNEL" -a "$package" == "$DEFAULTKERNEL" ]; then |
if [[ -n ${dracut} ]] || [[ -n ${adddracutargs} ]] |
792 |
makedefault="--make-default" |
then |
793 |
[ -n "$verbose" ] && echo "making it the default based on config" |
if [ -r /etc/vconsole.conf ] |
794 |
fi |
then |
795 |
|
. /etc/vconsole.conf |
796 |
|
|
797 |
|
for i in SYSFONT SYSFONTACM UNIMAP KEYTABLE |
798 |
|
do |
799 |
|
val=$(eval echo \$$i) |
800 |
|
[[ -n ${val} ]] && kernargs="${kernargs} ${i}=${val}" |
801 |
|
done |
802 |
|
else |
803 |
|
if [ -r /etc/conf.d/consolefont ] |
804 |
|
then |
805 |
|
. /etc/conf.d/consolefont |
806 |
|
|
807 |
|
if [[ -n ${CONSOLEFONT} ]] |
808 |
|
then |
809 |
|
kernargs="${kernargs} SYSFONT=${CONSOLEFONT}" |
810 |
|
fi |
811 |
|
fi |
812 |
|
|
813 |
|
if [ -r /etc/conf.d/keymap ] |
814 |
|
then |
815 |
|
. /etc/conf.d/keymap |
816 |
|
|
817 |
|
if [[ -n ${KEYMAP} ]] |
818 |
|
then |
819 |
|
kernargs="${kernargs} KEYTABLE=${KEYMAP}" |
820 |
|
fi |
821 |
|
fi |
822 |
|
fi |
823 |
|
|
824 |
if [ "$moddep" == "make" ]; then |
if [ -r /etc/locale.conf ] |
825 |
doDepmod |
then |
826 |
elif [ "$moddep" == "remove" ]; then |
. /etc/locale.conf |
827 |
doRmmoddep |
|
828 |
|
if [[ -n ${LANG} ]] |
829 |
|
then |
830 |
|
kernargs="${kernargs} LANG=${LANG}" |
831 |
|
fi |
832 |
|
fi |
833 |
fi |
fi |
834 |
|
|
835 |
if [ "$initrd" == "make" ]; then |
# set this as the default if we have the package and it matches |
836 |
mkinitrd |
if [[ ${mode} = --install ]] && [[ ${UPDATEDEFAULT} = yes ]] && [[ -n ${package} ]] && |
837 |
elif [ "$initrd" == "remove" ]; then |
[[ -n ${DEFAULTKERNEL} ]] && [[ ${package} = ${DEFAULTKERNEL} ]] |
838 |
rminitrd |
then |
839 |
|
makedefault="--make-default" |
840 |
|
[[ -n ${verbose} ]] && echo "making it the default based on config" |
841 |
|
fi |
842 |
|
|
843 |
|
if [[ ${moddep} = make ]] |
844 |
|
then |
845 |
|
doDepmod |
846 |
|
elif [[ ${moddep} = remove ]] |
847 |
|
then |
848 |
|
doRmmoddep |
849 |
|
fi |
850 |
|
|
851 |
|
if [[ ${initrd} = make ]] |
852 |
|
then |
853 |
|
makeinitrd |
854 |
|
elif [[ ${initrd} = remove ]] |
855 |
|
then |
856 |
|
rminitrd |
857 |
|
fi |
858 |
|
|
859 |
|
if [ ! -x ${grubby} ] |
860 |
|
then |
861 |
|
[[ -n ${verbose} ]] && echo "${grubby} does not exist" |
862 |
|
exit 0 |
863 |
|
fi |
864 |
|
|
865 |
|
[[ -n ${grubConfig} ]] && [ -f ${grubConfig} ] && cfgGrub=1 |
866 |
|
[[ -n ${grub2Config} ]] && [ -f ${grub2Config} ] && cfgGrub2=1 |
867 |
|
[[ -n ${grub2EfiConfig} ]] && [ -f ${grub2EfiConfig} ] && cfgGrub2Efi=1 |
868 |
|
[[ -n ${liloConfig} ]] && [ -f ${liloConfig} ] && cfgLilo=1 |
869 |
|
[[ -n ${extlinuxConfig} ]] && [ -f ${extlinuxConfig} ] && cfgExtlinux=1 |
870 |
|
|
871 |
|
# if we have a U-Boot directory, but no boot script, check if the directory |
872 |
|
# is mounted. If not, mount it, and then check if a boot script exists. |
873 |
|
if [[ -n ${ubootDir} ]] |
874 |
|
then |
875 |
|
if [ -f ${ubootScript} ] |
876 |
|
then |
877 |
|
cfguBoot=1 |
878 |
|
else |
879 |
|
mountEntry=$(mount | grep ${ubootDir}) |
880 |
|
if [[ -z ${mountEntry} ]] |
881 |
|
then |
882 |
|
mount ${ubootDevice} ${ubootDir} |
883 |
|
mounted=1 |
884 |
|
fi |
885 |
|
[ -f ${ubootScript} ] && cfguBoot=1 |
886 |
|
fi |
887 |
fi |
fi |
888 |
|
|
889 |
if [ ! -x $grubby ] ; then |
# if we're using U-Boot, check if the default load address should change |
890 |
[ -n "$verbose" ] && echo "$grubby does not exist" |
if [[ -n ${cfguBoot} ]] && [[ -z ${UBOOT_IMGADDR} ]] |
891 |
exit 0 |
then |
892 |
|
[[ ${version} =~ .([^.]*)$ ]] |
893 |
|
platform=${BASH_REMATCH[1]} |
894 |
|
# A few platforms use an alternate kernel load address |
895 |
|
if [[ ${platform} = omap ]] |
896 |
|
then |
897 |
|
ubootAddress=0x80008000 |
898 |
|
elif [[ ${platform} = imx ]] |
899 |
|
then |
900 |
|
ubootAddress=0x90008000 |
901 |
|
fi |
902 |
fi |
fi |
903 |
|
|
|
|
|
|
[ -n "$grubConfig" ] && [ -f "$grubConfig" ] && cfgGrub=1; |
|
|
[ -n "$liloConfig" ] && [ -f "$liloConfig" ] && cfgLilo=1; |
|
|
|
|
904 |
# 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 |
905 |
# is lilo to determine if it should be run |
# is lilo to determine if it should be run |
906 |
if [ -n "$cfgLilo" -a -n "$isx86" ]; then |
if [[ -n ${cfgLilo} ]] && [[ -n ${isx86} ]] |
907 |
runLilo=$($grubby --bootloader-probe | grep lilo) |
then |
908 |
|
runLilo=$(${grubby} --bootloader-probe | grep lilo) |
909 |
|
fi |
910 |
|
|
911 |
|
if [[ ${mode} = --install ]] |
912 |
|
then |
913 |
|
install |
914 |
|
elif [[ ${mode} = --remove ]] |
915 |
|
then |
916 |
|
remove |
917 |
|
elif [[ ${mode} = --update ]] |
918 |
|
then |
919 |
|
update |
920 |
fi |
fi |
921 |
|
|
922 |
if [ "$mode" == "--install" ]; then |
# if we mounted the U-Boot directory, unmount it. |
923 |
install |
[[ -n ${mounted} ]] && umount ${ubootDir} |
|
elif [ "$mode" == "--remove" ]; then |
|
|
remove |
|
|
fi |
|
924 |
|
|
925 |
exit 0 |
exit 0 |