Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2080 by niro, Wed May 11 21:49:26 2011 UTC revision 2563 by niro, Mon Jul 4 20:10:20 2011 UTC
# Line 20  add_conf_prot_mask() Line 20  add_conf_prot_mask()
20   done   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  # updates /boot/grub/grub.conf with given params
34  # example:   alx_grub_update kernel-image-name description  # example:   alx_grub_update kernel-image-name description
35  alx_grub_update()  alx_grub_update()
# Line 29  alx_grub_update() Line 39  alx_grub_update()
39   local i   local i
40   local rootfs   local rootfs
41   local grubroot   local grubroot
42     local grubopts
43   local OLD_IFS   local OLD_IFS
44   local grubconf="/boot/grub/grub.conf"   local grubconf="/boot/grub/grub.conf"
45     local grub2conf="/boot/grub/grub.cfg"
46     local pass
47    
48   KERNEL_IMAGE="$1"   KERNEL_IMAGE="$1"
49   KERNEL_DESCRIPTION="$2"   KERNEL_DESCRIPTION="$2"
# Line 44  alx_grub_update() Line 57  alx_grub_update()
57    
58   [ -z "${KERNEL_DESCRIPTION}" ] && KERNEL_DESCRIPTION="${KERNEL_IMAGE}"   [ -z "${KERNEL_DESCRIPTION}" ] && KERNEL_DESCRIPTION="${KERNEL_IMAGE}"
59    
60   if [ ! -f ${grubconf} ]   # grub2
61     if [[ -x /sbin/grub-mkconfig ]]
62   then   then
63   echo "${grubconf} not found"   # create a device.map
64   return 1   if [[ ! -f /boot/grub/device.map ]]
65     then
66     grub-mkdevicemap
67     fi
68    
69     # needed by grub-mkconfig on the first run
70     if [[ ! -f /boot/grub/video.lst ]]
71     then
72     install -m0644 /$(mlibdir)/grub/*/video.lst /boot/grub/video.lst
73     fi
74    
75     # update grub.cfg
76     LC_ALL=C grub-mkconfig -o ${grub2conf}
77    
78     # install bootloader to disk
79     #local bootpartition="$(df -h /boot |(read; awk '{print $1; exit}'))"
80     local bootdisk
81     bootdisk="$(grub-probe --target=drive /boot | sed 's:(\(.*\),.*):(\1):')"
82    
83     # Generate core.img, but don't let it be installed in boot sector
84     grub-install --no-floppy "${bootdisk}"
85    
86     # grub legacy
87     else
88    
89     if [ ! -f ${grubconf} ]
90     then
91     echo "${grubconf} not found"
92     return 1
93     fi
94    
95     # first of all get the first rootfs instance
96     for i in $(< ${grubconf})
97     do
98     rootfs="$(echo ${i} | grep root=)"
99     [[ -n ${rootfs} ]] && break
100     done
101    
102     # then get the grub-root
103     OLD_IFS="$IFS"
104     IFS=$'\n'
105     for i in $(< ${grubconf})
106     do
107     grubroot="$(echo ${i} | grep 'root (' | cut -d' ' -f2)"
108     [[ -n ${grubroot} ]] && break
109     done
110     IFS="${OLD_IFS}"
111    
112     # check for special hardware
113     if [[ -x $(which hwinfo) ]]
114     then
115     # zotac devices
116     if [[ ! -z $(hwinfo --bios --storage | grep -i zotac) ]]
117     then
118     grubopts="rootdelay=8"
119     echo "Special device 'ZOTAC' detected!"
120     fi
121     fi
122    
123     # fix description
124     : > ${grubconf}
125     echo "default 0" >> ${grubconf}
126     echo "timeout 3" >> ${grubconf}
127     # using roots current password if one was set
128     pass="$(grep '^root:' /etc/shadow | cut -d: -f2)"
129     # or fallback to a default password
130     [[ -z ${pass} ]] && pass="$1$oc/rCMuc$ZodLQSj6N5zYIJtOBg.RT/"
131     echo "password --md5 ${pass}"  >> ${grubconf}
132     echo  >> ${grubconf}
133     echo "# normal boot" >> ${grubconf}
134     echo "title ${KERNEL_DESCRIPTION}" >> ${grubconf}
135     echo "root ${grubroot}" >> ${grubconf}
136     echo "kernel ${grubroot}/boot/${KERNEL_IMAGE} ${rootfs} quiet ${grubopts}" >> ${grubconf}
137     echo >> ${grubconf}
138     echo "# admin boots" >> ${grubconf}
139     echo "title ${KERNEL_DESCRIPTION} - Re-run hardware-detection" >> ${grubconf}
140     echo "lock"  >> ${grubconf}
141     echo "root ${grubroot}" >> ${grubconf}
142     echo "kernel ${grubroot}/boot/${KERNEL_IMAGE} ${rootfs} quiet ${grubopts} hardware-auto-detection" >> ${grubconf}
143     echo >> ${grubconf}
144     echo "title ${KERNEL_DESCRIPTION} - Reset *all* local settings" >> ${grubconf}
145     echo "lock"  >> ${grubconf}
146     echo "root ${grubroot}" >> ${grubconf}
147     echo "kernel ${grubroot}/boot/${KERNEL_IMAGE} ${rootfs} quiet ${grubopts} alx-reset-settings" >> ${grubconf}
148   fi   fi
   
  # first of all get the first rootfs instance  
  for i in $(< ${grubconf})  
  do  
  rootfs="$(echo ${i} | grep root=)"  
  [[ -n ${rootfs} ]] && break  
  done  
   
  # then get the grub-root  
  OLD_IFS="$IFS"  
  IFS=$'\n'  
  for i in $(< ${grubconf})  
  do  
  grubroot="$(echo ${i} | grep 'root (' | cut -d' ' -f2)"  
  [[ -n ${grubroot} ]] && break  
  done  
  IFS="${OLD_IFS}"  
   
  # fix description  
  : > ${grubconf}  
  echo "default 0" >> ${grubconf}  
  echo "timeout 3" >> ${grubconf}  
  # using roots current password  
  echo "password --md5 $(cat /etc/shadow | grep root | cut -d: -f2)"  >> ${grubconf}  
  echo  >> ${grubconf}  
  echo "# normal boot" >> ${grubconf}  
  echo "title ${KERNEL_DESCRIPTION}" >> ${grubconf}  
  echo "root ${grubroot}" >> ${grubconf}  
  echo "kernel ${grubroot}/boot/${KERNEL_IMAGE} ${rootfs} quiet" >> ${grubconf}  
  echo >> ${grubconf}  
  echo "# admin boots" >> ${grubconf}  
  echo "title ${KERNEL_DESCRIPTION} - Re-run hardware-detection" >> ${grubconf}  
  echo "lock"  >> ${grubconf}  
  echo "root ${grubroot}" >> ${grubconf}  
  echo "kernel ${grubroot}/boot/${KERNEL_IMAGE} ${rootfs} quiet hardware-auto-detection" >> ${grubconf}  
  echo >> ${grubconf}  
  echo "title ${KERNEL_DESCRIPTION} - Reset *all* local settings" >> ${grubconf}  
  echo "lock"  >> ${grubconf}  
  echo "root ${grubroot}" >> ${grubconf}  
  echo "kernel ${grubroot}/boot/${KERNEL_IMAGE} ${rootfs} quiet alx-reset-settings" >> ${grubconf}  
149  }  }
150    
151  ## compat  ## compat

Legend:
Removed from v.2080  
changed lines
  Added in v.2563