Magellan Linux

Annotation of /mage/branches/alx-0_6_0/include/alx.minc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2092 - (hide annotations) (download)
Thu May 12 00:57:40 2011 UTC (13 years ago) by niro
File size: 2618 byte(s)
-added add_conf_prot_ignore() function
1 niro 1921 # 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 niro 2092 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 niro 1921 # 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 OLD_IFS
43     local grubconf="/boot/grub/grub.conf"
44    
45     KERNEL_IMAGE="$1"
46     KERNEL_DESCRIPTION="$2"
47    
48     # some checks
49     if [ -z "${KERNEL_IMAGE}" ]
50     then
51     echo "At least a kernel-image must be given"
52     return 1
53     fi
54    
55     [ -z "${KERNEL_DESCRIPTION}" ] && KERNEL_DESCRIPTION="${KERNEL_IMAGE}"
56    
57     if [ ! -f ${grubconf} ]
58     then
59     echo "${grubconf} not found"
60     return 1
61     fi
62    
63     # first of all get the first rootfs instance
64     for i in $(< ${grubconf})
65     do
66     rootfs="$(echo ${i} | grep root=)"
67     [[ -n ${rootfs} ]] && break
68     done
69    
70     # then get the grub-root
71     OLD_IFS="$IFS"
72     IFS=$'\n'
73     for i in $(< ${grubconf})
74     do
75     grubroot="$(echo ${i} | grep 'root (' | cut -d' ' -f2)"
76     [[ -n ${grubroot} ]] && break
77     done
78     IFS="${OLD_IFS}"
79    
80     # fix description
81     : > ${grubconf}
82     echo "default 0" >> ${grubconf}
83     echo "timeout 3" >> ${grubconf}
84     # using roots current password
85     echo "password --md5 $(cat /etc/shadow | grep root | cut -d: -f2)" >> ${grubconf}
86     echo >> ${grubconf}
87 niro 2080 echo "# normal boot" >> ${grubconf}
88 niro 1921 echo "title ${KERNEL_DESCRIPTION}" >> ${grubconf}
89     echo "root ${grubroot}" >> ${grubconf}
90     echo "kernel ${grubroot}/boot/${KERNEL_IMAGE} ${rootfs} quiet" >> ${grubconf}
91     echo >> ${grubconf}
92     echo "# admin boots" >> ${grubconf}
93     echo "title ${KERNEL_DESCRIPTION} - Re-run hardware-detection" >> ${grubconf}
94     echo "lock" >> ${grubconf}
95     echo "root ${grubroot}" >> ${grubconf}
96     echo "kernel ${grubroot}/boot/${KERNEL_IMAGE} ${rootfs} quiet hardware-auto-detection" >> ${grubconf}
97     echo >> ${grubconf}
98     echo "title ${KERNEL_DESCRIPTION} - Reset *all* local settings" >> ${grubconf}
99     echo "lock" >> ${grubconf}
100     echo "root ${grubroot}" >> ${grubconf}
101     echo "kernel ${grubroot}/boot/${KERNEL_IMAGE} ${rootfs} quiet alx-reset-settings" >> ${grubconf}
102     }
103    
104 niro 2067 ## compat
105     alx_grub_update_new()
106 niro 1921 {
107 niro 2067 echo -e "${COLYELLOW}alx_grub_update_new() is deprecated - please only use alx_grub_update() from now on${COLDEFAULT}"
108     alx_grub_update
109     echo -e "${COLYELLOW}alx_grub_update_new() is deprecated - please only use alx_grub_update() from now on${COLDEFAULT}"
110 niro 1921 }