Contents of /mage/branches/alx-0_6_0/include/alx.minc
Parent Directory | Revision Log
Revision 2067 -
(show annotations)
(download)
Wed May 11 21:16:12 2011 UTC (13 years, 4 months ago) by niro
File size: 2494 byte(s)
Wed May 11 21:16:12 2011 UTC (13 years, 4 months ago) by niro
File size: 2494 byte(s)
-renamed alx_grub_update_new() -> alx_grub_update() -added compat alx_grub_update_new() for later removal -deleted deprecated target_xxx() functions
1 | # alx specific functions |
2 | |
3 | add_conf_prot() |
4 | { |
5 | local i |
6 | |
7 | for i in $@ |
8 | do |
9 | export CONFIG_PROTECT="${CONFIG_PROTECT} ${i}" |
10 | done |
11 | } |
12 | |
13 | add_conf_prot_mask() |
14 | { |
15 | local i |
16 | |
17 | for i in $@ |
18 | do |
19 | export CONFIG_PROTECT_MASK="${CONFIG_PROTECT_MASK} ${i}" |
20 | done |
21 | } |
22 | |
23 | # updates /boot/grub/grub.conf with given params |
24 | # example: alx_grub_update kernel-image-name description |
25 | alx_grub_update() |
26 | { |
27 | local KERNEL_IMAGE |
28 | local KERNEL_DESCRIPTION |
29 | local i |
30 | local rootfs |
31 | local grubroot |
32 | local OLD_IFS |
33 | local grubconf="/boot/grub/grub.conf" |
34 | |
35 | KERNEL_IMAGE="$1" |
36 | KERNEL_DESCRIPTION="$2" |
37 | |
38 | # some checks |
39 | if [ -z "${KERNEL_IMAGE}" ] |
40 | then |
41 | echo "At least a kernel-image must be given" |
42 | return 1 |
43 | fi |
44 | |
45 | [ -z "${KERNEL_DESCRIPTION}" ] && KERNEL_DESCRIPTION="${KERNEL_IMAGE}" |
46 | |
47 | if [ ! -f ${grubconf} ] |
48 | then |
49 | echo "${grubconf} not found" |
50 | return 1 |
51 | fi |
52 | |
53 | # first of all get the first rootfs instance |
54 | for i in $(< ${grubconf}) |
55 | do |
56 | rootfs="$(echo ${i} | grep root=)" |
57 | [[ -n ${rootfs} ]] && break |
58 | done |
59 | |
60 | # then get the grub-root |
61 | OLD_IFS="$IFS" |
62 | IFS=$'\n' |
63 | for i in $(< ${grubconf}) |
64 | do |
65 | grubroot="$(echo ${i} | grep 'root (' | cut -d' ' -f2)" |
66 | [[ -n ${grubroot} ]] && break |
67 | done |
68 | IFS="${OLD_IFS}" |
69 | |
70 | # fix description |
71 | : > ${grubconf} |
72 | echo "default 0" >> ${grubconf} |
73 | echo "timeout 3" >> ${grubconf} |
74 | # using roots current password |
75 | echo "password --md5 $(cat /etc/shadow | grep root | cut -d: -f2)" >> ${grubconf} |
76 | echo >> ${grubconf} |
77 | acho "# normal boot" >> ${grubconf} |
78 | echo "title ${KERNEL_DESCRIPTION}" >> ${grubconf} |
79 | echo "root ${grubroot}" >> ${grubconf} |
80 | echo "kernel ${grubroot}/boot/${KERNEL_IMAGE} ${rootfs} quiet" >> ${grubconf} |
81 | echo >> ${grubconf} |
82 | echo "# admin boots" >> ${grubconf} |
83 | echo "title ${KERNEL_DESCRIPTION} - Re-run hardware-detection" >> ${grubconf} |
84 | echo "lock" >> ${grubconf} |
85 | echo "root ${grubroot}" >> ${grubconf} |
86 | echo "kernel ${grubroot}/boot/${KERNEL_IMAGE} ${rootfs} quiet hardware-auto-detection" >> ${grubconf} |
87 | echo >> ${grubconf} |
88 | echo "title ${KERNEL_DESCRIPTION} - Reset *all* local settings" >> ${grubconf} |
89 | echo "lock" >> ${grubconf} |
90 | echo "root ${grubroot}" >> ${grubconf} |
91 | echo "kernel ${grubroot}/boot/${KERNEL_IMAGE} ${rootfs} quiet alx-reset-settings" >> ${grubconf} |
92 | } |
93 | |
94 | ## compat |
95 | alx_grub_update_new() |
96 | { |
97 | echo -e "${COLYELLOW}alx_grub_update_new() is deprecated - please only use alx_grub_update() from now on${COLDEFAULT}" |
98 | alx_grub_update |
99 | echo -e "${COLYELLOW}alx_grub_update_new() is deprecated - please only use alx_grub_update() from now on${COLDEFAULT}" |
100 | } |