Magellan Linux

Diff of /trunk/installer-simple/bin/installer.sh.in

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

revision 2430 by niro, Tue Jan 7 14:14:23 2014 UTC revision 2883 by niro, Fri Jul 31 09:42:12 2015 UTC
# Line 7  Line 7 
7  # Niels Rogalla <niro@magellan-linux.de>  # Niels Rogalla <niro@magellan-linux.de>
8  #  #
9    
10  # ignore the environment  # setup locales
11  LC_ALL=C  TEXTDOMAIN=installer
12    
13  # include dir  # include dir
14  INSTALLER_LIBDIR="%LIBDIR%"  INSTALLER_LIBDIR="%LIBDIR%"
15    
# Line 39  do Line 40  do
40   fi   fi
41  done  done
42    
 # TOTALLINES=linecount of ${CDIMAGENAME}-tarball -1 !  
 # -> now in images.conf  
 CDIMAGENAME=""  
 TOTALLINES=""  
 CURRENTLINE=0  
 if [ -e /mnt/cdrom/system/images.conf ]  
 then  
  source /mnt/cdrom/system/images.conf  
  # check if all required variables are set  
  [[ -z ${CDIMAGENAME} ]] && die "CDIMAGENAME is empty in /mnt/cdrom/system/images.conf"  
  [[ -z ${TOTALLINES} ]] && die "TOTALLINES is empty in /mnt/cdrom/system/images.conf"  
 else  
  die "/mnt/cdrom/system/images.conf not found"  
 fi  
   
43  ### System/Config Version  ### System/Config Version
44  VERSION="%VERSIONTAG%"  VERSION="%VERSIONTAG%"
45  TITLE="${DEFAULT_TITLE} - ${VERSION}"  TITLE="${DEFAULT_TITLE} - ${VERSION}"
46    
47  # some sane defaults  # some sane defaults
48  CDROOT="${DEFAULT_CDROOT}"  LIVEROOT="${DEFAULT_LIVEROOT}"
49    IMAGEROOT="${DEFAULT_IMAGEROOT}"
50  INSTALLROOT="${DEFAULT_INSTALLROOT}"  INSTALLROOT="${DEFAULT_INSTALLROOT}"
51  KERNELPKG="${DEFAULT_KERNELPKG}"  KERNELPKG="${DEFAULT_KERNELPKG}"
52  KERNELOPTS="${DEFAULT_KERNELOPTS}"  KERNELOPTS="${DEFAULT_KERNELOPTS}"
# Line 70  SPECIALDEVICE="" Line 57  SPECIALDEVICE=""
57  FORMFACTOR="${DEFAULT_FORMFACTOR}"  FORMFACTOR="${DEFAULT_FORMFACTOR}"
58  FORMAT_FILESYSTEM="${DEFAULT_FILESYSTEM}"  FORMAT_FILESYSTEM="${DEFAULT_FILESYSTEM}"
59    
60  #################################################  # TOTALLINES=linecount of ${CDIMAGENAME}-tarball -1 !
61  #  DIALOG BOXEN #  # -> now in images.conf
62  #################################################  CDIMAGENAME=""
63    TOTALLINES=""
64    CURRENTLINE=0
65    if [ -e ${IMAGEROOT}/images.conf ]
66    then
67     source ${IMAGEROOT}/images.conf
68     # check if all required variables are set
69     [[ -z ${CDIMAGENAME} ]] && die "CDIMAGENAME is empty in ${IMAGEROOT}/images.conf"
70     [[ -z ${TOTALLINES} ]] && die "TOTALLINES is empty in ${IMAGEROOT}/images.conf"
71    else
72     die "${IMAGEROOT}/images.conf not found"
73    fi
74    
75    ### helper scripts ###
76    
77  trap_exit()  trap_exit()
78  {  {
# Line 86  trap_exit() Line 86  trap_exit()
86   exit 1   exit 1
87  }  }
88    
89  dialog_die()  install_meter()
90  {  {
91   ERROR="$1"   while [[ ${CURRENTLINE} != ${TOTALLINES} ]]
92   RETVAL="$?"   do
93   dialog_install_failure   CURRENTLINE=$(grep -c . /tmp/install.log)
94   exit 1   PERCENT=$(( ${CURRENTLINE} * 100 / ${TOTALLINES}))
95     echo ${PERCENT}
96     sleep 1
97     done
98     rm -f /tmp/install.log
99     return 0
100  }  }
101    
102  dialog_warning()  install_mount_rootfs()
103  {  {
104   local retval   local opts
105    
106   yesnobox $"\Z1 !!! Warning !!! \Zn\n\n\This harddrive will be irreversibly erased.\n\n\Do you want to continue ?"   if [[ -n ${SWAPHDD} ]]
  retval=$?  
  if [[ ${retval} -eq 1 ]]  
107   then   then
108   clear   swapon ${SWAPHDD} || die
109   echo $"The process was aborted."   fi
110   exit 1   if [[ -n ${ROOTHDD} ]]
111     then
112     mount -t ${FORMAT_FILESYSTEM_ROOTHDD} ${ROOTHDD} ${INSTALL_ROOT} || die
113     fi
114     if [[ -n ${BOOTHDD} ]]
115     then
116     install -d ${INSTALL_ROOT}/boot || die
117     mount -t ${FORMAT_FILESYSTEM_BOOTHDD} ${BOOTHDD} ${INSTALL_ROOT}/boot || die
118   fi   fi
 }  
   
 dialog_setup_hdd_info()  
 {  
  local SHDD="${HDD//\/dev\/}"  
119    
120   messagebox -h $"[ Harddrive partitioning ]" \   cd ${INSTALL_ROOT} || die
  $"\nPlease create 1 partition.\n\n\[ \Z3${SHDD}1\Zn ] type: \Z3linux\Zn with the whole diskspace\n\Please mark ${SHDD}1 \Z3bootable\Zn."  
121  }  }
122    
 dialog_setup_hdd_info_auto()  
 {  
  local SHDD="${HDD//\/dev\/}"  
   
  messagebox -h $"[ Harddrive partitioning ]" \  
  $"\Z1Warning!\Zn\n\nAll data on disk [ \Z3${HDD}\Zn ] will be erased!"  
 }  
123    
124  dialog_setup_system_menu()  mount_rootfs()
125  {  {
  local mode  
126   local retval   local retval
127    
128   mode=$(menubox -h $"[ Harddrive partitioning ]" $"\nSelect an installation mode" \   if [[ -n ${SWAPHDD} ]]
  $"1:Automatic setup (recommended)" \  
  ":" \  
  $":\Z1Expert modes:\Zn" \  
  $"2:Common IDE-disk (manual setup)")  
  retval=$?  
  [[ ${retval} -eq 1 ]] && return 1  
  if [[ ${retval} -eq 0 ]]  
129   then   then
130   case "${mode}" in   swapon ${SWAPHDD} || dialog_die $"Could not enable swap space '${SWAPHDD}'"
  "1") run_install_auto ;;  
  "2") run_install_normal ;;  
  "") dialog_setup_system_menu;;  
  esac  
131   fi   fi
 }  
132    
133  dialog_hardware_detection()   if [[ -n ${ROOTHDD} ]]
 {  
  local message  
   
  run_hardware_detection_disks  
   
  message+=$"Harddrives:\n"  
   
  if [[ ! -z ${ALL_DISKS} ]]  
  then  
  for i in ${ALL_DISKS}  
  do  
  message+="\Z3${i}\Zn "  
  done  
  message+="\n"  
  fi  
   
  if [[ ! -z ${ALL_CDROMS} ]]  
134   then   then
135   message+="\n"   if is_mounted --location "${INSTALLROOT}"
136   message+=$"Optical disk drives:\n"   then
137   for i in ${ALL_CDROMS}   echo $"${INSTALLROOT} already mounted" >&2
138   do   else
139   message+="\Z3${i}\Zn"   mount "${ROOTHDD}" "${INSTALLROOT}" || dialog_die $"Could not mount rootfs - drive '${ROOTHDD}' -> '${INSTALLROOT}'"
140   done   fi
  message+="\n"  
  fi  
   
  # other devices  
  run_hardware_detection  
  case "${SPECIALDEVICE}" in  
  zotac*) message+=$"\n\Z2Zotac device detected.\Zn" ;;  
  rangee) message+=$"\n\Z2Rangee device detected.\Zn" ;;  
  maxdata) message+=$"\n\Z2Maxdata device detected.\Zn" ;;  
  *) message+=$"\n \\ZnCommon device detected.\Zn" ;;  
  esac  
  if [[ ${FORMFACTOR} = laptop ]]  
  then  
  message+=$"\n\ZnFormfactor Laptop, activating 'ondemand' powersaving  mode.\Zn"  
141   fi   fi
142    
143   messagebox -y 15 -h $"Detected hardware:" "${message}"   [[ -d ${INSTALLROOT}/boot ]] || install -d ${INSTALLROOT}/boot
 }  
144    
145  dialog_setup_hdd_partitions_manual()   if [[ -n ${BOOTHDD} ]]
 {  
  local i  
  local retval  
   
  if [[ -z ${ALL_DISKS} ]]  
146   then   then
147   dialog_no_harddrive_found   if is_mounted --location "${INSTALLROOT}"/boot
  exit 1  
  else  
  HDD=$(dialog_select_target_harddrive)  
  retval=$?  
  [[ ${retval} -eq 1 ]] && return 1  
  if [[ ${retval} -eq 0 ]]  
148   then   then
149   dialog_setup_hdd_info   echo $"${INSTALLROOT}/boot already mounted" >&2
150   setup_hdd_partitions_manual   else
151     mount "${BOOTHDD}" "${INSTALLROOT}"/boot || dialog_die $"Could not mount bootfs - drive '${BOOTHDD}' -> '${INSTALLROOT}/boot'"
152   fi   fi
153   fi   fi
154  }  }
155    
156  dialog_setup_hdd_partitions_auto()  umount_rootfs()
157  {  {
158   local i   is_mounted --location ${INSTALLROOT}/boot && umount ${INSTALLROOT}/boot
159   local retval   is_mounted --location ${INSTALLROOT} && umount ${INSTALLROOT}
160    
161   if [[ -z ${ALL_DISKS} ]]   if [[ -n ${SWAPHDD} ]]
162   then   then
163   dialog_no_harddrive_found   swapoff ${SWAPHDD} || die
  exit 1  
  else  
  HDD=$(dialog_select_target_harddrive)  
  retval=$?  
  [[ ${retval} -eq 1 ]] && return 1  
  if [[ ${retval} -eq 0 ]]  
  then  
  dialog_setup_hdd_info_auto  
  dialog_setup_hdd_create_partitions  
  setup_hdd_partitions_auto  
  fi  
164   fi   fi
165  }  }
166    
167  install_meter()  install_do_reboot()
 {  
  while [[ ${CURRENTLINE} != ${TOTALLINES} ]]  
  do  
  CURRENTLINE=$(grep -c . /tmp/install.log)  
  PERCENT=$(( ${CURRENTLINE} * 100 / ${TOTALLINES}))  
  echo ${PERCENT}  
  sleep 1  
  done  
  rm -f /tmp/install.log  
  return 0  
 }  
   
 dialog_main()  
168  {  {
169   local method=0   reboot
  local retval  
   
  while [[ ${method} -le 2 ]]  
  do  
  method=$(menubox $"Configuration:" \  
  $"1:Install system" \  
  $"2:Show detected harddrives" \  
  $"3:Exit and reboot" \  
  $"4:Exit and drop into a shell")  
  retval=$?  
  [[ ${retval} -eq 1 ]] && exit 1  
  if [[ ${retval} -eq 0 ]]  
  then  
  case ${method} in  
  "1") dialog_setup_system_menu ;;  
  "2") dialog_hardware_detection ;;  
  "3") install_do_reboot ;;  
  "4") /bin/bash --login -i ;;  
  esac  
  fi  
  done  
170  }  }
171    
 #################################################  
 # Install Komandos #  
 #################################################  
172  run_hardware_detection()  run_hardware_detection()
173  {  {
174   local hwinfo   local hwinfo
175    
176   hwinfo="$(hwinfo --bios --storage --pci --gfxcard --sys)"   hwinfo="$(hwinfo --bios --storage --pci --gfxcard --sys)"
177    
178   ## check for special devices/clients:   # check for special devices/clients:
179   ## if zotac a zotac and the disk is a removeable device, then add rootdelay to kernelcmd   # if zotac a zotac and the disk is a removeable device, then add rootdelay to kernelcmd
180   #local removable=0   local removable=0
181   #if [[ ! -z $(echo "${hwinfo}" | grep -i zotac) ]]   if [[ ! -z $(echo "${hwinfo}" | grep -i zotac) ]]
182   #then   then
183   #for i in /sys/block/[hs]d*/removable   #for i in /sys/block/[hs]d*/removable
184   #do   #do
185   #if [[ $(< ${i}) = 1 ]]   # if [[ $(< ${i}) = 1 ]]
186   #then   # then
187   #removable=1   # removable=1
188   #fi   # fi
189   #done   #done
190     # smartcard = udevadm info -n /dev/sda -a | grep -i 'configuration.*card'
191    
192   ## only add this for grub legacy, grub2 detect these settings on its own   # only add this for grub legacy, grub2 detect these settings on its own
193   #export GRUBLEGACYOPTS="rootdelay=8"   export GRUBLEGACYOPTS="rootdelay=8"
194   ## there are to zotac types in the wild, nvidia based gfx and intel   # there are to zotac types in the wild, nvidia based gfx and intel
195   #if [[ ! -z $(echo "${hwinfo}" | grep -i nouveau) ]]   if [[ ! -z $(echo "${hwinfo}" | grep -i nouveau) ]]
196   #then   then
197   #export SPECIALDEVICE="zotac_nvidia"   export SPECIALDEVICE="zotac_nvidia"
198   #else   else
199   #export SPECIALDEVICE="zotac_intel"   export SPECIALDEVICE="zotac_intel"
200   #fi   fi
201   #fi   fi
202    
203   # check for special devices/clients:   # check for special devices/clients:
204   # if a rangee and disk ist smaller then 256mb move partion one block further ahead   # if a rangee and disk ist smaller then 256mb move partion one block further ahead
# Line 339  run_hardware_detection_disks() Line 234  run_hardware_detection_disks()
234   # all disks but exclude ramdisks   # all disks but exclude ramdisks
235   export ALL_DISKS=$(get_hwinfo disk | sed '/\/dev\/ram[0-9].*/d')   export ALL_DISKS=$(get_hwinfo disk | sed '/\/dev\/ram[0-9].*/d')
236   # remove the boot device from ALL_DISKS if it was an usbstick   # remove the boot device from ALL_DISKS if it was an usbstick
237   if [[ $(grep '[[:space:]]/mnt/cdrom[[:space:]]' /proc/mounts | cut -d' ' -f3) != iso9660 ]]   if [[ $(grep '[[:space:]]${LIVEROOT}[[:space:]]' /proc/mounts | cut -d' ' -f3) != iso9660 ]]
238   then   then
239   bootdev="$(grep '[[:space:]]/mnt/cdrom[[:space:]]' /proc/mounts | cut -d' ' -f1 | sed 's:[0-9]::g')"   bootdev=$(grep "[[:space:]]${LIVEROOT}[[:space:]]" /proc/mounts | cut -d' ' -f1 | sed 's:[0-9]::g')
240   export ALL_DISKS=$(echo "${ALL_DISKS}" | grep -v "${bootdev}")   export ALL_DISKS=$(echo "${ALL_DISKS}" | grep -v "${bootdev}")
241   fi   fi
242   export ALL_CDROMS="$(get_hwinfo cdrom)"   export ALL_CDROMS="$(get_hwinfo cdrom)"
243  }  }
244    
245  hdd_size_below_256mb()  setup_hdd_partitions()
246  {  {
247   local hdd="$1"   case "${INSTALL_METHOD}" in
248   local size   auto)
249   local retval   BOOTHDD=""
250   [[ -z ${hdd} ]] && dialog_die "Error: get_hdd_size() no \$hdd given!"   SWAPHDD=""
251     ROOTHDD="${HDD}1"
252     ;;
253     normal)
254     BOOTHDD="${HDD}1"
255     SWAPHDD="${HDD}2"
256     ROOTHDD="${HDD}3"
257     ;;
258     esac
259    
260   size=$(fdisk -l ${hdd} | grep "Disk.*${hdd}" | sed 's:.*,\ \(.*\)\ byte.*:\1:')   # sanity check - should not happen
261   if [[ ${size} -le 257000000 ]]   if is_mounted --device "${ROOTHDD}"
262   then   then
263   retval="0"   echo "partition: device ${ROOTHDD} is already mounted, umount it" >&2
264   else   umount "${ROOTHDD}"
  retval="1"  
265   fi   fi
266     if [[ -n ${BOOTHDD} ]]
  return "${retval}"  
 }  
   
 setup_hdd_partitions_auto()  
 {  
  ROOTHDD="${HDD}1"  
   
  # run this only if FDISKPARTITIONBELOW256MB is not already 1  
  if [[ ${FDISKPARTIONBELOW256MB} != 1 ]]  
267   then   then
268   if hdd_size_below_256mb ${HDD}   if is_mounted --device "${BOOTHDD}"
269   then   then
270   FDISKPARTIONBELOW256MB=1   echo "partition: device ${BOOTHDD} is already mounted, umount it" >&2
271   else   umount "${BOOTHDD}"
  FDISKPARTIONBELOW256MB=0  
272   fi   fi
273   fi   fi
274    
275   ## delete disk   if [[ ${INSTALL_METHOD} = auto ]]
  dd if=/dev/zero of=${HDD} count=1 &> /dev/null || dialog_die  
   
  if [[ ${FDISKPARTIONBELOW256MB} = 1 ]]  
276   then   then
277   ## setup one bootable partition   # run this only if FDISKPARTITIONBELOW256MB is not already 1
278   #1. n= new disk   if [[ ${FDISKPARTIONBELOW256MB} != 1 ]]
279   #2. p= primary disk   then
280   #3. 1= first partition   if device_minimum_size "${HDD}" 256
281   #4. 2= default sector start // small disk needs more space for grub2 mbr sector   then
282   #5. ''= defaul sector end   FDISKPARTIONBELOW256MB=1
283   #6. a= bootable flag   else
284   #7. 1= boot flag for partition 1   FDISKPARTIONBELOW256MB=0
285   #8. w= write/quit   fi
286   fdisk ${HDD} &> /dev/null << EOF   fi
287    
288     ## delete disk
289     dd if=/dev/zero of=${HDD} count=1 &> /dev/null || dialog_die
290    
291     if [[ ${FDISKPARTIONBELOW256MB} = 1 ]]
292     then
293     ## setup one bootable partition
294     #1. n= new disk
295     #2. p= primary disk
296     #3. 1= first partition
297     #4. 2= default sector start // small disk needs more space for grub2 mbr sector
298     #5. ''= defaul sector end
299     #6. a= bootable flag
300     #7. 1= boot flag for partition 1
301     #8. w= write/quit
302     fdisk ${HDD} &> /dev/null << EOF
303  n  n
304  p  p
305  1  1
# Line 404  a Line 309  a
309  1  1
310  w  w
311  EOF  EOF
312   else   else
313   ## setup one bootable partition   ## setup one bootable partition
314   #1. n= new disk   #1. n= new disk
315   #2. p= primary disk   #2. p= primary disk
316   #3. 1= first partition   #3. 1= first partition
317   #4. ''= default sector start   #4. ''= default sector start
318   #5. ''= defaul sector end   #5. ''= defaul sector end
319   #6. a= bootable flag   #6. a= bootable flag
320   #7. 1= boot flag for partition 1   #7. 1= boot flag for partition 1
321   #8. w= write/quit   #8. w= write/quit
322   fdisk ${HDD} &> /dev/null << EOF   fdisk ${HDD} &> /dev/null << EOF
323  n  n
324  p  p
325  1  1
# Line 424  a Line 329  a
329  1  1
330  w  w
331  EOF  EOF
332     fi
333     else
334     cfdisk ${HDD} || dialog_die
335   fi   fi
336  }  }
337    
 setup_hdd_partitions_manual()  
 {  
  ROOTHDD="${HDD}1"  
   
  ## hdds partitionieren manual  
  cfdisk ${HDD} || dialog_die  
 }  
   
338  setup_hdd_format()  setup_hdd_format()
339  {  {
340   mke2fs -j -q ${ROOTHDD} || dialog_die   install -d /tmp
341  }   :> /tmp/format.log
342    
343  install_mount_rootfs()   if [[ -n ${SWAPHDD} ]]
 {  
  mount ${ROOTHDD} ${INSTALLROOT} || dialog_die  
  install -d ${INSTALLROOT}/boot || dialog_die  
  cd ${INSTALLROOT} || dialog_die  
 }  
   
 install_system_image()  
 {  
  tar xvjpf ${CDROOT}/system/${CDIMAGENAME} -C ${INSTALLROOT}  
 }  
   
 install_bootsector_chroot()  
 {  
  local my_roothdd  
  local grubconf=${INSTALLROOT}/boot/grub/grub.conf  
  local grub2conf=/boot/grub/grub.cfg  
   
  # check for grub2  
  if [[ -f ${INSTALLROOT}/sbin/grub-mkconfig ]]  
344   then   then
345   # needed by grub-mkconfig on the first run   # sanity check - should not happen
346   if [[ ! -f ${INSTALLROOT}/boot/grub/video.lst ]]   if is_mounted --device "${SWAPHDD}"
347   then   then
348   install -m0644 ${INSTALLROOT}/lib/grub/*/video.lst ${INSTALLROOT}/boot/grub/video.lst || dialog_die   echo "format: device ${SWAPHDD} is already mounted, umount it" >&2
349     umount "${SWAPHDD}"
350   fi   fi
351     mkswap ${SWAPHDD} || die
352     fi
353    
354   # set kernelopts   if [[ -n ${BOOTHDD} ]]
355   if [[ -f ${INSTALLROOT}/etc/conf.d/grub ]]   then
356     # sanity check - should not happen
357     if is_mounted --device "${BOOTHDD}"
358   then   then
359   sed -i "s:^\(export GRUB_CMDLINE_LINUX_DEFAULT=\).*:\1\"${KERNELOPTS}\":" ${INSTALLROOT}/etc/conf.d/grub || dialog_die   echo "format: device ${BOOTHDD} is already mounted, umount it" >&2
360   else   umount "${BOOTHDD}"
  echo "export GRUB_CMDLINE_LINUX_DEFAULT=\"${KERNELOPTS}\"" >  ${INSTALLROOT}/etc/conf.d/grub || dialog_die  
361   fi   fi
  echo 'grub-mkdevicemap' > ${INSTALLROOT}/root/.installrc || dialog_die  
  echo "LC_ALL=C grub-mkconfig -o ${grub2conf}  &> /dev/null" >> ${INSTALLROOT}/root/.installrc || dialog_die  
  echo "grub-install --no-floppy ${HDD} &> /dev/null" >> ${INSTALLROOT}/root/.installrc || dialog_die  
  echo "exit 0" >> ${INSTALLROOT}/root/.installrc || dialog_die  
362    
363   # grub-legacy   mkfs."${FORMAT_FILESYSTEM}" "${BOOTHDD}" &>> /tmp/format.log || dialog_die
364   else   fi
  ### grubconf schreiben  
  source ${INSTALLROOT}/boot/kernelversion  
365    
366   #for alx only   if [[ -n ${ROOTHDD} ]]
367   if [ -e ${INSTALLROOT}/etc/alx_version ]   then
368     # sanity check - should not happen
369     if is_mounted --device "${ROOTHDD}"
370   then   then
371   OLD_ALXVER="${ALXVER}"   echo "format: device ${ROOTHDD} is already mounted, umount it" >&2
372   source ${INSTALLROOT}/etc/alx_version   umount "${ROOTHDD}"
  KRNVER="ALX-${ALXVER}"  
  ALXVER="${OLD_ALXVER}"  
373   fi   fi
374    
375   [[ -z ${KRNVER} ]] && KRNVER="AutoSta_LX"   mkfs."${FORMAT_FILESYSTEM}" "${ROOTHDD}" &>> /tmp/format.log || dialog_die
376   [[ -z ${KRNINITRD} ]] && KRNINITRD="initrd"   fi
377   [[ -z ${KRNIMG} ]] && KRNIMG="vmlinuz"  }
   
  # uuid support  
  if is_uuid_supported  
  then  
  my_roothdd="UUID=$(get_uuid ${ROOTHDD})"  
  else  
  my_roothdd="${ROOTHDD}"  
  fi  
378    
379   : > ${grubconf} || dialog_die  install_system_image()
380   echo "default 0" >> ${grubconf} || dialog_die  {
381   echo "timeout 3" >> ${grubconf} || dialog_die   pushd ${INSTALLROOT} > /dev/null
382   # using current root password   tar xvjpf ${IMAGEROOT}/${CDIMAGENAME} -C ${INSTALLROOT}
383   echo "password --md5 $(cat ${INSTALLROOT}/etc/shadow | grep root | cut -d: -f2)"  >> ${grubconf} || dialog_die   popd > /dev/null
384    }
385    
386   echo  >> ${grubconf} || dialog_die  install_system_settings()
387   echo "# normal boot" >> ${grubconf} || dialog_die  {
388   echo "title ${KRNVER}" >> ${grubconf} || dialog_die   local CONFIG
  echo "root (hd0,0)" >> ${grubconf} || dialog_die  
  echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS}" >> ${grubconf} || dialog_die  
  if is_initrd_supported  
  then  
  echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || dialog_die  
  fi  
389    
390   echo >> ${grubconf} || dialog_die   # write fstab
391   echo "# admin boot" >> ${grubconf} || dialog_die   CONFIG="${INSTALLROOT}/etc/fstab"
392   echo "title ${KRNVER} - Re-run hardware-detection" >> ${grubconf} || dialog_die   clearconfig
393   echo "lock"  >> ${grubconf} || dialog_die   if [[ -n ${BOOTHDD} ]]
394   echo "root (hd0,0)" >> ${grubconf} || dialog_die   then
395   echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS} hardware-auto-detection" >> ${grubconf} || dialog_die   addconfig -e "UUID=$(get_uuid ${BOOTHDD})\t/\t${FORMAT_FILESYSTEM}\tnoatime\t1 1"
396   if is_initrd_supported   fi
397   then   if [[ -n ${ROOTHDD} ]]
398   echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || dialog_die   then
399   fi   addconfig -e "UUID=$(get_uuid ${ROOTHDD})\t/\t${FORMAT_FILESYSTEM}\tnoatime\t0 0"
400     fi
401     if [[ -n ${SWAPHDD} ]]
402     then
403     addconfig -e "UUID='$(get_uuid ${SWAPHDD})'\tswap\tswap\tpri=1\t0 0"
404     fi
405     addconfig -e "proc\t/proc\tproc\tdefaults\t0 0"
406     addconfig -e "shm\t/dev/shm\ttmpfs\tdefaults\t0 0"
407    
408   echo >> ${grubconf} || dialog_die   # install network config skeleton
409   echo "title ${KRNVER} - Reset *all* local settings" >> ${grubconf} || dialog_die   CONFIG="${INSTALLROOT}/etc/conf.d/net.eth0"
410   echo "lock"  >> ${grubconf} || dialog_die   clearconfig
411   echo "root (hd0,0)" >> ${grubconf} || dialog_die   addconfig 'ONBOOT="yes"'
412   echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS} alx-reset-settings" >> ${grubconf} || dialog_die   addconfig 'NETWORKING="dhcp"'
413   if is_initrd_supported  
414     # intel framebuffer quirk
415     CONFIG="${INSTALLROOT}/etc/splash/splash.conf"
416     if [ -e ${CONFIG} ] && [ -e /proc/fb ]
417     then
418     if [[ ! -z $(grep 'inteldrmfb' /proc/fb) ]]
419   then   then
420   echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || dialog_die   fbdev=$(grep 'inteldrmfb' /proc/fb | sed 's:\([0-9]\).*:\1:')
421     [[ ${fbdev} != 0 ]] && sed -i "s:^\(SPLASH_DEV=\).*:\1\"/dev/fb${fbdev}\":" ${CONFIG} || dialog_die
422   fi   fi
   
  # bootsector schreiben chrooted schreiben (lfs/magellan)  
  cat > ${INSTALLROOT}/root/.installrc << CHROOTEOF  
 /usr/sbin/grub --no-floppy --batch << "EOF" 1> /dev/null 2> /dev/null  
 root (hd0,0)  
 setup (hd0)  
 quit  
 EOF  
 exit 0  
 CHROOTEOF  
423   fi   fi
424    }
425    
  ## enter chroot  
  mount -t proc proc ${INSTALLROOT}/proc  
  mount -t sysfs sysfs ${INSTALLROOT}/sys  
  mount -o bind /dev ${INSTALLROOT}/dev  
  chroot ${INSTALLROOT} /bin/bash --rcfile /root/.installrc -i  
  umount ${INSTALLROOT}/proc  
  umount ${INSTALLROOT}/sys  
  umount ${INSTALLROOT}/dev  
  rm ${INSTALLROOT}/root/.installrc  
 }  
   
 is_initrd_supported()  
 {  
  # only generate initrds if the cmd exists  
  [[ -x ${INSTALLROOT}/sbin/mkinitrd ]] && return 0  
  return 1  
 }  
   
 install_initrd_chroot()  
 {  
  # only generate initrds if the cmd exists  
  is_initrd_supported || return 0  
   
  DISKMODS="sd_mod"  
  OLDPATAMODS="amd74xx piix sis5513 via82cxxx"  
  PATAMODS="ata_piix pata_amd pata_mpiix pata_oldpiix pata_sis pata_via"  
  SATAMODS="sata_via sata_sis sata_nv"  
  DRMMODS="i915 mga nouveau r128 radeon savage sis tdfx ttm via"  
  OTHERMODS=""  
  case ${SPECIALDEVICE} in  
  zotac_intel) FBMODS=""; DRMMODS="i915" ;;  
  zotac_nvidia) FBMODS=""; DRMMODS="nouveau" ;;  
  rangee) FBMODS="" ;; ## fallback to vesafb, viafb does not run on all CLE266 boards  
  # not working with kms enabled drivers -> segfaults  
  #maxdata) FBMODS="i810fb" ;; ## check for maxdata / i810/ i815 Chipsets and disable KMS and use i810fb frambuffer  
  maxdata) FBMODS="" ;;  
  *) FBMODS="uvesafb" ;;  
  esac  
426    
427   if [[ ${FORMFACTOR} = laptop ]]  ### installer dialogs ###
  then  
  OTHERMODS="acpi-cpufreq cpufreq_ondemand cpufreq_conservative cpufreq_powersave"  
  fi  
428    
429   # install an appropriate uvesafb.conf  dialog_die()
430   install -d ${INSTALLROOT}/etc/modprobe.d || dialog_die  {
431   echo "options uvesafb mode_option=1024x768-32@60 scroll=ywrap" > ${INSTALLROOT}/etc/modprobe.d/uvesafb.conf || dialog_die   ERROR="$1"
432     RETVAL="$?"
433     dialog_install_failure
434     exit 1
435    }
436    
437   # install an appropriate viafb.conf  dialog_warning()
438   echo "options viafb viafb_mode=1024x768 viafb_refresh=60" > ${INSTALLROOT}/etc/modprobe.d/viafb.conf || dialog_die  {
439     local retval
440    
441   # install an appropriate i810fb.conf   yesnobox $"\Z1 !!! Warning !!! \Zn\n\n\This harddrive will be irreversibly erased.\n\n\Do you want to continue ?"
442   echo "options i810fb xres=1024 yres=768 bpp=16 mtrr=1 hsync1=30 hsync2=62 vsync1=30 vsync2=60"  > ${INSTALLROOT}/etc/modprobe.d/i810fb.conf || dialog_die   retval=$?
443     if [[ ${retval} -eq 1 ]]
444     then
445     clear
446     echo $"The process was aborted."
447     exit 1
448     fi
449    }
450    
  cat > ${INSTALLROOT}/root/.installrc << CHROOTEOF  
 echo "MODULES=\"${FORMAT_FILESYSTEM} ${DISKMODS} ${OLDATAMODS} ${PATAMODS} ${SATAMODS} ${DRMMODS} ${FBMODS} ${OTHERMODS}\"" > /etc/conf.d/mkinitrd  
 mkinitrd -f /boot/$(readlink /boot/initrd) $(readlink /boot/vmlinuz | sed "s:kernel-::g") > /dev/null  
 exit 0  
 CHROOTEOF  
451    
452   ## enters chroot  ### installer tasks ###
  mount -t proc proc ${INSTALLROOT}/proc  
  mount -t sysfs sysfs ${INSTALLROOT}/sys  
  mount -o bind /dev ${INSTALLROOT}/dev  
  chroot ${INSTALLROOT} /bin/bash --rcfile /root/.installrc -i  
  umount ${INSTALLROOT}/proc  
  umount ${INSTALLROOT}/sys  
  umount ${INSTALLROOT}/dev  
  rm ${INSTALLROOT}/root/.installrc  
 }  
453    
454  is_uuid_supported()  task_setup_system_menu()
455  {  {
456   if [[ -x $(type -P busybox.mkinitrd) ]]   local mode
457     local retval
458    
459     mode="$(dialog_setup_system_menu)"
460     retval=$?
461     [[ ${retval} -eq 1 ]] && return 1
462     if [[ ${retval} -eq 0 ]]
463   then   then
464   # only detect uuids if supported   case "${mode}" in
465   if [[ ! -z $(busybox.mkinitrd | grep blkid) ]]   "1") run_install auto ;;
466   then   "2") run_install normal ;;
467   return 0   "") task_setup_system_menu;;
468   fi   esac
469   fi   fi
   
  return 1  
470  }  }
471    
472  get_uuid()  task_hardware_detection()
473  {  {
474   local UUID   local message
475   local SEC_TYPE  
476   local TYPE   run_hardware_detection_disks
477    
478   local dev="$1"   message+=$"Harddrives:\n"
  [[ -z ${dev} ]] && dialog_die "no dev given"  
479    
480   # check if given device is already an UUID   if [[ ! -z ${ALL_DISKS} ]]
  if [[ ${dev/UUID=/}x != ${dev}x ]]  
481   then   then
482   eval "${dev}"   for i in ${ALL_DISKS}
483   else   do
484   eval $(busybox.mkinitrd blkid ${dev} | grep "${dev}:" | sed 's/.*:\ //')   message+="\Z3${i}\Zn "
485     done
486     message+="\n"
487   fi   fi
  echo "${UUID}"  
 }  
488    
489  install_system_settings()   if [[ ! -z ${ALL_CDROMS} ]]
 {  
  # schreibe fstab  
  if is_uuid_supported  
490   then   then
491   echo -e "UUID=$(get_uuid ${ROOTHDD})\t/\t${FORMAT_FILESYSTEM}\tnoatime\t0 0" >> ${INSTALLROOT}/etc/fstab || dialog_die   message+="\n"
492   else   message+=$"Optical disk drives:\n"
493   echo -e "${ROOTHDD}\t/\t${FORMAT_FILESYSTEM}\tnoatime\t0 0" >> ${INSTALLROOT}/etc/fstab || dialog_die   for i in ${ALL_CDROMS}
494     do
495     message+="\Z3${i}\Zn"
496     done
497     message+="\n"
498   fi   fi
  # not needed busybox loads all with swapon -a, even if not mentioned in fstab  
  #echo -e "UUID='$(get_uuid ${SWAPHDD})'\tswap\tswap\tpri=1\t0 0" >> ${INSTALLROOT}/etc/fstab || dialog_die  
  echo -e "proc\t/proc\tproc\tdefaults\t0 0" >> ${INSTALLROOT}/etc/fstab || dialog_die  
  echo -e "shm\t/dev/shm\ttmpfs\tdefaults\t0 0" >> ${INSTALLROOT}/etc/fstab || dialog_die  
499    
500   # install network config skeleton   # other devices
501   install -m0644 ${INSTALLROOT}/etc/alxconfig-ng/skel/net/net.eth0 ${INSTALLROOT}/etc/conf.d/ || dialog_die   run_hardware_detection
502     case "${SPECIALDEVICE}" in
503     zotac*) message+=$"\n\Z2Zotac device detected.\Zn" ;;
504     rangee) message+=$"\n\Z2Rangee device detected.\Zn" ;;
505     maxdata) message+=$"\n\Z2Maxdata device detected.\Zn" ;;
506     *) message+=$"\n\ZnCommon device detected.\Zn" ;;
507     esac
508     if [[ ${FORMFACTOR} = laptop ]]
509     then
510     message+=$"\n\ZnFormfactor Laptop, activating 'ondemand' powersaving mode.\Zn"
511     fi
512    
513     messagebox -y 12 -h $"Detected hardware:" "${message}"
514    }
515    
516   # intel framebufer quirk  task_setup_hdd_partitions()
517   if [[ -e /proc/fb ]]  {
518     local i
519     local retval
520    
521     if [[ -z ${ALL_DISKS} ]]
522   then   then
523   if [[ ! -z $(grep 'inteldrmfb' /proc/fb) ]]   dialog_no_harddrive_found
524     exit 1
525     else
526     HDD=$(dialog_select_target_harddrive)
527     retval=$?
528     [[ ${retval} -eq 1 ]] && return 1
529     if [[ ${retval} -eq 0 ]]
530   then   then
531   fbdev=$(grep 'inteldrmfb' /proc/fb | sed 's:\([0-9]\).*:\1:')   dialog_setup_hdd_info
532   if [[ ${fbdev} != 0 ]]   setup_hdd_partitions
  then  
  sed -i "s:^\(SPLASH_DEV=\).*:\1\"/dev/fb${fbdev}\":" ${INSTALLROOT}/etc/splash/splash.conf || dialog_die  
  fi  
533   fi   fi
534   fi   fi
535  }  }
536    
537  install_umount_rootfs()  task_main()
538  {  {
539   cd /   local method=0
540   umount ${INSTALLROOT}/boot || dialog_die   local retval
  umount ${INSTALLROOT} || dialog_die  
 }  
541    
542  install_do_reboot()   while [[ ${method} -le 2 ]]
543  {   do
544   reboot   method=$(dialog_main)
545     retval=$?
546     [[ ${retval} -eq 1 ]] && exit 1
547     if [[ ${retval} -eq 0 ]]
548     then
549     case ${method} in
550     "1") task_setup_system_menu ;;
551     "2") task_hardware_detection ;;
552     "3") install_do_reboot ;;
553     "4") /bin/bash --login -i ;;
554     esac
555     fi
556     done
557  }  }
558    
559  #################################################  run_install()
 #     Install Ablauf Scripte #  
 #################################################  
   
 run_install_normal()  
560  {  {
561   dialog_hardware_detection   local method="$1"
   
  dialog_setup_hdd_partitions_manual  
  dialog_setup_hdd_format  
  setup_hdd_format > /dev/null  
  install_mount_rootfs  
  (install_system_image > /tmp/install.log) 2> /tmp/install_errors.log | install_meter | dialog_install_system_image  
   
  dialog_install_settings  
  sleep 1  
  install_system_settings  
  dialog_install_initrd  
  install_initrd_chroot  
562    
563   dialog_install_bootsector   task_hardware_detection
  install_bootsector_chroot  
564    
565   install_umount_rootfs   case "${method}" in
566   dialog_install_successful   auto)
567  }   export INSTALL_METHOD="${method}"
568     ;;
569  run_install_auto()   normal)
570  {   export INSTALL_METHOD="${method}"
571   dialog_hardware_detection   ;;
572     *)
573     die "Unknown install method '${method}', aborting."
574     ;;
575     esac
576    
577   dialog_setup_hdd_partitions_auto   task_setup_hdd_partitions
578   dialog_setup_hdd_format   dialog_setup_hdd_format
579   setup_hdd_format > /dev/null   setup_hdd_format > /dev/null
580   install_mount_rootfs   mount_rootfs
581   (install_system_image > /tmp/install.log) 2> /tmp/install_errors.log | install_meter | dialog_install_system_image   (install_system_image > /tmp/install.log) 2> /tmp/install_errors.log | install_meter | dialog_install_system_image
582    
583   dialog_install_settings   dialog_install_settings
584   sleep 1   sleep 1
585   install_system_settings   install_system_settings
586   dialog_install_initrd   if is_initrd_supported
587   install_initrd_chroot   then
588     dialog_install_initrd
589     initrd_config
590     initrd_install
591     fi
592    
593   dialog_install_bootsector   dialog_install_bootsector
594   install_bootsector_chroot   bootloader_config
595     bootloader_install
596    
597   install_umount_rootfs   umount_rootfs
598   dialog_install_successful   dialog_install_successful
599  }  }
600    
601  # set some proper traps  # set some proper traps
602  trap "trap_exit" SIGINT SIGQUIT  trap "trap_exit" SIGINT SIGQUIT
603    
604  dialog_main  task_main
605    
606  exit 0  exit 0

Legend:
Removed from v.2430  
changed lines
  Added in v.2883