Magellan Linux

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

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

revision 2429 by niro, Tue Jan 7 14:13:11 2014 UTC revision 2892 by niro, Fri Jul 31 11:40:56 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    # initialize global variables so they are exportable
48  # some sane defaults  # some sane defaults
49  CDROOT="${DEFAULT_CDROOT}"  INSTALL_METHOD=""
50    LIVEROOT="${DEFAULT_LIVEROOT}"
51    IMAGEROOT="${DEFAULT_IMAGEROOT}"
52  INSTALLROOT="${DEFAULT_INSTALLROOT}"  INSTALLROOT="${DEFAULT_INSTALLROOT}"
53  KERNELPKG="${DEFAULT_KERNELPKG}"  KERNELPKG="${DEFAULT_KERNELPKG}"
54  KERNELOPTS="${DEFAULT_KERNELOPTS}"  KERNELOPTS="${DEFAULT_KERNELOPTS}"
# Line 69  FDISKPARTIONBELOW256MB=0 Line 58  FDISKPARTIONBELOW256MB=0
58  SPECIALDEVICE=""  SPECIALDEVICE=""
59  FORMFACTOR="${DEFAULT_FORMFACTOR}"  FORMFACTOR="${DEFAULT_FORMFACTOR}"
60  FORMAT_FILESYSTEM="${DEFAULT_FILESYSTEM}"  FORMAT_FILESYSTEM="${DEFAULT_FILESYSTEM}"
61    FLASHDISK=0
62    
63  #################################################  # TOTALLINES=linecount of ${CDIMAGENAME}-tarball -1 !
64  #  DIALOG BOXEN #  # -> now in images.conf
65  #################################################  CDIMAGENAME=""
66    TOTALLINES=""
67    CURRENTLINE=0
68    if [ -e ${IMAGEROOT}/images.conf ]
69    then
70     source ${IMAGEROOT}/images.conf
71     # check if all required variables are set
72     [[ -z ${CDIMAGENAME} ]] && die "CDIMAGENAME is empty in ${IMAGEROOT}/images.conf"
73     [[ -z ${TOTALLINES} ]] && die "TOTALLINES is empty in ${IMAGEROOT}/images.conf"
74    else
75     die "${IMAGEROOT}/images.conf not found"
76    fi
77    
78    ### helper scripts ###
79    
80  trap_exit()  trap_exit()
81  {  {
# Line 81  trap_exit() Line 84  trap_exit()
84   is_mounted --location "${INSTALLROOT}/sys" && umount ${INSTALLROOT}/sys   is_mounted --location "${INSTALLROOT}/sys" && umount ${INSTALLROOT}/sys
85   is_mounted --location "${INSTALLROOT}/boot" && umount ${INSTALLROOT}/boot   is_mounted --location "${INSTALLROOT}/boot" && umount ${INSTALLROOT}/boot
86   is_mounted --location "${INSTALLROOT}" && umount ${INSTALLROOT}   is_mounted --location "${INSTALLROOT}" && umount ${INSTALLROOT}
87     [[ -n ${SWAPHDD} ]] && swapoff ${SWAPHDD}
88    
89   echo $"Installation aborted."   echo $"Installation aborted."
90   exit 1   exit 1
91  }  }
92    
93  dialog_die()  install_meter()
 {  
  ERROR="$1"  
  RETVAL="$?"  
  dialog_install_failure  
  exit 1  
 }  
   
 dialog_warning()  
 {  
  local retval  
   
  yesnobox $"\Z1 !!! Warning !!! \Zn\n\n\This harddrive will be irreversibly erased.\n\n\Do you want to continue ?"  
  retval=$?  
  if [[ ${retval} -eq 1 ]]  
  then  
  clear  
  echo $"The process was aborted."  
  exit 1  
  fi  
 }  
   
 dialog_setup_hdd_info()  
 {  
  local SHDD="${HDD//\/dev\/}"  
   
  messagebox -h $"[ Harddrive partitioning ]" \  
  $"\nPlease create 1 partition.\n\n\[ \Z3${SHDD}1\Zn ] type: \Z3linux\Zn with the whole diskspace\n\Please mark ${SHDD}1 \Z3bootable\Zn."  
 }  
   
 dialog_setup_hdd_info_auto()  
94  {  {
95   local SHDD="${HDD//\/dev\/}"   while [[ ${CURRENTLINE} != ${TOTALLINES} ]]
96     do
97   messagebox -h $"[ Harddrive partitioning ]" \   CURRENTLINE=$(grep -c . /tmp/install.log)
98   $"\Z1Warning!\Zn\n\nAll data on disk [ \Z3${HDD}\Zn ] will be erased!"   PERCENT=$(( ${CURRENTLINE} * 100 / ${TOTALLINES}))
99     echo ${PERCENT}
100     sleep 1
101     done
102     rm -f /tmp/install.log
103     return 0
104  }  }
105    
106  dialog_setup_system_menu()  mount_rootfs()
107  {  {
  local mode  
108   local retval   local retval
109    
110   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 ]]  
  then  
  case "${mode}" in  
  "1") run_install_auto ;;  
  "2") run_install_normal ;;  
  "") dialog_setup_system_menu;;  
  esac  
  fi  
 }  
   
 dialog_hardware_detection()  
 {  
  local message  
   
  run_hardware_detection_disks  
   
  message+=$"Harddrives:\n"  
   
  if [[ ! -z ${ALL_DISKS} ]]  
111   then   then
112   for i in ${ALL_DISKS}   swapon ${SWAPHDD} || dialog_die $"Could not enable swap space '${SWAPHDD}'"
  do  
  message+="\Z3${i}\Zn "  
  done  
  message+="\n"  
113   fi   fi
114    
115   if [[ ! -z ${ALL_CDROMS} ]]   if [[ -n ${ROOTHDD} ]]
  then  
  message+="\n"  
  message+=$"Optical disk drives:\n"  
  for i in ${ALL_CDROMS}  
  do  
  message+="\Z3${i}\Zn"  
  done  
  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 ]]  
116   then   then
117   message+=$"\n\ZnFormfactor Laptop, activating 'ondemand' powersaving  mode.\Zn"   if is_mounted --location "${INSTALLROOT}"
118     then
119     echo $"${INSTALLROOT} already mounted" >&2
120     else
121     mount -t "${FORMAT_FILESYSTEM_ROOTHDD}" "${ROOTHDD}" "${INSTALLROOT}" || dialog_die $"Could not mount rootfs - drive '${ROOTHDD}' -> '${INSTALLROOT}'"
122     fi
123   fi   fi
124    
125   messagebox -y 15 -h $"Detected hardware:" "${message}"   [[ -d ${INSTALLROOT}/boot ]] || install -d ${INSTALLROOT}/boot
 }  
126    
127  dialog_setup_hdd_partitions_manual()   if [[ -n ${BOOTHDD} ]]
 {  
  local i  
  local retval  
   
  if [[ -z ${ALL_DISKS} ]]  
128   then   then
129   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 ]]  
130   then   then
131   dialog_setup_hdd_info   echo $"${INSTALLROOT}/boot already mounted" >&2
132   setup_hdd_partitions_manual   else
133     mount -t "${FORMAT_FILESYSTEM_BOOTHDD}" "${BOOTHDD}" "${INSTALLROOT}"/boot || dialog_die $"Could not mount bootfs - drive '${BOOTHDD}' -> '${INSTALLROOT}/boot'"
134   fi   fi
135   fi   fi
136  }  }
137    
138  dialog_setup_hdd_partitions_auto()  umount_rootfs()
139  {  {
140   local i   is_mounted --location ${INSTALLROOT}/boot && umount ${INSTALLROOT}/boot
141   local retval   is_mounted --location ${INSTALLROOT} && umount ${INSTALLROOT}
142    
143   if [[ -z ${ALL_DISKS} ]]   if [[ -n ${SWAPHDD} ]]
144   then   then
145   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  
146   fi   fi
147  }  }
148    
149  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()  
150  {  {
151   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  
152  }  }
153    
 #################################################  
 # Install Komandos #  
 #################################################  
154  run_hardware_detection()  run_hardware_detection()
155  {  {
156   local hwinfo   local hwinfo
# Line 291  run_hardware_detection() Line 167  run_hardware_detection()
167   if [[ $(< ${i}) = 1 ]]   if [[ $(< ${i}) = 1 ]]
168   then   then
169   removable=1   removable=1
170     # we assume that all removable disks are flash disks on a zotac
171     export FLASHDISK=1
172   fi   fi
173   done   done
174     # smartcard = udevadm info -n /dev/sda -a | grep -i 'configuration.*card'
175    
176   # 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
177   export GRUBLEGACYOPTS="rootdelay=8"   export GRUBLEGACYOPTS="rootdelay=8"
# Line 323  run_hardware_detection() Line 202  run_hardware_detection()
202   export GRUBLEGACYOPTS=""   export GRUBLEGACYOPTS=""
203   fi   fi
204    
205     # check for i845 Chipsets and enable KMS and use 915 drm driver later in initrd
206     if [[ ! -z $(echo "${hwinfo}" | grep -i i845) ]]
207     then
208     export SPECIALDEVICE="i845"
209     # unset default video=1024x768 opt or the drm driver breaks
210     export KERNELOPTS="quiet"
211     export GRUBLEGACYOPTS=""
212     # enable full kms support
213     export GRUB2GFXPAYLOAD="keep"
214     fi
215    
216     # check for radeon gfxcards
217     if [[ ! -z $(echo "${hwinfo}" | grep -i radeon) ]]
218     then
219     # enable full kms support
220     export GRUB2GFXPAYLOAD="keep"
221     fi
222    
223     # requires nomsi to prevent massive IRQ error spam
224     # see: http://ubuntuforums.org/showthread.php?t=1234983
225     if [[ ! -z $(echo "${hwinfo}" | grep -i 'P5VD2-X') ]] || [[ ! -z $(echo "${hwinfo}" | grep -i 'VT8237') ]] || [[ ! -z $(echo "${hwinfo}" | grep -i 'VX700') ]]
226     then
227     export SPECIALDEVICE="nomsi"
228     export KERNELOPTS="${KERNELOPTS} pci=nomsi,noaer"
229     fi
230    
231   # check for special devices/clients:   # check for special devices/clients:
232   # check for laptops and activate cpufreq scaling   # check for laptops and activate cpufreq scaling
233   if [[ $(echo "${hwinfo}" | grep 'Formfactor:' | sed 's:.*Formfactor\:\ \"\(.*\)\":\1:') = laptop ]]   if [[ $(echo "${hwinfo}" | grep 'Formfactor:' | sed 's:.*Formfactor\:\ \"\(.*\)\":\1:') = laptop ]]
# Line 339  run_hardware_detection_disks() Line 244  run_hardware_detection_disks()
244   # all disks but exclude ramdisks   # all disks but exclude ramdisks
245   export ALL_DISKS=$(get_hwinfo disk | sed '/\/dev\/ram[0-9].*/d')   export ALL_DISKS=$(get_hwinfo disk | sed '/\/dev\/ram[0-9].*/d')
246   # remove the boot device from ALL_DISKS if it was an usbstick   # remove the boot device from ALL_DISKS if it was an usbstick
247   if [[ $(grep '[[:space:]]/mnt/cdrom[[:space:]]' /proc/mounts | cut -d' ' -f3) != iso9660 ]]   if [[ $(grep '[[:space:]]${LIVEROOT}[[:space:]]' /proc/mounts | cut -d' ' -f3) != iso9660 ]]
248   then   then
249   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')
250   export ALL_DISKS=$(echo "${ALL_DISKS}" | grep -v "${bootdev}")   export ALL_DISKS=$(echo "${ALL_DISKS}" | grep -v "${bootdev}")
251   fi   fi
252   export ALL_CDROMS="$(get_hwinfo cdrom)"   export ALL_CDROMS="$(get_hwinfo cdrom)"
253  }  }
254    
255  hdd_size_below_256mb()  setup_hdd_partitions()
256  {  {
257   local hdd="$1"   # sanity check - should not happen
258   local size   if is_mounted --device "${ROOTHDD}"
  local retval  
  [[ -z ${hdd} ]] && dialog_die "Error: get_hdd_size() no \$hdd given!"  
   
  size=$(fdisk -l ${hdd} | grep "Disk.*${hdd}" | sed 's:.*,\ \(.*\)\ byte.*:\1:')  
  if [[ ${size} -le 257000000 ]]  
259   then   then
260   retval="0"   echo "partition: device ${ROOTHDD} is already mounted, umount it" >&2
261   else   umount "${ROOTHDD}"
  retval="1"  
262   fi   fi
263     if [[ -n ${BOOTHDD} ]]
  return "${retval}"  
 }  
   
 setup_hdd_partitions_auto()  
 {  
  ROOTHDD="${HDD}1"  
   
  # run this only if FDISKPARTITIONBELOW256MB is not already 1  
  if [[ ${FDISKPARTIONBELOW256MB} != 1 ]]  
264   then   then
265   if hdd_size_below_256mb ${HDD}   if is_mounted --device "${BOOTHDD}"
266   then   then
267   FDISKPARTIONBELOW256MB=1   echo "partition: device ${BOOTHDD} is already mounted, umount it" >&2
268   else   umount "${BOOTHDD}"
  FDISKPARTIONBELOW256MB=0  
269   fi   fi
270   fi   fi
271    
272   ## delete disk   if [[ ${INSTALL_METHOD} = auto ]]
  dd if=/dev/zero of=${HDD} count=1 &> /dev/null || dialog_die  
   
  if [[ ${FDISKPARTIONBELOW256MB} = 1 ]]  
273   then   then
274   ## setup one bootable partition   # run this only if FDISKPARTITIONBELOW256MB is not already 1
275   #1. n= new disk   if [[ ${FDISKPARTIONBELOW256MB} != 1 ]]
276   #2. p= primary disk   then
277   #3. 1= first partition   if device_minimum_size "${HDD}" 256
278   #4. 2= default sector start // small disk needs more space for grub2 mbr sector   then
279   #5. ''= defaul sector end   FDISKPARTIONBELOW256MB=1
280   #6. a= bootable flag   else
281   #7. 1= boot flag for partition 1   FDISKPARTIONBELOW256MB=0
282   #8. w= write/quit   fi
283   fdisk ${HDD} &> /dev/null << EOF   fi
284    
285     ## delete disk
286     dd if=/dev/zero of=${HDD} count=1 &> /dev/null || dialog_die
287    
288     if [[ ${FLASHDISK} = 1 ]]
289     then
290     if [[ ${FDISKPARTIONBELOW256MB} = 1 ]]
291     then
292     ## setup one bootable partition
293     # 1. n= new disk
294     # 2. p= primary disk
295     # 3. 1= first partition
296     # 4. 2= default sector start // small disk needs more space for grub2 mbr sector
297     # 5. ''= defaul sector end
298     # 6. a= bootable flag
299     # 7. 1= boot flag for partition 1
300     # 8. n= new disk
301     #10. p= primary disk
302     #11. 2= second partition
303     #12. ''= default sector start
304     #13. ''= defaul sector end
305     #14. w= write/quit
306     fdisk ${HDD} &> /dev/null << EOF
307  n  n
308  p  p
309  1  1
310  2  2
311    +50M
312  a  a
313  1  1
314    n
315    p
316    2
317    
318    
319  w  w
320  EOF  EOF
321   else   else
322   ## setup one bootable partition   ## setup one bootable partition
323   #1. n= new disk   # 1. n= new disk
324   #2. p= primary disk   # 2. p= primary disk
325   #3. 1= first partition   # 3. 1= first partition
326   #4. ''= default sector start   # 4. ''= default sector start
327   #5. ''= defaul sector end   # 5. ''= defaul sector end
328   #6. a= bootable flag   # 6. a= bootable flag
329   #7. 1= boot flag for partition 1   # 7. 1= boot flag for partition 1
330   #8. w= write/quit   # 8. n= new disk
331   fdisk ${HDD} &> /dev/null << EOF   #10. p= primary disk
332     #11. 2= second partition
333     #12. ''= default sector start
334     #13. ''= defaul sector end
335     #14. w= write/quit
336     fdisk ${HDD} &> /dev/null << EOF
337  n  n
338  p  p
339  1  1
340    
341    +50M
342    a
343    1
344    n
345    p
346    2
347    
348    
349    w
350    EOF
351     fi
352     else
353     if [[ ${FDISKPARTIONBELOW256MB} = 1 ]]
354     then
355     ## setup one bootable partition
356     #1. n= new disk
357     #2. p= primary disk
358     #3. 1= first partition
359     #4. 2= default sector start // small disk needs more space for grub2 mbr sector
360     #5. ''= defaul sector end
361     #6. a= bootable flag
362     #7. 1= boot flag for partition 1
363     #8. w= write/quit
364     fdisk ${HDD} &> /dev/null << EOF
365    n
366    p
367    1
368    2
369    
370  a  a
371  1  1
372  w  w
373  EOF  EOF
374   fi   else
375  }   ## setup one bootable partition
376     #1. n= new disk
377     #2. p= primary disk
378     #3. 1= first partition
379     #4. ''= default sector start
380     #5. ''= defaul sector end
381     #6. a= bootable flag
382     #7. 1= boot flag for partition 1
383     #8. w= write/quit
384     fdisk ${HDD} &> /dev/null << EOF
385    n
386    p
387    1
388    
 setup_hdd_partitions_manual()  
 {  
  ROOTHDD="${HDD}1"  
389    
390   ## hdds partitionieren manual  a
391   cfdisk ${HDD} || dialog_die  1
392    w
393    EOF
394     fi
395     fi
396     else
397     cfdisk ${HDD} || dialog_die
398     fi
399  }  }
400    
401  setup_hdd_format()  setup_hdd_format()
402  {  {
403   mke2fs -j -q ${ROOTHDD} || dialog_die   install -d /tmp
404  }   :> /tmp/format.log
405    
406  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 ]]  
407   then   then
408   # needed by grub-mkconfig on the first run   # sanity check - should not happen
409   if [[ ! -f ${INSTALLROOT}/boot/grub/video.lst ]]   if is_mounted --device "${SWAPHDD}"
410   then   then
411   install -m0644 ${INSTALLROOT}/lib/grub/*/video.lst ${INSTALLROOT}/boot/grub/video.lst || dialog_die   echo "format: device ${SWAPHDD} is already mounted, umount it" >&2
412     umount "${SWAPHDD}"
413   fi   fi
414     mkswap ${SWAPHDD} || die
415     fi
416    
417   # set kernelopts   if [[ -n ${BOOTHDD} ]]
418   if [[ -f ${INSTALLROOT}/etc/conf.d/grub ]]   then
419     # sanity check - should not happen
420     if is_mounted --device "${BOOTHDD}"
421   then   then
422   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
423   else   umount "${BOOTHDD}"
  echo "export GRUB_CMDLINE_LINUX_DEFAULT=\"${KERNELOPTS}\"" >  ${INSTALLROOT}/etc/conf.d/grub || dialog_die  
424   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  
425    
426   # grub-legacy   mkfs."${FORMAT_FILESYSTEM_BOOTHDD}" "${BOOTHDD}" &>> /tmp/format.log || dialog_die
427   else   fi
  ### grubconf schreiben  
  source ${INSTALLROOT}/boot/kernelversion  
428    
429   #for alx only   if [[ -n ${ROOTHDD} ]]
430   if [ -e ${INSTALLROOT}/etc/alx_version ]   then
431     # sanity check - should not happen
432     if is_mounted --device "${ROOTHDD}"
433   then   then
434   OLD_ALXVER="${ALXVER}"   echo "format: device ${ROOTHDD} is already mounted, umount it" >&2
435   source ${INSTALLROOT}/etc/alx_version   umount "${ROOTHDD}"
  KRNVER="ALX-${ALXVER}"  
  ALXVER="${OLD_ALXVER}"  
436   fi   fi
437    
438   [[ -z ${KRNVER} ]] && KRNVER="AutoSta_LX"   mkfs."${FORMAT_FILESYSTEM_ROOTHDD}" "${ROOTHDD}" &>> /tmp/format.log || dialog_die
439   [[ -z ${KRNINITRD} ]] && KRNINITRD="initrd"   fi
440   [[ -z ${KRNIMG} ]] && KRNIMG="vmlinuz"  }
   
  # uuid support  
  if is_uuid_supported  
  then  
  my_roothdd="UUID=$(get_uuid ${ROOTHDD})"  
  else  
  my_roothdd="${ROOTHDD}"  
  fi  
441    
442   : > ${grubconf} || dialog_die  install_system_image()
443   echo "default 0" >> ${grubconf} || dialog_die  {
444   echo "timeout 3" >> ${grubconf} || dialog_die   pushd ${INSTALLROOT} > /dev/null
445   # using current root password   tar xvjpf ${IMAGEROOT}/${CDIMAGENAME} -C ${INSTALLROOT}
446   echo "password --md5 $(cat ${INSTALLROOT}/etc/shadow | grep root | cut -d: -f2)"  >> ${grubconf} || dialog_die   popd > /dev/null
447    }
448    
449   echo  >> ${grubconf} || dialog_die  install_system_settings()
450   echo "# normal boot" >> ${grubconf} || dialog_die  {
451   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  
452    
453   echo >> ${grubconf} || dialog_die   # write fstab
454   echo "# admin boot" >> ${grubconf} || dialog_die   CONFIG="${INSTALLROOT}/etc/fstab"
455   echo "title ${KRNVER} - Re-run hardware-detection" >> ${grubconf} || dialog_die   clearconfig
456   echo "lock"  >> ${grubconf} || dialog_die   if [[ -n ${BOOTHDD} ]]
457   echo "root (hd0,0)" >> ${grubconf} || dialog_die   then
458   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_BOOTHDD}\tnoatime\t1 1"
459   if is_initrd_supported   fi
460   then   if [[ -n ${ROOTHDD} ]]
461   echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || dialog_die   then
462   fi   addconfig -e "UUID=$(get_uuid ${ROOTHDD})\t/\t${FORMAT_FILESYSTEM_ROOTHDD}\tnoatime\t0 0"
463     fi
464     if [[ -n ${SWAPHDD} ]]
465     then
466     addconfig -e "UUID='$(get_uuid ${SWAPHDD})'\tswap\tswap\tpri=1\t0 0"
467     fi
468     addconfig -e "proc\t/proc\tproc\tdefaults\t0 0"
469     addconfig -e "shm\t/dev/shm\ttmpfs\tdefaults\t0 0"
470    
471   echo >> ${grubconf} || dialog_die   # install network config skeleton
472   echo "title ${KRNVER} - Reset *all* local settings" >> ${grubconf} || dialog_die   CONFIG="${INSTALLROOT}/etc/conf.d/net.eth0"
473   echo "lock"  >> ${grubconf} || dialog_die   clearconfig
474   echo "root (hd0,0)" >> ${grubconf} || dialog_die   addconfig 'ONBOOT="yes"'
475   echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS} alx-reset-settings" >> ${grubconf} || dialog_die   addconfig 'NETWORKING="dhcp"'
476   if is_initrd_supported  
477     # intel framebuffer quirk
478     CONFIG="${INSTALLROOT}/etc/splash/splash.conf"
479     if [ -e ${CONFIG} ] && [ -e /proc/fb ]
480     then
481     if [[ ! -z $(grep 'inteldrmfb' /proc/fb) ]]
482   then   then
483   echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || dialog_die   fbdev=$(grep 'inteldrmfb' /proc/fb | sed 's:\([0-9]\).*:\1:')
484     [[ ${fbdev} != 0 ]] && sed -i "s:^\(SPLASH_DEV=\).*:\1\"/dev/fb${fbdev}\":" ${CONFIG} || dialog_die
485   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  
486   fi   fi
487    }
488    
  ## 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  
489    
490   if [[ ${FORMFACTOR} = laptop ]]  ### installer dialogs ###
  then  
  OTHERMODS="acpi-cpufreq cpufreq_ondemand cpufreq_conservative cpufreq_powersave"  
  fi  
491    
492   # install an appropriate uvesafb.conf  dialog_die()
493   install -d ${INSTALLROOT}/etc/modprobe.d || dialog_die  {
494   echo "options uvesafb mode_option=1024x768-32@60 scroll=ywrap" > ${INSTALLROOT}/etc/modprobe.d/uvesafb.conf || dialog_die   ERROR="$1"
495     RETVAL="$?"
496     dialog_install_failure
497     exit 1
498    }
499    
500   # install an appropriate viafb.conf  dialog_warning()
501   echo "options viafb viafb_mode=1024x768 viafb_refresh=60" > ${INSTALLROOT}/etc/modprobe.d/viafb.conf || dialog_die  {
502     local retval
503    
504   # install an appropriate i810fb.conf   yesnobox $"\Z1 !!! Warning !!! \Zn\n\n\This harddrive will be irreversibly erased.\n\n\Do you want to continue ?"
505   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=$?
506     if [[ ${retval} -eq 1 ]]
507     then
508     clear
509     echo $"The process was aborted."
510     exit 1
511     fi
512    }
513    
  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  
514    
515   ## 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  
 }  
516    
517  is_uuid_supported()  task_setup_system_menu()
518  {  {
519   if [[ -x $(type -P busybox.mkinitrd) ]]   local mode
520     local retval
521    
522     mode="$(dialog_setup_system_menu)"
523     retval=$?
524     [[ ${retval} -eq 1 ]] && return 1
525     if [[ ${retval} -eq 0 ]]
526   then   then
527   # only detect uuids if supported   case "${mode}" in
528   if [[ ! -z $(busybox.mkinitrd | grep blkid) ]]   "1") run_install auto ;;
529   then   "2") run_install normal ;;
530   return 0   "") task_setup_system_menu;;
531   fi   esac
532   fi   fi
   
  return 1  
533  }  }
534    
535  get_uuid()  task_hardware_detection()
536  {  {
537   local UUID   local message
538   local SEC_TYPE  
539   local TYPE   run_hardware_detection_disks
540    
541   local dev="$1"   message+=$"Harddrives:\n"
  [[ -z ${dev} ]] && dialog_die "no dev given"  
542    
543   # check if given device is already an UUID   if [[ ! -z ${ALL_DISKS} ]]
  if [[ ${dev/UUID=/}x != ${dev}x ]]  
544   then   then
545   eval "${dev}"   for i in ${ALL_DISKS}
546   else   do
547   eval $(busybox.mkinitrd blkid ${dev} | grep "${dev}:" | sed 's/.*:\ //')   message+="\Z3${i}\Zn "
548     done
549     message+="\n"
550   fi   fi
  echo "${UUID}"  
 }  
551    
552  install_system_settings()   if [[ ! -z ${ALL_CDROMS} ]]
 {  
  # schreibe fstab  
  if is_uuid_supported  
553   then   then
554   echo -e "UUID=$(get_uuid ${ROOTHDD})\t/\t${FORMAT_FILESYSTEM}\tnoatime\t0 0" >> ${INSTALLROOT}/etc/fstab || dialog_die   message+="\n"
555   else   message+=$"Optical disk drives:\n"
556   echo -e "${ROOTHDD}\t/\t${FORMAT_FILESYSTEM}\tnoatime\t0 0" >> ${INSTALLROOT}/etc/fstab || dialog_die   for i in ${ALL_CDROMS}
557     do
558     message+="\Z3${i}\Zn"
559     done
560     message+="\n"
561   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  
562    
563   # install network config skeleton   # other devices
564   install -m0644 ${INSTALLROOT}/etc/alxconfig-ng/skel/net/net.eth0 ${INSTALLROOT}/etc/conf.d/ || dialog_die   run_hardware_detection
565     case "${SPECIALDEVICE}" in
566     zotac*) message+=$"\n\Z2Zotac device detected.\Zn" ;;
567     rangee) message+=$"\n\Z2Rangee device detected.\Zn" ;;
568     maxdata) message+=$"\n\Z2Maxdata device detected.\Zn" ;;
569     i845) message+=$"\n\Z2Intel i845 VGA device detected.\Zn" ;;
570     nomsi) message+=$"\n\Z2Mainboard with P5VD2-X/VT8237/VX700 chipset detected.\Zn"
571     message+=$"\n\Z2Disabling Message Signaled Interrupts (MSI) capability of the kernel.\Zn" ;;
572     *) message+=$"\n\ZnCommon device detected.\Zn" ;;
573     esac
574     if [[ ${FORMFACTOR} = laptop ]]
575     then
576     message+=$"\n\ZnFormfactor Laptop, activating 'ondemand' powersaving mode.\Zn"
577     fi
578     if [[ ${FLASHDISK} = 1 ]]
579     then
580     message+=$"\n\ZnFlash memory detected.\Zn"
581     message+=$"\n\ZnF2FS will be used as default filesystem withn the auto installation mode.\Zn"
582     fi
583    
584     messagebox -y 12 -h $"Detected hardware:" "${message}"
585    }
586    
587    task_setup_hdd_partitions()
588    {
589     local i
590     local retval
591    
592   # intel framebufer quirk   if [[ -z ${ALL_DISKS} ]]
  if [[ -e /proc/fb ]]  
593   then   then
594   if [[ ! -z $(grep 'inteldrmfb' /proc/fb) ]]   dialog_no_harddrive_found
595     exit 1
596     else
597     HDD=$(dialog_select_target_harddrive)
598     retval=$?
599     [[ ${retval} -eq 1 ]] && return 1
600     if [[ ${retval} -eq 0 ]]
601   then   then
602   fbdev=$(grep 'inteldrmfb' /proc/fb | sed 's:\([0-9]\).*:\1:')   dialog_setup_hdd_info
603   if [[ ${fbdev} != 0 ]]   setup_hdd_partitions
  then  
  sed -i "s:^\(SPLASH_DEV=\).*:\1\"/dev/fb${fbdev}\":" ${INSTALLROOT}/etc/splash/splash.conf || dialog_die  
  fi  
604   fi   fi
605   fi   fi
606  }  }
607    
608  install_umount_rootfs()  task_main()
609  {  {
610   cd /   local method=0
611   umount ${INSTALLROOT}/boot || dialog_die   local retval
  umount ${INSTALLROOT} || dialog_die  
 }  
612    
613  install_do_reboot()   while [[ ${method} -le 2 ]]
614  {   do
615   reboot   method=$(dialog_main)
616     retval=$?
617     [[ ${retval} -eq 1 ]] && exit 1
618     if [[ ${retval} -eq 0 ]]
619     then
620     case ${method} in
621     "1") task_setup_system_menu ;;
622     "2") task_hardware_detection ;;
623     "3") install_do_reboot ;;
624     "4") /bin/bash --login -i ;;
625     esac
626     fi
627     done
628  }  }
629    
630  #################################################  run_install()
 #     Install Ablauf Scripte #  
 #################################################  
   
 run_install_normal()  
631  {  {
632   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  
   
  dialog_install_bootsector  
  install_bootsector_chroot  
633    
634   install_umount_rootfs   task_hardware_detection
  dialog_install_successful  
 }  
635    
636  run_install_auto()   case "${method}" in
637  {   auto)
638   dialog_hardware_detection   if [[ ${FLASHDISK} = 1 ]]
639     then
640     export BOOTHDD="${HDD}1"
641     export SWAPHDD=""
642     export ROOTHDD="${HDD}2"
643     export FORMAT_FILESYSTEM_BOOTHDD="f2fs"
644     export FORMAT_FILESYSTEM_ROOTHDD="ext2"
645     else
646     export BOOTHDD=""
647     export SWAPHDD=""
648     export ROOTHDD="${HDD}1"
649     export FORMAT_FILESYSTEM_BOOTHDD=""
650     export FORMAT_FILESYSTEM_ROOTHDD="${FORMAT_FILESYSTEM}"
651     fi
652     export INSTALL_METHOD="${method}"
653     ;;
654     normal)
655     export BOOTHDD="${HDD}1"
656     export SWAPHDD="${HDD}2"
657     export ROOTHDD="${HDD}3"
658     export FORMAT_FILESYSTEM_BOOTHDD="${FORMAT_FILESYSTEM}"
659     export FORMAT_FILESYSTEM_ROOTHDD="${FORMAT_FILESYSTEM}"
660     export INSTALL_METHOD="${method}"
661     ;;
662     single)
663     export BOOTHDD=""
664     export SWAPHDD=""
665     export ROOTHDD="${HDD}1"
666     export FORMAT_FILESYSTEM_BOOTHDD=""
667     export FORMAT_FILESYSTEM_ROOTHDD="${FORMAT_FILESYSTEM}"
668     export INSTALL_METHOD="${method}"
669     ;;
670     flash)
671     export BOOTHDD="${HDD}1"
672     export SWAPHDD=""
673     export ROOTHDD="${HDD}2"
674     export FORMAT_FILESYSTEM_BOOTHDD="${FORMAT_FILESYSTEM}"
675     export FORMAT_FILESYSTEM_ROOTHDD="f2fs"
676     export INSTALL_METHOD="${method}"
677     ;;
678     *)
679     die "Unknown install method '${method}', aborting."
680     ;;
681     esac
682    
683   dialog_setup_hdd_partitions_auto   task_setup_hdd_partitions
684   dialog_setup_hdd_format   dialog_setup_hdd_format
685   setup_hdd_format > /dev/null   setup_hdd_format > /dev/null
686   install_mount_rootfs   mount_rootfs
687   (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
688    
689   dialog_install_settings   dialog_install_settings
690   sleep 1   sleep 1
691   install_system_settings   install_system_settings
692   dialog_install_initrd   if is_initrd_supported
693   install_initrd_chroot   then
694     dialog_install_initrd
695     initrd_config
696     initrd_install
697     fi
698    
699   dialog_install_bootsector   dialog_install_bootsector
700   install_bootsector_chroot   bootloader_config
701     bootloader_install
702    
703   install_umount_rootfs   umount_rootfs
704   dialog_install_successful   dialog_install_successful
705  }  }
706    
707  # set some proper traps  # set some proper traps
708  trap "trap_exit" SIGINT SIGQUIT  trap "trap_exit" SIGINT SIGQUIT
709    
710  dialog_main  task_main
711    
712  exit 0  exit 0

Legend:
Removed from v.2429  
changed lines
  Added in v.2892