Magellan Linux

Diff of /mage/branches/alx07x-unstable/include/alx.minc

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

mage/branches/alx-0_6_0/include/alx.minc revision 1921 by niro, Fri May 6 17:16:39 2011 UTC mage/branches/alx07x-unstable/include/alx.minc revision 7861 by niro, Wed Nov 18 09:35:23 2015 UTC
# Line 20  add_conf_prot_mask() Line 20  add_conf_prot_mask()
20   done   done
21  }  }
22    
23  # updates /boot/grub/grub.conf with given params  add_conf_prot_ignore()
 # example:   alx_grub_update kernel-image-name description  
 alx_grub_update()  
24  {  {
25   local KERNEL_IMAGE   local i
  local KERNEL_DESCRIPTION  
  local old_image  
   
  KERNEL_IMAGE="$1"  
  KERNEL_DESCRIPTION="$2"  
   
  # some checks  
  if [ -z "${KERNEL_IMAGE}" ]  
  then  
  echo "At least a kernel-image must be given"  
  return 1  
  fi  
   
  [ -z "${KERNEL_DESCRIPTION}" ] && KERNEL_DESCRIPTION="${KERNEL_IMAGE}"  
   
  if [ ! -f /boot/grub/grub.conf ]  
  then  
  echo "/boot/grub/grub.conf not found"  
  return 1  
  fi  
   
  # fix description  
  sed -i "s:^\(title=\).*:\1${KERNEL_DESCRIPTION}:" /boot/grub/grub.conf  
26    
27   # fix kernel image   for i in $@
28   old_image="$(basename $(cat /boot/grub/grub.conf|grep kernel |cut -d' ' -f2))"   do
29   sed -i "s:${old_image}:${KERNEL_IMAGE}:" /boot/grub/grub.conf   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_new()  alx_grub_update()
36  {  {
37   local KERNEL_IMAGE   local KERNEL_IMAGE
38   local KERNEL_DESCRIPTION   local KERNEL_DESCRIPTION
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 78  alx_grub_update_new() Line 57  alx_grub_update_new()
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   # first of all get the first rootfs instance   fi
68   for i in $(< ${grubconf})  
69   do   # needed by grub-mkconfig on the first run
70   rootfs="$(echo ${i} | grep root=)"   if [[ ! -f /boot/grub/video.lst ]]
71   [[ -n ${rootfs} ]] && break   then
72   done   install -m0644 /$(mlibdir)/grub/*/video.lst /boot/grub/video.lst
73     fi
74   # then get the grub-root  
75   OLD_IFS="$IFS"   # update grub.cfg
76   IFS=$'\n'   LC_ALL=C grub-mkconfig -o ${grub2conf}
77   for i in $(< ${grubconf})  
78   do   # install bootloader to disk
79   grubroot="$(echo ${i} | grep 'root (' | cut -d' ' -f2)"   #local bootpartition="$(df -h /boot |(read; awk '{print $1; exit}'))"
80   [[ -n ${grubroot} ]] && break   local bootdisk
81   done   bootdisk="$(grub-probe --target=drive /boot | sed 's:(\(.*\),.*):(\1):')"
82   IFS="${OLD_IFS}"  
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   # fix description   # first of all get the first rootfs instance
96   : > ${grubconf}   for i in $(< ${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}  
  acho "# 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}  
 }  
   
 # checks if compilation should be against alx  
 target_alx_dev()  
 {  
  local i  
   
  if [ -n "${MAGE_TARGETS}" ]  
  then  
  for i in ${MAGE_TARGETS}  
97   do   do
98   [[ ${i} = -alx_dev ]] && return 0   rootfs="$(echo ${i} | grep root=)"
99     [[ -n ${rootfs} ]] && break
  # alx-dev will always build when building target alx,  
  # so target alx ist also allowed to be alx-dev  
  [[ ${i} = -alx ]] && return 0  
100   done   done
  fi  
   
  # nothing match, we are *not* on alx linux  
  return 1  
 }  
101    
102  # check if compilation should be against stripped down alx for livecds   # then get the grub-root
103  target_alx_livecd()   OLD_IFS="$IFS"
104  {   IFS=$'\n'
105   if [ -n "${MAGE_TARGETS}" ]   for i in $(< ${grubconf})
  then  
  for i in ${MAGE_TARGETS}  
106   do   do
107   [[ ${i} = alx_livecd ]] && return 0   grubroot="$(echo ${i} | grep 'root (' | cut -d' ' -f2)"
108     [[ -n ${grubroot} ]] && break
109   done   done
110   fi   IFS="${OLD_IFS}"
111    
112   # nothing match, we are *not* on alx linux   # check for special hardware
113   return 1   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
149  }  }
150    
151  # check if compilation should be against stripped down alx  ## compat
152  target_alx()  alx_grub_update_new()
153  {  {
154   if [ -n "${MAGE_TARGETS}" ]   echo -e "${COLYELLOW}alx_grub_update_new() is deprecated - please only use alx_grub_update() from now on${COLDEFAULT}"
155   then   alx_grub_update
156   for i in ${MAGE_TARGETS}   echo -e "${COLYELLOW}alx_grub_update_new() is deprecated - please only use alx_grub_update() from now on${COLDEFAULT}"
  do  
  [[ ${i} = -alx ]] && return 0  
  done  
  fi  
   
  # nothing match, we are *not* on alx linux  
  return 1  
157  }  }

Legend:
Removed from v.1921  
changed lines
  Added in v.7861