Contents of /mage/branches/alx-0_6_0/include/alx.minc
Parent Directory | Revision Log
Revision 2200 -
(show annotations)
(download)
Wed Jun 8 08:23:38 2011 UTC (13 years, 3 months ago) by niro
File size: 2888 byte(s)
Wed Jun 8 08:23:38 2011 UTC (13 years, 3 months ago) by niro
File size: 2888 byte(s)
-fixe bootopts of zotac clients
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 | add_conf_prot_ignore() |
24 | { |
25 | local i |
26 | |
27 | for i in $@ |
28 | do |
29 | export CONFIG_PROTECT_IGNORE="${CONFIG_PROTECT_IGNORE} ${i}" |
30 | done |
31 | } |
32 | |
33 | # updates /boot/grub/grub.conf with given params |
34 | # example: alx_grub_update kernel-image-name description |
35 | alx_grub_update() |
36 | { |
37 | local KERNEL_IMAGE |
38 | local KERNEL_DESCRIPTION |
39 | local i |
40 | local rootfs |
41 | local grubroot |
42 | local grubopts |
43 | local OLD_IFS |
44 | local grubconf="/boot/grub/grub.conf" |
45 | |
46 | KERNEL_IMAGE="$1" |
47 | KERNEL_DESCRIPTION="$2" |
48 | |
49 | # some checks |
50 | if [ -z "${KERNEL_IMAGE}" ] |
51 | then |
52 | echo "At least a kernel-image must be given" |
53 | return 1 |
54 | fi |
55 | |
56 | [ -z "${KERNEL_DESCRIPTION}" ] && KERNEL_DESCRIPTION="${KERNEL_IMAGE}" |
57 | |
58 | if [ ! -f ${grubconf} ] |
59 | then |
60 | echo "${grubconf} not found" |
61 | return 1 |
62 | fi |
63 | |
64 | # first of all get the first rootfs instance |
65 | for i in $(< ${grubconf}) |
66 | do |
67 | rootfs="$(echo ${i} | grep root=)" |
68 | [[ -n ${rootfs} ]] && break |
69 | done |
70 | |
71 | # then get the grub-root |
72 | OLD_IFS="$IFS" |
73 | IFS=$'\n' |
74 | for i in $(< ${grubconf}) |
75 | do |
76 | grubroot="$(echo ${i} | grep 'root (' | cut -d' ' -f2)" |
77 | [[ -n ${grubroot} ]] && break |
78 | done |
79 | IFS="${OLD_IFS}" |
80 | |
81 | # check for special hardware |
82 | if [[ -x $(which hwinfo) ]] |
83 | then |
84 | # zotac devices |
85 | if [[ ! -z $(hwinfo --bios | grep -i zotac) ]] |
86 | then |
87 | grubopts="rootdelay=8" |
88 | echo "Special device 'ZOTAC' detected!" |
89 | fi |
90 | fi |
91 | |
92 | # fix description |
93 | : > ${grubconf} |
94 | echo "default 0" >> ${grubconf} |
95 | echo "timeout 3" >> ${grubconf} |
96 | # using roots current password |
97 | echo "password --md5 $(cat /etc/shadow | grep root | cut -d: -f2)" >> ${grubconf} |
98 | echo >> ${grubconf} |
99 | echo "# normal boot" >> ${grubconf} |
100 | echo "title ${KERNEL_DESCRIPTION}" >> ${grubconf} |
101 | echo "root ${grubroot}" >> ${grubconf} |
102 | echo "kernel ${grubroot}/boot/${KERNEL_IMAGE} ${rootfs} quiet ${grubopts}" >> ${grubconf} |
103 | echo >> ${grubconf} |
104 | echo "# admin boots" >> ${grubconf} |
105 | echo "title ${KERNEL_DESCRIPTION} - Re-run hardware-detection" >> ${grubconf} |
106 | echo "lock" >> ${grubconf} |
107 | echo "root ${grubroot}" >> ${grubconf} |
108 | echo "kernel ${grubroot}/boot/${KERNEL_IMAGE} ${rootfs} quiet ${grubopts} hardware-auto-detection" >> ${grubconf} |
109 | echo >> ${grubconf} |
110 | echo "title ${KERNEL_DESCRIPTION} - Reset *all* local settings" >> ${grubconf} |
111 | echo "lock" >> ${grubconf} |
112 | echo "root ${grubroot}" >> ${grubconf} |
113 | echo "kernel ${grubroot}/boot/${KERNEL_IMAGE} ${rootfs} quiet ${grubopts} alx-reset-settings" >> ${grubconf} |
114 | } |
115 | |
116 | ## compat |
117 | alx_grub_update_new() |
118 | { |
119 | echo -e "${COLYELLOW}alx_grub_update_new() is deprecated - please only use alx_grub_update() from now on${COLDEFAULT}" |
120 | alx_grub_update |
121 | echo -e "${COLYELLOW}alx_grub_update_new() is deprecated - please only use alx_grub_update() from now on${COLDEFAULT}" |
122 | } |