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 6821 by niro, Thu Jul 23 08:57:15 2015 UTC revision 6828 by niro, Thu Jul 23 11:39:57 2015 UTC
# Line 16  source ${MLIBDIR}/functions/hwdetection. Line 16  source ${MLIBDIR}/functions/hwdetection.
16  VERSION="@@VERSION@@"  VERSION="@@VERSION@@"
17  TITLE="alxinstall-ng - ${VERSION}"  TITLE="alxinstall-ng - ${VERSION}"
18    
19    # locations
20  CDPATH="/mnt/cdrom"  CDPATH="/mnt/cdrom"
21  INSTALLPATH="/mnt/magellan"  INSTALLPATH="/mnt/magellan"
22    
23  ### linecount of system.tar.gz -1 !  # default system settings
 CURRENTLINE=0  
 #TOTALLINES=11072 # -> now in images.conf  
   
24  # standard kernel opts  # standard kernel opts
25  KERNELOPTS="quiet video=1024x768"  DEFAULT_KERNELOPTS="quiet video=1024x768"
26    
27  # grub options  # grub options
28  GRUBLEGACYOPTS=""  DEFAULT_GRUBLEGACYOPTS=""
29  GRUB2OPTS=""  DEFAULT_GRUB2OPTS=""
30  GRUB2GFXPAYLOAD="1024x768x16,1024x768"  DEFAULT_GRUB2GFXPAYLOAD="1024x768x16,1024x768"
   
 # fdisk options  
 FDISKPARTIONBELOW256MB=0  
31    
32  # default specialdevices  # default specialdevices
33  SPECIALDEVICE=""  DEFAULT_FORMFACTOR="desktop"
 FORMFACTOR="desktop"  
34    
35  # target filesystem  # target filesystem
36  FORMAT_FILESYSTEM="ext4"  DEFAULT_FORMAT_FILESYSTEM="ext4"
37    
38    # initialize global variables so they are exportable
39    INSTALL_METHOD=""
40    KERNELOPTS=""
41    GRUBLEGACYOPTS=""
42    GRUB2OPTS=""
43    GRUB2GFXPAYLOAD=""
44    FORMFACTOR=""
45    FORMAT_FILESYSTEM=""
46    FDISKPARTIONBELOW256MB=0
47    SPECIALDEVICE=""
48    ### linecount of system.tar.gz -1 !
49    CURRENTLINE=0
50    #TOTALLINES=11072 # -> now in images.conf
51    
52  #################################################  #################################################
53  #  DIALOG BOXES #  #  DIALOG BOXES #
# Line 73  dialog_warning() Line 81  dialog_warning()
81    
82  dialog_setup_hdd_info()  dialog_setup_hdd_info()
83  {  {
84     case "${INSTALL_METHOD}" in
85     auto)
86     dialog_setup_hdd_info_auto
87     dialog_setup_hdd_create_partitions
88     ;;
89     normal) dialog_setup_hdd_info_normal ;;
90     single) dialog_setup_hdd_info_single ;;
91     esac
92    }
93    
94    dialog_setup_hdd_info_normal()
95    {
96   local SHDD="$(echo ${HDD} | sed 's/\/dev\///')"   local SHDD="$(echo ${HDD} | sed 's/\/dev\///')"
97    
98   dialog \   dialog \
# Line 87  dialog_setup_hdd_info() Line 107  dialog_setup_hdd_info()
107   Bitte ${SHDD}1 als \Z3bootable\Zn markieren." 12 81   Bitte ${SHDD}1 als \Z3bootable\Zn markieren." 12 81
108  }  }
109    
110  dialog_setup_hdd_info_simple()  dialog_setup_hdd_info_single()
111  {  {
112   local SHDD="$(echo $HDD | sed 's/\/dev\///')"   local SHDD="$(echo $HDD | sed 's/\/dev\///')"
113    
# Line 130  dialog_setup_system_menu() Line 150  dialog_setup_system_menu()
150   "" "" \   "" "" \
151   "" "\Z1Experten Modi:\Zn" \   "" "\Z1Experten Modi:\Zn" \
152   "2" "Normale IDE-Disk (Manuell)" \   "2" "Normale IDE-Disk (Manuell)" \
153   "3" "Flash-Speicher (Manuell)")   "3" "Normale IDE Disk (Single)")
154   RES=$?   RES=$?
155   [[ ${RES} -eq 1 ]] && return 1   [[ ${RES} -eq 1 ]] && return 1
156   if [[ ${RES} -eq 0 ]]   if [[ ${RES} -eq 0 ]]
157   then   then
158   case "${i}" in   case "${i}" in
159   "1") run_install_auto ;;   "1") run_install auto ;;
160   "2") run_install_normal ;;   "2") run_install normal ;;
161   "3") run_install_simple ;;   "3") run_install single ;;
162   "") dialog_setup_system_menu;;   "") dialog_setup_system_menu;;
163   esac   esac
164   fi   fi
# Line 209  dialog_hardware_detection() Line 229  dialog_hardware_detection()
229   fi   fi
230  }  }
231    
232  dialog_setup_hdd_partitions_manuell()  dialog_setup_hdd_partitions()
233  {  {
234   local i   local i
235    
# Line 242  dialog_setup_hdd_partitions_manuell() Line 262  dialog_setup_hdd_partitions_manuell()
262   if [[ ${RES} -eq 0 ]]   if [[ ${RES} -eq 0 ]]
263   then   then
264   dialog_setup_hdd_info   dialog_setup_hdd_info
265   setup_hdd_partitions_manuell   setup_hdd_partitions
  fi  
  fi  
 }  
   
 dialog_setup_hdd_partitions_manuell_simple()  
 {  
  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_simple  
  setup_hdd_partitions_manuell_simple  
  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  
266   fi   fi
267   fi   fi
268  }  }
# Line 426  dialog_main() Line 369  dialog_main()
369  run_hardware_detection()  run_hardware_detection()
370  {  {
371   local hwinfo   local hwinfo
   
372   hwinfo="$(hwinfo --bios --storage --pci --gfxcard --sys)"   hwinfo="$(hwinfo --bios --storage --pci --gfxcard --sys)"
373    
374   # check for special devices/clients:   # check for special devices/clients:
# Line 531  hdd_size_below_256mb() Line 473  hdd_size_below_256mb()
473   return "${retval}"   return "${retval}"
474  }  }
475    
476  setup_hdd_partitions_auto()  setup_hdd_partitions()
477  {  {
478   ROOTHDD="${HDD}1"   case "${INSTALL_METHOD}" in
479     normal)
480     BOOTHDD="${HDD}1"
481     SWAPHDD="${HDD}2"
482     ROOTHDD="${HDD}3"
483     ;;
484    
485     single|auto)
486     BOOTHDD=""
487     SWAPHDD=""
488     ROOTHDD="${HDD}1"
489     ;;
490     esac
491    
492   # run this only if FDISKPARTITIONBELOW256MB is not already 1   if [[ ${INSTALL_METHOD} = auto ]]
  if [[ ${FDISKPARTIONBELOW256MB} != 1 ]]  
493   then   then
494   if hdd_size_below_256mb ${HDD}   # run this only if FDISKPARTITIONBELOW256MB is not already 1
495     if [[ ${FDISKPARTIONBELOW256MB} != 1 ]]
496   then   then
497   FDISKPARTIONBELOW256MB=1   if hdd_size_below_256mb ${HDD}
498   else   then
499   FDISKPARTIONBELOW256MB=0   FDISKPARTIONBELOW256MB=1
500     else
501     FDISKPARTIONBELOW256MB=0
502     fi
503   fi   fi
  fi  
504    
505   ## delete disk   ## delete disk
506   dd if=/dev/zero of=${HDD} count=1 &> /dev/null || die   dd if=/dev/zero of=${HDD} count=1 &> /dev/null || die
507    
508   if [[ ${FDISKPARTIONBELOW256MB} = 1 ]]   if [[ ${FDISKPARTIONBELOW256MB} = 1 ]]
509   then   then
510   ## setup one bootable partition   ## setup one bootable partition
511   #1. n= new disk   #1. n= new disk
512   #2. p= primary disk   #2. p= primary disk
513   #3. 1= first partition   #3. 1= first partition
514   #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
515   #5. ''= defaul sector end   #5. ''= defaul sector end
516   #6. a= bootable flag   #6. a= bootable flag
517   #7. 1= boot flag for partition 1   #7. 1= boot flag for partition 1
518   #8. w= write/quit   #8. w= write/quit
519   fdisk ${HDD} &> /dev/null << EOF   fdisk ${HDD} &> /dev/null << EOF
520  n  n
521  p  p
522  1  1
# Line 570  a Line 526  a
526  1  1
527  w  w
528  EOF  EOF
529   else   else
530   ## setup one bootable partition   ## setup one bootable partition
531   #1. n= new disk   #1. n= new disk
532   #2. p= primary disk   #2. p= primary disk
533   #3. 1= first partition   #3. 1= first partition
534   #4. ''= default sector start   #4. ''= default sector start
535   #5. ''= defaul sector end   #5. ''= defaul sector end
536   #6. a= bootable flag   #6. a= bootable flag
537   #7. 1= boot flag for partition 1   #7. 1= boot flag for partition 1
538   #8. w= write/quit   #8. w= write/quit
539   fdisk ${HDD} &> /dev/null << EOF   fdisk ${HDD} &> /dev/null << EOF
540  n  n
541  p  p
542  1  1
# Line 590  a Line 546  a
546  1  1
547  w  w
548  EOF  EOF
549     fi
550     else
551     ## hdds partitionieren manuell
552     cfdisk ${HDD} || die
553   fi   fi
554  }  }
555    
 setup_hdd_partitions_manuell()  
 {  
  BOOTHDD="${HDD}1"  
  SWAPHDD="${HDD}2"  
  ROOTHDD="${HDD}3"  
   
  ## hdds partitionieren manuell  
  cfdisk ${HDD} || die  
 }  
   
 setup_hdd_partitions_manuell_simple()  
 {  
  ROOTHDD="${HDD}1"  
   
  ## hdds partitionieren manuell  
  cfdisk ${HDD} || die  
 }  
   
556  setup_hdd_format()  setup_hdd_format()
557  {  {
558   mkswap ${SWAPHDD} || die   if [[ -n ${SWAPHDD} ]]
559   mke2fs -j -q ${BOOTHDD} || die   then
560   mke2fs -j -q ${ROOTHDD} || die   mkswap ${SWAPHDD} || die
561  }   fi
562     if [[ -n ${BOOTHDD} ]]
563  setup_hdd_format_simple()   then
564  {   mkfs.${FORMAT_FILESYSTEM} -q ${BOOTHDD} || die
565   mke2fs -j -q ${ROOTHDD} || die   fi
566     if [[ -n ${ROOTHDD} ]]
567     then
568     mkfs.${FORMAT_FILESYSTEM} -q ${ROOTHDD} || die
569     fi
570  }  }
571    
572  install_mount_rootfs()  install_mount_rootfs()
573  {  {
574   swapon ${SWAPHDD} || die   if [[ -n ${SWAPHDD} ]]
575   mount ${ROOTHDD} ${INSTALLPATH} || die   then
576   install -d ${INSTALLPATH}/boot || die   swapon ${SWAPHDD} || die
577   mount ${BOOTHDD} ${INSTALLPATH}/boot || die   fi
578   cd ${INSTALLPATH} || die   if [[ -n ${ROOTHDD} ]]
579  }   then
580     mount ${ROOTHDD} ${INSTALLPATH} || die
581     fi
582     if [[ -n ${BOOTHDD} ]]
583     then
584     install -d ${INSTALLPATH}/boot || die
585     mount ${BOOTHDD} ${INSTALLPATH}/boot || die
586     fi
587    
 install_mount_rootfs_simple()  
 {  
  mount ${ROOTHDD} ${INSTALLPATH} || die  
  install -d ${INSTALLPATH}/boot || die  
588   cd ${INSTALLPATH} || die   cd ${INSTALLPATH} || die
589  }  }
590    
# Line 856  install_system_settings() Line 805  install_system_settings()
805   # schreibe fstab   # schreibe fstab
806   if is_uuid_supported   if is_uuid_supported
807   then   then
808   echo -e "UUID=$(get_uuid ${BOOTHDD})\t/boot\t${FORMAT_FILESYSTEM}\tnoatime,noauto\t1 1" > ${INSTALLPATH}/etc/fstab || die   if [[ -n ${BOOTHDD} ]]
809   echo -e "UUID=$(get_uuid ${ROOTHDD})\t/\t${FORMAT_FILESYSTEM}\tnoatime\t0 0" >> ${INSTALLPATH}/etc/fstab || die   then
810     echo -e "UUID=$(get_uuid ${BOOTHDD})\t/boot\t${FORMAT_FILESYSTEM}\tnoatime,noauto\t1 1" > ${INSTALLPATH}/etc/fstab || die
811     fi
812     if [[ -n ${ROOTHDD} ]]
813     then
814     echo -e "UUID=$(get_uuid ${ROOTHDD})\t/\t${FORMAT_FILESYSTEM}\tnoatime\t0 0" >> ${INSTALLPATH}/etc/fstab || die
815     fi
816   else   else
817   echo -e "${BOOTHDD}\t/boot\t${FORMAT_FILESYSTEM}\tnoatime,noauto\t1 1" > ${INSTALLPATH}/etc/fstab || die   if [[ -n ${BOOTHDD} ]]
818   echo -e "${ROOTHDD}\t/\t${FORMAT_FILESYSTEM}\tnoatime\t0 0" >> ${INSTALLPATH}/etc/fstab || die   then
819     echo -e "${BOOTHDD}\t/boot\t${FORMAT_FILESYSTEM}\tnoatime,noauto\t1 1" > ${INSTALLPATH}/etc/fstab || die
820     fi
821     if [[ -n ${ROOTHDD} ]]
822     then
823     echo -e "${ROOTHDD}\t/\t${FORMAT_FILESYSTEM}\tnoatime\t0 0" >> ${INSTALLPATH}/etc/fstab || die
824     fi
825   fi   fi
826   # not needed busybox loads all with swapon -a, even if not mentioned in fstab   # not needed busybox loads all with swapon -a, even if not mentioned in fstab
827   #echo -e "UUID='$(get_uuid ${SWAPHDD})'\tswap\tswap\tpri=1\t0 0" >> ${INSTALLPATH}/etc/fstab || die   #echo -e "UUID='$(get_uuid ${SWAPHDD})'\tswap\tswap\tpri=1\t0 0" >> ${INSTALLPATH}/etc/fstab || die
# Line 884  install_system_settings() Line 845  install_system_settings()
845   fi   fi
846  }  }
847    
 install_system_settings_simple()  
 {  
  # write fstab  
  if is_uuid_supported  
  then  
  echo -e "UUID=$(get_uuid ${ROOTHDD})\t/\t${FORMAT_FILESYSTEM}\tnoatime\t0 0" > ${INSTALLPATH}/etc/fstab || die  
  else  
  echo -e "${ROOTHDD}\t/\t${FORMAT_FILESYSTEM}\tnoatime\t0 0" > ${INSTALLPATH}/etc/fstab || die  
  fi  
  echo -e "proc\t/proc\tproc\tdefaults\t0 0" >> ${INSTALLPATH}/etc/fstab || die  
  echo -e "shm\t/dev/shm\ttmpfs\tdefaults\t0 0" >> ${INSTALLPATH}/etc/fstab || die  
 }  
   
848  install_umount_rootfs()  install_umount_rootfs()
849  {  {
850   cd /   cd /
851   umount ${INSTALLPATH}/boot || die   if [[ -n ${BOOTHDD} ]]
852   umount ${INSTALLPATH} || die   then
853   swapoff ${SWAPHDD} || die   umount ${INSTALLPATH}/boot || die
854  }   fi
855     if [[ -n ${ROOTHDD} ]]
856  install_umount_rootfs_simple()   then
857  {   umount ${INSTALLPATH} || die
858   cd /   fi
859   umount ${INSTALLPATH} || die   if [[ -n ${SWAPHDD} ]]
860     then
861     swapoff ${SWAPHDD} || die
862     fi
863  }  }
864    
865  install_do_reboot()  install_do_reboot()
# Line 920  install_do_reboot() Line 871  install_do_reboot()
871  #     Install Main Scripts #  #     Install Main Scripts #
872  #################################################  #################################################
873    
874  run_install_normal()  run_install()
875  {  {
876     local method="$1"
877    
878     # setup install environment
879     export KERNELOPTS="${DEFAULT_KERNELOPTS}"
880     export GRUBLEGACYOPTS="${GRUBLEGACYOPTS}"
881     export GRUB2OPTS="${GRUB2OPTS}"
882     export GRUB2GFXPAYLOAD="${DEFAULT_GRUB2GFXPAYLOAD}"
883     export FORMFACTOR="${DEFAULT_FORMFACTOR}"
884     export FORMAT_FILESYSTEM="${DEFAULT_FORMAT_FILESYSTEM}"
885    
886     case "${method}" in
887     auto)
888     export INSTALL_METHOD="${method}"
889     ;;
890     normal)
891     export INSTALL_METHOD="${method}"
892     ;;
893     single)
894     export INSTALL_METHOD="${method}"
895     ;;
896     *)
897     echo "Unknown install method '${method}', aborting."
898     exit 1
899     ;;
900     esac
901    
902   dialog_hardware_detection   dialog_hardware_detection
903    
904   dialog_setup_hdd_partitions_manuell   dialog_setup_hdd_partitions
905   dialog_setup_hdd_format   dialog_setup_hdd_format
906   setup_hdd_format > /dev/null   setup_hdd_format > /dev/null
907   install_mount_rootfs   install_mount_rootfs
# Line 942  run_install_normal() Line 919  run_install_normal()
919   dialog_install_successful   dialog_install_successful
920  }  }
921    
 run_install_simple()  
 {  
  dialog_hardware_detection  
   
  dialog_setup_hdd_partitions_manuell_simple  
  dialog_setup_hdd_format  
  setup_hdd_format_simple > /dev/null  
  install_mount_rootfs_simple  
  (install_system_image > /tmp/install.log) 2> /tmp/install_errors.log | dialog_install_meter | dialog_install_system_image  
   
  dialog_install_settings  
  sleep 1  
  install_system_settings_simple  
  install_initrd_chroot  
   
  dialog_install_bootsector  
  install_bootsector_chroot  
   
  install_umount_rootfs_simple  
  dialog_install_successful  
 }  
   
 run_install_auto()  
 {  
  dialog_hardware_detection  
   
  dialog_setup_hdd_partitions_auto  
  dialog_setup_hdd_format  
  setup_hdd_format_simple > /dev/null  
  install_mount_rootfs_simple  
  (install_system_image > /tmp/install.log) 2> /tmp/install_errors.log | dialog_install_meter | dialog_install_system_image  
   
  dialog_install_settings  
  sleep 1  
  install_system_settings_simple  
  install_initrd_chroot  
   
  dialog_install_bootsector  
  install_bootsector_chroot  
   
  install_umount_rootfs_simple  
  dialog_install_successful  
 }  
   
922  dialog_main  dialog_main
923    
924  exit 0  exit 0

Legend:
Removed from v.6821  
changed lines
  Added in v.6828