Magellan Linux

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

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

revision 2435 by niro, Tue Jan 7 14:23:24 2014 UTC revision 2481 by niro, Wed Jan 8 10:27:55 2014 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    LC_MESSAGES=C
13    
14  # include dir  # include dir
15  INSTALLER_LIBDIR="%LIBDIR%"  INSTALLER_LIBDIR="%LIBDIR%"
16    
# Line 108  dialog_warning() Line 110  dialog_warning()
110   fi   fi
111  }  }
112    
113  dialog_setup_hdd_info()  task_setup_system_menu()
 {  
  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()  
 {  
  local SHDD="${HDD//\/dev\/}"  
   
  messagebox -h $"[ Harddrive partitioning ]" \  
  $"\Z1Warning!\Zn\n\nAll data on disk [ \Z3${HDD}\Zn ] will be erased!"  
 }  
   
 dialog_setup_system_menu()  
114  {  {
115   local mode   local mode
116   local retval   local retval
117    
118   mode=$(menubox -h $"[ Harddrive partitioning ]" $"\nSelect an installation mode" \   mode="$(dialog_setup_system_menu)"
  $"1:Automatic setup (recommended)" \  
  ":" \  
  $":\Z1Expert modes:\Zn" \  
  $"2:Common IDE-disk (manual setup)")  
119   retval=$?   retval=$?
120   [[ ${retval} -eq 1 ]] && return 1   [[ ${retval} -eq 1 ]] && return 1
121   if [[ ${retval} -eq 0 ]]   if [[ ${retval} -eq 0 ]]
# Line 141  dialog_setup_system_menu() Line 123  dialog_setup_system_menu()
123   case "${mode}" in   case "${mode}" in
124   "1") run_install_auto ;;   "1") run_install_auto ;;
125   "2") run_install_normal ;;   "2") run_install_normal ;;
126   "") dialog_setup_system_menu;;   "") task_setup_system_menu;;
127   esac   esac
128   fi   fi
129  }  }
130    
131  dialog_hardware_detection()  task_hardware_detection()
132  {  {
133   local message   local message
134    
# Line 180  dialog_hardware_detection() Line 162  dialog_hardware_detection()
162   zotac*) message+=$"\n\Z2Zotac device detected.\Zn" ;;   zotac*) message+=$"\n\Z2Zotac device detected.\Zn" ;;
163   rangee) message+=$"\n\Z2Rangee device detected.\Zn" ;;   rangee) message+=$"\n\Z2Rangee device detected.\Zn" ;;
164   maxdata) message+=$"\n\Z2Maxdata device detected.\Zn" ;;   maxdata) message+=$"\n\Z2Maxdata device detected.\Zn" ;;
165   *) message+=$"\n \\ZnCommon device detected.\Zn" ;;   *) message+=$"\n\ZnCommon device detected.\Zn" ;;
166   esac   esac
167   if [[ ${FORMFACTOR} = laptop ]]   if [[ ${FORMFACTOR} = laptop ]]
168   then   then
169   message+=$"\n\ZnFormfactor Laptop, activating 'ondemand' powersaving  mode.\Zn"   message+=$"\n\ZnFormfactor Laptop, activating 'ondemand' powersaving mode.\Zn"
170   fi   fi
171    
172   messagebox -y 15 -h $"Detected hardware:" "${message}"   messagebox -y 12 -h $"Detected hardware:" "${message}"
173  }  }
174    
175  dialog_setup_hdd_partitions_manual()  task_setup_hdd_partitions_manual()
176  {  {
177   local i   local i
178   local retval   local retval
# Line 211  dialog_setup_hdd_partitions_manual() Line 193  dialog_setup_hdd_partitions_manual()
193   fi   fi
194  }  }
195    
196  dialog_setup_hdd_partitions_auto()  task_setup_hdd_partitions_auto()
197  {  {
198   local i   local i
199   local retval   local retval
# Line 246  install_meter() Line 228  install_meter()
228   return 0   return 0
229  }  }
230    
231  dialog_main()  task_main()
232  {  {
233   local method=0   local method=0
234   local retval   local retval
235    
236   while [[ ${method} -le 2 ]]   while [[ ${method} -le 2 ]]
237   do   do
238   method=$(menubox $"Configuration:" \   method=$(dialog_main)
  $"1:Install system" \  
  $"2:Show detected harddrives" \  
  $"3:Exit and reboot" \  
  $"4:Exit and drop into a shell")  
239   retval=$?   retval=$?
240   [[ ${retval} -eq 1 ]] && exit 1   [[ ${retval} -eq 1 ]] && exit 1
241   if [[ ${retval} -eq 0 ]]   if [[ ${retval} -eq 0 ]]
242   then   then
243   case ${method} in   case ${method} in
244   "1") dialog_setup_system_menu ;;   "1") task_setup_system_menu ;;
245   "2") dialog_hardware_detection ;;   "2") task_hardware_detection ;;
246   "3") install_do_reboot ;;   "3") install_do_reboot ;;
247   "4") /bin/bash --login -i ;;   "4") /bin/bash --login -i ;;
248   esac   esac
# Line 348  run_hardware_detection_disks() Line 326  run_hardware_detection_disks()
326   export ALL_CDROMS="$(get_hwinfo cdrom)"   export ALL_CDROMS="$(get_hwinfo cdrom)"
327  }  }
328    
 hdd_size_below_256mb()  
 {  
  local hdd="$1"  
  local size  
  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 ]]  
  then  
  retval="0"  
  else  
  retval="1"  
  fi  
   
  return "${retval}"  
 }  
   
329  setup_hdd_partitions_auto()  setup_hdd_partitions_auto()
330  {  {
331   ROOTHDD="${HDD}1"   ROOTHDD="${HDD}1"
# Line 438  EOF Line 398  EOF
398  setup_hdd_partitions_manual()  setup_hdd_partitions_manual()
399  {  {
400   ROOTHDD="${HDD}1"   ROOTHDD="${HDD}1"
401     SWAPHDD=""
402   ## hdds partitionieren manual   BOOTHDD=""
403   cfdisk ${HDD} || dialog_die   cfdisk ${HDD} || dialog_die
404  }  }
405    
# Line 468  install_system_image() Line 428  install_system_image()
428   popd > /dev/null   popd > /dev/null
429  }  }
430    
 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 ]]  
  then  
  # needed by grub-mkconfig on the first run  
  if [[ ! -f ${INSTALLROOT}/boot/grub/video.lst ]]  
  then  
  install -m0644 ${INSTALLROOT}/lib/grub/*/video.lst ${INSTALLROOT}/boot/grub/video.lst || dialog_die  
  fi  
   
  # set kernelopts  
  if [[ -f ${INSTALLROOT}/etc/conf.d/grub ]]  
  then  
  sed -i "s:^\(export GRUB_CMDLINE_LINUX_DEFAULT=\).*:\1\"${KERNELOPTS}\":" ${INSTALLROOT}/etc/conf.d/grub || dialog_die  
  else  
  echo "export GRUB_CMDLINE_LINUX_DEFAULT=\"${KERNELOPTS}\"" >  ${INSTALLROOT}/etc/conf.d/grub || dialog_die  
  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  
   
  # grub-legacy  
  else  
  ### grubconf schreiben  
  source ${INSTALLROOT}/boot/kernelversion  
   
  #for alx only  
  if [ -e ${INSTALLROOT}/etc/alx_version ]  
  then  
  OLD_ALXVER="${ALXVER}"  
  source ${INSTALLROOT}/etc/alx_version  
  KRNVER="ALX-${ALXVER}"  
  ALXVER="${OLD_ALXVER}"  
  fi  
   
  [[ -z ${KRNVER} ]] && KRNVER="AutoSta_LX"  
  [[ -z ${KRNINITRD} ]] && KRNINITRD="initrd"  
  [[ -z ${KRNIMG} ]] && KRNIMG="vmlinuz"  
   
  # uuid support  
  if is_uuid_supported  
  then  
  my_roothdd="UUID=$(get_uuid ${ROOTHDD})"  
  else  
  my_roothdd="${ROOTHDD}"  
  fi  
   
  : > ${grubconf} || dialog_die  
  echo "default 0" >> ${grubconf} || dialog_die  
  echo "timeout 3" >> ${grubconf} || dialog_die  
  # using current root password  
  echo "password --md5 $(cat ${INSTALLROOT}/etc/shadow | grep root | cut -d: -f2)"  >> ${grubconf} || dialog_die  
   
  echo  >> ${grubconf} || dialog_die  
  echo "# normal boot" >> ${grubconf} || dialog_die  
  echo "title ${KRNVER}" >> ${grubconf} || dialog_die  
  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  
   
  echo >> ${grubconf} || dialog_die  
  echo "# admin boot" >> ${grubconf} || dialog_die  
  echo "title ${KRNVER} - Re-run hardware-detection" >> ${grubconf} || dialog_die  
  echo "lock"  >> ${grubconf} || dialog_die  
  echo "root (hd0,0)" >> ${grubconf} || dialog_die  
  echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS} hardware-auto-detection" >> ${grubconf} || dialog_die  
  if is_initrd_supported  
  then  
  echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || dialog_die  
  fi  
   
  echo >> ${grubconf} || dialog_die  
  echo "title ${KRNVER} - Reset *all* local settings" >> ${grubconf} || dialog_die  
  echo "lock"  >> ${grubconf} || dialog_die  
  echo "root (hd0,0)" >> ${grubconf} || dialog_die  
  echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS} alx-reset-settings" >> ${grubconf} || dialog_die  
  if is_initrd_supported  
  then  
  echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || dialog_die  
  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  
  fi  
   
  ## 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  
   
  if [[ ${FORMFACTOR} = laptop ]]  
  then  
  OTHERMODS="acpi-cpufreq cpufreq_ondemand cpufreq_conservative cpufreq_powersave"  
  fi  
   
  # install an appropriate uvesafb.conf  
  install -d ${INSTALLROOT}/etc/modprobe.d || dialog_die  
  echo "options uvesafb mode_option=1024x768-32@60 scroll=ywrap" > ${INSTALLROOT}/etc/modprobe.d/uvesafb.conf || dialog_die  
   
  # install an appropriate viafb.conf  
  echo "options viafb viafb_mode=1024x768 viafb_refresh=60" > ${INSTALLROOT}/etc/modprobe.d/viafb.conf || dialog_die  
   
  # install an appropriate i810fb.conf  
  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  
   
  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  
   
  ## enters 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_uuid_supported()  
 {  
  if [[ -x $(type -P busybox.mkinitrd) ]]  
  then  
  # only detect uuids if supported  
  if [[ ! -z $(busybox.mkinitrd | grep blkid) ]]  
  then  
  return 0  
  fi  
  fi  
   
  return 1  
 }  
   
 get_uuid()  
 {  
  local UUID  
  local SEC_TYPE  
  local TYPE  
   
  local dev="$1"  
  [[ -z ${dev} ]] && dialog_die "no dev given"  
   
  # check if given device is already an UUID  
  if [[ ${dev/UUID=/}x != ${dev}x ]]  
  then  
  eval "${dev}"  
  else  
  eval $(busybox.mkinitrd blkid ${dev} | grep "${dev}:" | sed 's/.*:\ //')  
  fi  
  echo "${UUID}"  
 }  
   
431  install_system_settings()  install_system_settings()
432  {  {
433   # schreibe fstab   local CONFIG
434   if is_uuid_supported  
435   then   # write fstab
436   echo -e "UUID=$(get_uuid ${ROOTHDD})\t/\t${FORMAT_FILESYSTEM}\tnoatime\t0 0" >> ${INSTALLROOT}/etc/fstab || dialog_die   CONFIG="${INSTALLROOT}/etc/fstab"
437   else   clearconfig
438   echo -e "${ROOTHDD}\t/\t${FORMAT_FILESYSTEM}\tnoatime\t0 0" >> ${INSTALLROOT}/etc/fstab || dialog_die   addconfig -e "UUID=$(get_uuid ${ROOTHDD})\t/\t${FORMAT_FILESYSTEM}\tnoatime,noauto\t1 1"
439   fi   addconfig -e "proc\t/proc\tproc\tdefaults\t0 0"
440   # not needed busybox loads all with swapon -a, even if not mentioned in fstab   addconfig -e "shm\t/dev/shm\ttmpfs\tdefaults\t0 0"
  #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  
441    
442   # install network config skeleton   # install network config skeleton
443   install -m0644 ${INSTALLROOT}/etc/alxconfig-ng/skel/net/net.eth0 ${INSTALLROOT}/etc/conf.d/ || dialog_die   CONFIG="${INSTALLROOT}/etc/conf.d/net.eth0"
444     clearconfig
445     addconfig 'ONBOOT="yes"'
446     addconfig 'NETWORKING="dhcp"'
447    
448   # intel framebufer quirk   # intel framebuffer quirk
449   if [[ -e /proc/fb ]]   if [ -e ${INSTALLROOT}/etc/splash/splash.conf ]
450   then   then
451   if [[ ! -z $(grep 'inteldrmfb' /proc/fb) ]]   if [ -e /proc/fb ]
452   then   then
453   fbdev=$(grep 'inteldrmfb' /proc/fb | sed 's:\([0-9]\).*:\1:')   if [[ ! -z $(grep 'inteldrmfb' /proc/fb) ]]
  if [[ ${fbdev} != 0 ]]  
454   then   then
455   sed -i "s:^\(SPLASH_DEV=\).*:\1\"/dev/fb${fbdev}\":" ${INSTALLROOT}/etc/splash/splash.conf || dialog_die   fbdev=$(grep 'inteldrmfb' /proc/fb | sed 's:\([0-9]\).*:\1:')
456     if [[ ${fbdev} != 0 ]]
457     then
458     sed -i "s:^\(SPLASH_DEV=\).*:\1\"/dev/fb${fbdev}\":" ${INSTALLROOT}/etc/splash/splash.conf || dialog_die
459     fi
460   fi   fi
461   fi   fi
462   fi   fi
# Line 721  install_do_reboot() Line 479  install_do_reboot()
479    
480  run_install_normal()  run_install_normal()
481  {  {
482   dialog_hardware_detection   task_hardware_detection
483    
484   dialog_setup_hdd_partitions_manual   task_setup_hdd_partitions_manual
485   dialog_setup_hdd_format   dialog_setup_hdd_format
486   setup_hdd_format > /dev/null   setup_hdd_format > /dev/null
487   install_mount_rootfs   install_mount_rootfs
# Line 732  run_install_normal() Line 490  run_install_normal()
490   dialog_install_settings   dialog_install_settings
491   sleep 1   sleep 1
492   install_system_settings   install_system_settings
493   dialog_install_initrd   if is_initrd_supported
494   install_initrd_chroot   then
495     dialog_install_initrd
496     initrd_config
497     initrd_install
498     fi
499    
500   dialog_install_bootsector   dialog_install_bootsector
501   install_bootsector_chroot   bootloader_config
502     bootloader_install
503    
504   install_umount_rootfs   install_umount_rootfs
505   dialog_install_successful   dialog_install_successful
# Line 744  run_install_normal() Line 507  run_install_normal()
507    
508  run_install_auto()  run_install_auto()
509  {  {
510   dialog_hardware_detection   task_hardware_detection
511    
512   dialog_setup_hdd_partitions_auto   task_setup_hdd_partitions_auto
513   dialog_setup_hdd_format   dialog_setup_hdd_format
514   setup_hdd_format > /dev/null   setup_hdd_format > /dev/null
515   install_mount_rootfs   install_mount_rootfs
# Line 755  run_install_auto() Line 518  run_install_auto()
518   dialog_install_settings   dialog_install_settings
519   sleep 1   sleep 1
520   install_system_settings   install_system_settings
521   dialog_install_initrd   if is_initrd_supported
522   install_initrd_chroot   then
523     dialog_install_initrd
524     initrd_config
525     initrd_install
526     fi
527    
528   dialog_install_bootsector   dialog_install_bootsector
529   install_bootsector_chroot   bootloader_config
530     bootloader_install
531    
532   install_umount_rootfs   install_umount_rootfs
533   dialog_install_successful   dialog_install_successful
# Line 768  run_install_auto() Line 536  run_install_auto()
536  # set some proper traps  # set some proper traps
537  trap "trap_exit" SIGINT SIGQUIT  trap "trap_exit" SIGINT SIGQUIT
538    
539  dialog_main  task_main
540    
541  exit 0  exit 0

Legend:
Removed from v.2435  
changed lines
  Added in v.2481