Magellan Linux

Diff of /alx-src/trunk/alxinstall-ng/bin/alxinstall-ng.sh.in

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

revision 6825 by niro, Thu Jul 23 10:50:11 2015 UTC revision 6834 by niro, Thu Jul 23 12:25:33 2015 UTC
# Line 10  MLIBDIR="/usr/lib/alxinstall-ng" Line 10  MLIBDIR="/usr/lib/alxinstall-ng"
10  source /mnt/cdrom/system/images.conf  source /mnt/cdrom/system/images.conf
11    
12  # includes  # includes
13    source ${MLIBDIR}/functions/generic.sh
14  source ${MLIBDIR}/functions/hwdetection.sh  source ${MLIBDIR}/functions/hwdetection.sh
15    
16  ### System/Config Version  ### System/Config Version
# Line 58  die() Line 59  die()
59   ERROR=$1   ERROR=$1
60   RETVAL=$?   RETVAL=$?
61   dialog_install_failure   dialog_install_failure
62     trap_exit
63   exit 1   exit 1
64  }  }
65    
# Line 81  dialog_warning() Line 83  dialog_warning()
83    
84  dialog_setup_hdd_info()  dialog_setup_hdd_info()
85  {  {
86     case "${INSTALL_METHOD}" in
87     auto)
88     dialog_setup_hdd_info_auto
89     dialog_setup_hdd_create_partitions
90     ;;
91     normal) dialog_setup_hdd_info_normal ;;
92     single) dialog_setup_hdd_info_single ;;
93     esac
94    }
95    
96    dialog_setup_hdd_info_normal()
97    {
98   local SHDD="$(echo ${HDD} | sed 's/\/dev\///')"   local SHDD="$(echo ${HDD} | sed 's/\/dev\///')"
99    
100   dialog \   dialog \
# Line 217  dialog_hardware_detection() Line 231  dialog_hardware_detection()
231   fi   fi
232  }  }
233    
234  dialog_setup_hdd_partitions_manuell()  dialog_setup_hdd_partitions()
235  {  {
236   local i   local i
237    
# Line 250  dialog_setup_hdd_partitions_manuell() Line 264  dialog_setup_hdd_partitions_manuell()
264   if [[ ${RES} -eq 0 ]]   if [[ ${RES} -eq 0 ]]
265   then   then
266   dialog_setup_hdd_info   dialog_setup_hdd_info
267   setup_hdd_partitions_manuell   setup_hdd_partitions
  fi  
  fi  
 }  
   
 dialog_setup_hdd_partitions_manuell_single()  
 {  
  local i  
   
  if [[ -z ${ALL_DISKS} ]]  
  then  
  dialog \  
  --backtitle "${TITLE}" \  
  --ok-label "Beenden" \  
  --msgbox "Kein geeignetes Laufwerk gefunden.\nDie Installation ist fehlgeschlagen." 6 70  
  exit 1  
  else  
   
  echo "dialog \\" > /tmp/hddtmp.sh  
  echo "--backtitle \"${TITLE}\" \\" >> /tmp/hddtmp.sh  
  echo "--ok-label \"Weiter\" \\" >> /tmp/hddtmp.sh  
  echo "--cancel-label \"Beenden\" \\" >> /tmp/hddtmp.sh  
  echo "--stdout \\" >> /tmp/hddtmp.sh  
  echo "--menu \"Installations Laufwerk auswaehlen:\" 10 70 3 \\" >> /tmp/hddtmp.sh  
   
  for i in ${ALL_DISKS}  
  do  
  echo "\"${i}\" \"\" \\" >> /tmp/hddtmp.sh  
  done  
  echo -e "\n" >> /tmp/hddtmp.sh  
   
  chmod a+x /tmp/hddtmp.sh  
  HDD="$(/tmp/hddtmp.sh)"  
  RES=$?  
  [[ ${RES} -eq 1 ]] && return 1  
  if [[ ${RES} -eq 0 ]]  
  then  
  dialog_setup_hdd_info_single  
  setup_hdd_partitions_manuell_single  
  fi  
  fi  
 }  
   
 dialog_setup_hdd_partitions_auto()  
 {  
  local i  
   
  if [[ -z ${ALL_DISKS} ]]  
  then  
  dialog \  
  --backtitle "${TITLE}" \  
  --ok-label "Beenden" \  
  --msgbox "Kein geeignetes Laufwerk gefunden.\nDie Installation ist fehlgeschlagen." 6 70  
  exit 1  
  else  
   
  echo "dialog \\" > /tmp/hddtmp.sh  
  echo "--backtitle \"${TITLE}\" \\" >> /tmp/hddtmp.sh  
  echo "--ok-label \"Weiter\" \\" >> /tmp/hddtmp.sh  
  echo "--cancel-label \"Beenden\" \\" >> /tmp/hddtmp.sh  
  echo "--stdout \\" >> /tmp/hddtmp.sh  
  echo "--menu \"Installations Laufwerk auswaehlen:\" 10 70 3 \\" >> /tmp/hddtmp.sh  
   
  for i in ${ALL_DISKS}  
  do  
  echo "\"${i}\" \"\" \\" >> /tmp/hddtmp.sh  
  done  
  echo -e "\n" >> /tmp/hddtmp.sh  
   
  chmod a+x /tmp/hddtmp.sh  
  HDD="$(/tmp/hddtmp.sh)"  
  RES=$?  
  [[ ${RES} -eq 1 ]] && return 1  
  if [[ ${RES} -eq 0 ]]  
  then  
  dialog_setup_hdd_info_auto  
  dialog_setup_hdd_create_partitions  
  setup_hdd_partitions_auto  
268   fi   fi
269   fi   fi
270  }  }
# Line 538  hdd_size_below_256mb() Line 475  hdd_size_below_256mb()
475   return "${retval}"   return "${retval}"
476  }  }
477    
478  setup_hdd_partitions_auto()  setup_hdd_partitions()
479  {  {
480   ROOTHDD="${HDD}1"   case "${INSTALL_METHOD}" in
481     normal)
482     BOOTHDD="${HDD}1"
483     SWAPHDD="${HDD}2"
484     ROOTHDD="${HDD}3"
485     ;;
486    
487   # run this only if FDISKPARTITIONBELOW256MB is not already 1   single|auto)
488   if [[ ${FDISKPARTIONBELOW256MB} != 1 ]]   BOOTHDD=""
489     SWAPHDD=""
490     ROOTHDD="${HDD}1"
491     ;;
492     esac
493    
494     if [[ ${INSTALL_METHOD} = auto ]]
495   then   then
496   if hdd_size_below_256mb ${HDD}   # run this only if FDISKPARTITIONBELOW256MB is not already 1
497     if [[ ${FDISKPARTIONBELOW256MB} != 1 ]]
498   then   then
499   FDISKPARTIONBELOW256MB=1   if hdd_size_below_256mb ${HDD}
500   else   then
501   FDISKPARTIONBELOW256MB=0   FDISKPARTIONBELOW256MB=1
502     else
503     FDISKPARTIONBELOW256MB=0
504     fi
505   fi   fi
  fi  
506    
507   ## delete disk   ## delete disk
508   dd if=/dev/zero of=${HDD} count=1 &> /dev/null || die   dd if=/dev/zero of=${HDD} count=1 &> /dev/null || die
509    
510   if [[ ${FDISKPARTIONBELOW256MB} = 1 ]]   if [[ ${FDISKPARTIONBELOW256MB} = 1 ]]
511   then   then
512   ## setup one bootable partition   ## setup one bootable partition
513   #1. n= new disk   #1. n= new disk
514   #2. p= primary disk   #2. p= primary disk
515   #3. 1= first partition   #3. 1= first partition
516   #4. 2= default sector start // small disk needs more space for grub2 mbr sector   #4. 2= default sector start // small disk needs more space for grub2 mbr sector
517   #5. ''= defaul sector end   #5. ''= defaul sector end
518   #6. a= bootable flag   #6. a= bootable flag
519   #7. 1= boot flag for partition 1   #7. 1= boot flag for partition 1
520   #8. w= write/quit   #8. w= write/quit
521   fdisk ${HDD} &> /dev/null << EOF   fdisk ${HDD} &> /dev/null << EOF
522  n  n
523  p  p
524  1  1
# Line 577  a Line 528  a
528  1  1
529  w  w
530  EOF  EOF
531   else   else
532   ## setup one bootable partition   ## setup one bootable partition
533   #1. n= new disk   #1. n= new disk
534   #2. p= primary disk   #2. p= primary disk
535   #3. 1= first partition   #3. 1= first partition
536   #4. ''= default sector start   #4. ''= default sector start
537   #5. ''= defaul sector end   #5. ''= defaul sector end
538   #6. a= bootable flag   #6. a= bootable flag
539   #7. 1= boot flag for partition 1   #7. 1= boot flag for partition 1
540   #8. w= write/quit   #8. w= write/quit
541   fdisk ${HDD} &> /dev/null << EOF   fdisk ${HDD} &> /dev/null << EOF
542  n  n
543  p  p
544  1  1
# Line 597  a Line 548  a
548  1  1
549  w  w
550  EOF  EOF
551     fi
552     else
553     ## hdds partitionieren manuell
554     cfdisk ${HDD} || die
555   fi   fi
556  }  }
557    
 setup_hdd_partitions_manuell()  
 {  
  case "${INSTALL_METHOD}" in  
  normal)  
  BOOTHDD="${HDD}1"  
  SWAPHDD="${HDD}2"  
  ROOTHDD="${HDD}3"  
  ;;  
   
  single|auto)  
  ROOTHDD="${HDD}1"  
  ;;  
  esac  
   
  ## hdds partitionieren manuell  
  cfdisk ${HDD} || die  
 }  
   
558  setup_hdd_format()  setup_hdd_format()
559  {  {
560   if [[ -n ${SWAPHDD} ]]   if [[ -n ${SWAPHDD} ]]
# Line 626  setup_hdd_format() Line 563  setup_hdd_format()
563   fi   fi
564   if [[ -n ${BOOTHDD} ]]   if [[ -n ${BOOTHDD} ]]
565   then   then
566   mke2fs -j -q ${BOOTHDD} || die   mkfs.${FORMAT_FILESYSTEM} -q ${BOOTHDD} || die
567   fi   fi
568   if [[ -n ${ROOTHDD} ]]   if [[ -n ${ROOTHDD} ]]
569   then   then
570   mke2fs -j -q ${ROOTHDD} || die   mkfs.${FORMAT_FILESYSTEM} -q ${ROOTHDD} || die
571   fi   fi
572  }  }
573    
# Line 663  install_bootsector_chroot() Line 600  install_bootsector_chroot()
600   local my_roothdd   local my_roothdd
601   local grubconf=${INSTALLPATH}/boot/grub/grub.conf   local grubconf=${INSTALLPATH}/boot/grub/grub.conf
602   local grub2conf=/boot/grub/grub.cfg   local grub2conf=/boot/grub/grub.cfg
603     local CONFIG
604    
605   # check for grub2   # check for grub2
606   if [[ -f ${INSTALLPATH}/sbin/grub-mkconfig ]]   if [[ -f ${INSTALLPATH}/sbin/grub-mkconfig ]]
# Line 682  install_bootsector_chroot() Line 620  install_bootsector_chroot()
620   echo "export GRUB_CMDLINE_LINUX_DEFAULT=\"${KERNELOPTS}\"" >  ${INSTALLPATH}/etc/conf.d/grub || die   echo "export GRUB_CMDLINE_LINUX_DEFAULT=\"${KERNELOPTS}\"" >  ${INSTALLPATH}/etc/conf.d/grub || die
621   echo "export GRUB_GFXPAYLOAD_LINUX=\"${GRUB2GFXPAYLOAD}\"" >>  ${INSTALLPATH}/etc/conf.d/grub || die   echo "export GRUB_GFXPAYLOAD_LINUX=\"${GRUB2GFXPAYLOAD}\"" >>  ${INSTALLPATH}/etc/conf.d/grub || die
622   fi   fi
623   echo 'grub-mkdevicemap' > ${INSTALLPATH}/root/.installrc || die   CONFIG=${INSTALLPATH}/.installrc
624   echo "LC_ALL=C grub-mkconfig -o ${grub2conf}  &> /dev/null" >> ${INSTALLPATH}/root/.installrc || die   clearconfig
625   echo "grub-install --no-floppy ${HDD} &> /dev/null" >> ${INSTALLPATH}/root/.installrc || die   addconfig 'grub-mkdevicemap'
626   echo "exit 0" >> ${INSTALLPATH}/root/.installrc || die   addconfig "LC_ALL=C grub-mkconfig -o ${grub2conf}  &> /dev/null"
627     addconfig "grub-install --no-floppy ${HDD} &> /dev/null"
628     addconfig "exit 0"
629    
630   # grub-legacy   # grub-legacy
631   else   else
# Line 713  install_bootsector_chroot() Line 653  install_bootsector_chroot()
653   my_roothdd="${ROOTHDD}"   my_roothdd="${ROOTHDD}"
654   fi   fi
655    
656   : > ${grubconf} || die   CONFIG="${grubconf}"
657   echo "default 0" >> ${grubconf} || die   clearconfig
658   echo "timeout 3" >> ${grubconf} || die   addconfig "default 0"
659     addconfig "timeout 3"
660   # using current root password   # using current root password
661   echo "password --md5 $(cat ${INSTALLPATH}/etc/shadow | grep root | cut -d: -f2)"  >> ${grubconf} || die   addconfig "password --md5 $(cat ${INSTALLPATH}/etc/shadow | grep root | cut -d: -f2)"
662     addconfig
663   echo  >> ${grubconf} || die   addconfig "# normal boot"
664   echo "# normal boot" >> ${grubconf} || die   addconfig "title ${KRNVER}"
665   echo "title ${KRNVER}" >> ${grubconf} || die   addconfig "root (hd0,0)"
666   echo "root (hd0,0)" >> ${grubconf} || die   addconfig "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS}"
  echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS}" >> ${grubconf} || die  
667   if is_initrd_supported   if is_initrd_supported
668   then   then
669   echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die   addconfig "initrd /boot/${KRNINITRD}"
670   fi   fi
671     addconfig
672   echo >> ${grubconf} || die   addconfig "# admin boot"
673   echo "# admin boot" >> ${grubconf} || die   addconfig "title ${KRNVER} - Re-run hardware-detection"
674   echo "title ${KRNVER} - Re-run hardware-detection" >> ${grubconf} || die   addconfig "lock"
675   echo "lock"  >> ${grubconf} || die   addconfig "root (hd0,0)"
676   echo "root (hd0,0)" >> ${grubconf} || die   addconfig "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS} hardware-auto-detection"
  echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS} hardware-auto-detection" >> ${grubconf} || die  
677   if is_initrd_supported   if is_initrd_supported
678   then   then
679   echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die   addconfig "initrd /boot/${KRNINITRD}"
680   fi   fi
681     addconfig
682   echo >> ${grubconf} || die   addconfig "title ${KRNVER} - Reset *all* local settings"
683   echo "title ${KRNVER} - Reset *all* local settings" >> ${grubconf} || die   addconfig "lock"
684   echo "lock"  >> ${grubconf} || die   addconfig "root (hd0,0)"
685   echo "root (hd0,0)" >> ${grubconf} || die   addconfig "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS} alx-reset-settings"
  echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS} alx-reset-settings" >> ${grubconf} || die  
686   if is_initrd_supported   if is_initrd_supported
687   then   then
688   echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die   addconfig "initrd /boot/${KRNINITRD}"
689   fi   fi
690    
691   # write bootsector chrooted (lfs/magellan)   # write bootsector chrooted (lfs/magellan)
692   cat > ${INSTALLPATH}/root/.installrc << CHROOTEOF   CONFIG=${INSTALLPATH}/.installrc
693  /usr/sbin/grub --no-floppy --batch << "EOF" 1> /dev/null 2> /dev/null   clearconfig
694  root (hd0,0)   addconfig '/usr/sbin/grub --no-floppy --batch << "EOF" 1> /dev/null 2> /dev/null'
695  setup (hd0)   addconfig 'root (hd0,0)'
696  quit   addconfig 'setup (hd0)'
697  EOF   addconfig 'quit'
698  exit 0   addconfig 'EOF'
699  CHROOTEOF   addconfig 'exit 0'
700   fi   fi
701    
702   ## enters chroot   ## enter chroot
703   mount -t proc proc ${INSTALLPATH}/proc   enter_chroot_installrc
  mount -t sysfs sysfs ${INSTALLPATH}/sys  
  mount -o bind /dev ${INSTALLPATH}/dev  
  chroot ${INSTALLPATH} /bin/bash --rcfile /root/.installrc -i  
  umount ${INSTALLPATH}/proc  
  umount ${INSTALLPATH}/sys  
  umount ${INSTALLPATH}/dev  
  rm ${INSTALLPATH}/root/.installrc  
704  }  }
705    
706  is_initrd_supported()  is_initrd_supported()
# Line 781  is_initrd_supported() Line 712  is_initrd_supported()
712    
713  install_initrd_chroot()  install_initrd_chroot()
714  {  {
715     local CONFIG
716    
717   # only generate initrds if the cmd exists   # only generate initrds if the cmd exists
718   is_initrd_supported || return 0   is_initrd_supported || return 0
719    
# Line 806  install_initrd_chroot() Line 739  install_initrd_chroot()
739   fi   fi
740    
741   # install an appropriate uvesafb.conf   # install an appropriate uvesafb.conf
742   install -d ${INSTALLPATH}/etc/modprobe.d || die   CONFIG=${INSTALLPATH}/etc/modprobe.d/uvesafb.conf
743   echo "options uvesafb mode_option=1024x768-32@60 scroll=ywrap" > ${INSTALLPATH}/etc/modprobe.d/uvesafb.conf || die   clearconfig
744     addconfig "options uvesafb mode_option=1024x768-32@60 scroll=ywrap"
745    
746   # install an appropriate viafb.conf   # install an appropriate viafb.conf
747   echo "options viafb viafb_mode=1024x768 viafb_refresh=60" > ${INSTALLPATH}/etc/modprobe.d/viafb.conf || die   CONFIG=${INSTALLPATH}/etc/modprobe.d/viafb.conf
748     clearconfig
749     addconfig "options viafb viafb_mode=1024x768 viafb_refresh=60"
750    
751   # install an appropriate i810fb.conf   # install an appropriate i810fb.conf
752   echo "options i810fb xres=1024 yres=768 bpp=16 mtrr=1 hsync1=30 hsync2=62 vsync1=30 vsync2=60"  > ${INSTALLPATH}/etc/modprobe.d/i810fb.conf || die   CONFIG=${INSTALLPATH}/etc/modprobe.d/i810fb.conf
753     clearconfig
754   cat > ${INSTALLPATH}/root/.installrc << CHROOTEOF   addconfig "options i810fb xres=1024 yres=768 bpp=16 mtrr=1 hsync1=30 hsync2=62 vsync1=30 vsync2=60"
755  echo "MODULES=\"${FORMAT_FILESYSTEM} ${DISKMODS} ${OLDATAMODS} ${PATAMODS} ${SATAMODS} ${DRMMODS} ${FBMODS} ${OTHERMODS}\"" > /etc/conf.d/mkinitrd  
756  mkinitrd -f /boot/$(readlink /boot/initrd) $(readlink /boot/vmlinuz | sed "s:kernel-::g") > /dev/null   CONFIG=${INSTALLPATH}/.installrc
757  exit 0   clearconfig
758  CHROOTEOF   addconfig 'echo "MODULES=\"${FORMAT_FILESYSTEM} ${DISKMODS} ${OLDATAMODS} ${PATAMODS} ${SATAMODS} ${DRMMODS} ${FBMODS} ${OTHERMODS}\"" > /etc/conf.d/mkinitrd'
759     addconfig 'mkinitrd -f /boot/$(readlink /boot/initrd) $(readlink /boot/vmlinuz | sed "s:kernel-::g") > /dev/null'
760   ## enters chroot   addconfig 'exit 0'
761   mount -t proc proc ${INSTALLPATH}/proc   ## enter chroot
762   mount -t sysfs sysfs ${INSTALLPATH}/sys   enter_chroot_installrc
  mount -o bind /dev ${INSTALLPATH}/dev  
  chroot ${INSTALLPATH} /bin/bash --rcfile /root/.installrc -i  
  umount ${INSTALLPATH}/proc  
  umount ${INSTALLPATH}/sys  
  umount ${INSTALLPATH}/dev  
  rm ${INSTALLPATH}/root/.installrc  
763  }  }
764    
765  is_uuid_supported()  is_uuid_supported()
# Line 966  run_install() Line 896  run_install()
896    
897   dialog_hardware_detection   dialog_hardware_detection
898    
899   case "${INSTALL_METHOD}" in   dialog_setup_hdd_partitions
  auto) dialog_setup_hdd_partitions_auto ;;  
  *) dialog_setup_hdd_partitions_manuell ;;  
  esac  
900   dialog_setup_hdd_format   dialog_setup_hdd_format
901   setup_hdd_format > /dev/null   setup_hdd_format > /dev/null
902   install_mount_rootfs   install_mount_rootfs
# Line 987  run_install() Line 914  run_install()
914   dialog_install_successful   dialog_install_successful
915  }  }
916    
917    # set some proper traps
918    trap "trap_exit" SIGINT SIGQUIT
919    
920  dialog_main  dialog_main
921    
922  exit 0  exit 0

Legend:
Removed from v.6825  
changed lines
  Added in v.6834