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 |
66 |
fi |
fi |
67 |
|
|
68 |
[ -f /etc/conf.d/grubby ] && . /etc/conf.d/grubby |
[ -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 |
|
|
91 |
elif [[ ${ARCH} = ppc64 ]] || [[ ${ARCH} = ppc ]] |
elif [[ ${ARCH} = ppc64 ]] || [[ ${ARCH} = ppc ]] |
92 |
then |
then |
93 |
liloConfig=/etc/yaboot.conf |
liloConfig=/etc/yaboot.conf |
94 |
|
grub2Config=/boot/grub/grub.cfg |
95 |
bootPrefix=/boot |
bootPrefix=/boot |
96 |
lilo=/sbin/ybin |
lilo=/sbin/ybin |
97 |
liloFlag=yaboot |
liloFlag=yaboot |
112 |
lilo=/sbin/zipl |
lilo=/sbin/zipl |
113 |
runLilo="yes" |
runLilo="yes" |
114 |
isx86="" |
isx86="" |
115 |
|
elif [[ ${ARCH} = armv7l ]] || [[ ${ARCH} = armv7hl ]] || [[ ${ARCH} = armv5tel ]] |
116 |
|
then |
117 |
|
liloConfig="" |
118 |
|
bootPrefix=/boot |
119 |
|
ubootDir=${UBOOT_DIR:-"/boot"} |
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 |
|
grub2Config=/boot/grub/grub.cfg |
145 |
|
grub2EfiConfig=/boot/grub/grub-efi.cfg |
146 |
|
extlinuxConfig=/boot/extlinux/extlinux.conf |
147 |
bootPrefix=/boot |
bootPrefix=/boot |
148 |
liloFlag=lilo |
liloFlag=lilo |
149 |
isx86="yes" |
isx86="yes" |
159 |
verbose="" |
verbose="" |
160 |
makedefault="" |
makedefault="" |
161 |
package="" |
package="" |
162 |
mbkernel="" |
mbkernel="${HYPERVISOR}" |
163 |
mbargs="" |
mbargs="${HYPERVISOR_ARGS}" |
164 |
adddracutargs="" |
adddracutargs="" |
165 |
addplymouthinitrd="" |
addplymouthinitrd="" |
166 |
|
|
178 |
exit 1 |
exit 1 |
179 |
} |
} |
180 |
|
|
|
run_grub2() |
|
|
{ |
|
|
if [ -d /boot/grub -a -x /sbin/grub-mkconfig ] |
|
|
then |
|
|
cp /boot/grub/grub.cfg /boot/grub/grub.cfg.old |
|
|
/sbin/grub-mkconfig -o /boot/grub/grub.cfg |
|
|
fi |
|
|
} |
|
|
|
|
181 |
install() |
install() |
182 |
{ |
{ |
183 |
# XXX kernel should be able to be specified also (or work right on ia64) |
# XXX kernel should be able to be specified also (or work right on ia64) |
215 |
return |
return |
216 |
fi |
fi |
217 |
|
|
|
# Run grub2's configuration update in parallel, if it is installed |
|
|
run_grub2 |
|
|
|
|
218 |
# get the root filesystem to use |
# get the root filesystem to use |
219 |
rootdevice=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $1; }}' /etc/fstab) |
rootdevice=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $1; }}' /etc/fstab) |
220 |
|
|
230 |
|
|
231 |
if [[ -n ${banner} ]] |
if [[ -n ${banner} ]] |
232 |
then |
then |
233 |
title="${banner} (${version})" |
title="${banner} [ ${version} ]" |
234 |
elif [ -f /etc/mageversion ] |
elif [ -f /etc/mageversion ] |
235 |
then |
then |
236 |
title="Magellan Linux $(< /etc/mageversion) (${version})" |
title="Magellan Linux $(< /etc/mageversion) [ ${version} ]" |
237 |
|
elif [[ $(read_os_release id) = magellan ]] |
238 |
|
then |
239 |
|
title="$(read_os_release name) $(read_os_release version_id) [ ${version} ]" |
240 |
else |
else |
241 |
title="Magellan Linux (${version})" |
title="Magellan Linux [ ${version} ]" |
242 |
fi |
fi |
243 |
${grubby} --add-kernel=${bootPrefix}/${kernelName}-${version} \ |
${grubby} --grub -c ${grubConfig} \ |
244 |
|
--add-kernel=${bootPrefix}/${kernelName}-${version} \ |
245 |
${INITRD} --copy-default ${makedefault} --title "${title}" \ |
${INITRD} --copy-default ${makedefault} --title "${title}" \ |
246 |
${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \ |
${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \ |
247 |
--args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}" |
--args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}" |
248 |
else |
else |
249 |
[[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby" |
[[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby for grub 0.97" |
250 |
|
fi |
251 |
|
if [[ -n ${cfgGrub2} ]] |
252 |
|
then |
253 |
|
[[ -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 |
fi |
301 |
|
|
302 |
if [[ -n ${cfgLilo} ]] |
if [[ -n ${cfgLilo} ]] |
322 |
else |
else |
323 |
[[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby" |
[[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby" |
324 |
fi |
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() |
359 |
return |
return |
360 |
fi |
fi |
361 |
|
|
|
# Run grub2's configuration update in parallel, if it is installed |
|
|
run_grub2 |
|
|
|
|
362 |
if [[ -n ${cfgGrub} ]] |
if [[ -n ${cfgGrub} ]] |
363 |
then |
then |
364 |
[[ -n ${verbose} ]] && echo "removing ${version} from ${grubConfig}" |
[[ -n ${verbose} ]] && echo "removing ${version} from ${grubConfig}" |
365 |
${grubby} --remove-kernel=${bootPrefix}/${kernelName}-${version} |
${grubby} --grub -c ${grubConfig} \ |
366 |
|
--remove-kernel=${bootPrefix}/${kernelName}-${version} |
367 |
else |
else |
368 |
[[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby" |
[[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby for grub 0.97" |
369 |
|
fi |
370 |
|
if [[ -n ${cfgGrub2} ]] |
371 |
|
then |
372 |
|
[[ -n ${verbose} ]] && echo "removing ${version} from ${grub2Config}" |
373 |
|
${grubby} --grub2 -c ${grub2Config} \ |
374 |
|
--remove-kernel=${bootPrefix}/${kernelName}-${version} |
375 |
|
else |
376 |
|
[[ -n ${verbose} ]] && echo "${grub2Config} does not exist, not running grubby for grub 2" |
377 |
|
fi |
378 |
|
if [[ -n ${cfgGrub2Efi} ]] |
379 |
|
then |
380 |
|
[[ -n ${verbose} ]] && echo "removing ${version} from ${grub2EfiConfig}" |
381 |
|
${grubby} --grub2 -c ${grub2EfiConfig} \ |
382 |
|
--remove-kernel=${bootPrefix}/${kernelName}-${version} |
383 |
|
else |
384 |
|
[[ -n ${verbose} ]] && echo "${grub2EfiConfig} does not exist, not running grubby grub 2 with UEFI" |
385 |
fi |
fi |
386 |
|
|
387 |
if [[ -n ${cfgLilo} ]] |
if [[ -n ${cfgLilo} ]] |
402 |
else |
else |
403 |
[[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby" |
[[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby" |
404 |
fi |
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() |
487 |
fi |
fi |
488 |
fi |
fi |
489 |
|
|
|
# Run grub2's configuration update in parallel, if it is installed |
|
|
run_grub2 |
|
|
|
|
490 |
if [[ -n ${cfgGrub} ]] |
if [[ -n ${cfgGrub} ]] |
491 |
then |
then |
492 |
[[ -n ${verbose} ]] && echo "updating ${version} from ${grubConfig}" |
[[ -n ${verbose} ]] && echo "updating ${version} from ${grubConfig}" |
493 |
${grubby} --update-kernel=${bootPrefix}/${kernelName}-${version} \ |
${grubby} --grub -c ${grubConfig} \ |
494 |
|
--update-kernel=${bootPrefix}/${kernelName}-${version} \ |
495 |
${INITRD} \ |
${INITRD} \ |
496 |
${kernargs:+--args="${kernargs}"} \ |
${kernargs:+--args="${kernargs}"} \ |
497 |
${removeargs:+--remove-args="${removeargs}"} |
${removeargs:+--remove-args="${removeargs}"} |
499 |
[[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby" |
[[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby" |
500 |
fi |
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} ]] |
if [[ -n ${cfgLilo} ]] |
527 |
then |
then |
528 |
[[ -n ${verbose} ]] && echo "updating ${version} from ${liloConfig}" |
[[ -n ${verbose} ]] && echo "updating ${version} from ${liloConfig}" |
545 |
else |
else |
546 |
[[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby" |
[[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby" |
547 |
fi |
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 |
{ |
{ |
597 |
if [[ -n ${dracut} ]] |
if [[ -n ${dracut} ]] |
598 |
then |
then |
599 |
tool="/sbin/dracut ${dracuthostonly} -f ${initrdfile} ${version}" |
tool="dracut ${dracuthostonly} -f ${initrdfile} ${version}" |
600 |
else |
else |
601 |
tool="/sbin/mkinitrd --allow-missing -f ${initrdfile} ${version}" |
tool="mkinitrd --allow-missing -f ${initrdfile} ${version}" |
602 |
fi |
fi |
603 |
[[ -n ${verbose} ]] && echo "creating initrd ${initrdfile} using ${version}" |
[[ -n ${verbose} ]] && echo "creating initrd ${initrdfile} using ${version}" |
604 |
${tool} |
${tool} |
839 |
|
|
840 |
if [[ ${initrd} = make ]] |
if [[ ${initrd} = make ]] |
841 |
then |
then |
842 |
mkinitrd |
makeinitrd |
843 |
elif [[ ${initrd} = remove ]] |
elif [[ ${initrd} = remove ]] |
844 |
then |
then |
845 |
rminitrd |
rminitrd |
852 |
fi |
fi |
853 |
|
|
854 |
[[ -n ${grubConfig} ]] && [ -f ${grubConfig} ] && cfgGrub=1 |
[[ -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 |
[[ -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 |
877 |
|
|
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 |
893 |
update |
update |
894 |
fi |
fi |
895 |
|
|
896 |
|
# if we mounted the U-Boot directory, unmount it. |
897 |
|
[[ -n ${mounted} ]] && umount ${ubootDir} |
898 |
|
|
899 |
exit 0 |
exit 0 |