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 2562 by niro, Thu Jun 30 15:25:12 2011 UTC revision 2563 by niro, Mon Jul 4 20:10:20 2011 UTC
# Line 42  alx_grub_update() Line 42  alx_grub_update()
42   local grubopts   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   local pass
47    
48   KERNEL_IMAGE="$1"   KERNEL_IMAGE="$1"
# Line 56  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   fi   then
66     grub-mkdevicemap
67     fi
68    
69   # first of all get the first rootfs instance   # needed by grub-mkconfig on the first run
70   for i in $(< ${grubconf})   if [[ ! -f /boot/grub/video.lst ]]
71   do   then
72   rootfs="$(echo ${i} | grep root=)"   install -m0644 /$(mlibdir)/grub/*/video.lst /boot/grub/video.lst
73   [[ -n ${rootfs} ]] && break   fi
  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}"  
74    
75   # check for special hardware   # update grub.cfg
76   if [[ -x $(which hwinfo) ]]   LC_ALL=C grub-mkconfig -o ${grub2conf}
77   then  
78   # zotac devices   # install bootloader to disk
79   if [[ ! -z $(hwinfo --bios --storage | grep -i zotac) ]]   #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   then
91   grubopts="rootdelay=8"   echo "${grubconf} not found"
92   echo "Special device 'ZOTAC' detected!"   return 1
93   fi   fi
  fi  
94    
95   # fix description   # first of all get the first rootfs instance
96   : > ${grubconf}   for i in $(< ${grubconf})
97   echo "default 0" >> ${grubconf}   do
98   echo "timeout 3" >> ${grubconf}   rootfs="$(echo ${i} | grep root=)"
99   # using roots current password if one was set   [[ -n ${rootfs} ]] && break
100   pass="$(grep '^root:' /etc/shadow | cut -d: -f2)"   done
101   # or fallback to a default password  
102   [[ -z ${pass} ]] && pass="$1$oc/rCMuc$ZodLQSj6N5zYIJtOBg.RT/"   # then get the grub-root
103   echo "password --md5 ${pass}"  >> ${grubconf}   OLD_IFS="$IFS"
104   echo  >> ${grubconf}   IFS=$'\n'
105   echo "# normal boot" >> ${grubconf}   for i in $(< ${grubconf})
106   echo "title ${KERNEL_DESCRIPTION}" >> ${grubconf}   do
107   echo "root ${grubroot}" >> ${grubconf}   grubroot="$(echo ${i} | grep 'root (' | cut -d' ' -f2)"
108   echo "kernel ${grubroot}/boot/${KERNEL_IMAGE} ${rootfs} quiet ${grubopts}" >> ${grubconf}   [[ -n ${grubroot} ]] && break
109   echo >> ${grubconf}   done
110   echo "# admin boots" >> ${grubconf}   IFS="${OLD_IFS}"
111   echo "title ${KERNEL_DESCRIPTION} - Re-run hardware-detection" >> ${grubconf}  
112   echo "lock"  >> ${grubconf}   # check for special hardware
113   echo "root ${grubroot}" >> ${grubconf}   if [[ -x $(which hwinfo) ]]
114   echo "kernel ${grubroot}/boot/${KERNEL_IMAGE} ${rootfs} quiet ${grubopts} hardware-auto-detection" >> ${grubconf}   then
115   echo >> ${grubconf}   # zotac devices
116   echo "title ${KERNEL_DESCRIPTION} - Reset *all* local settings" >> ${grubconf}   if [[ ! -z $(hwinfo --bios --storage | grep -i zotac) ]]
117   echo "lock"  >> ${grubconf}   then
118   echo "root ${grubroot}" >> ${grubconf}   grubopts="rootdelay=8"
119   echo "kernel ${grubroot}/boot/${KERNEL_IMAGE} ${rootfs} quiet ${grubopts} alx-reset-settings" >> ${grubconf}   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
149  }  }
150    
151  ## compat  ## compat

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