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 6822 by niro, Thu Jul 23 08:57:29 2015 UTC revision 6843 by niro, Thu Jul 23 13:26:00 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
17  VERSION="@@VERSION@@"  VERSION="@@VERSION@@"
18  TITLE="alxinstall-ng - ${VERSION}"  TITLE="alxinstall-ng - ${VERSION}"
19    
20    # locations
21  CDPATH="/mnt/cdrom"  CDPATH="/mnt/cdrom"
22  INSTALLPATH="/mnt/magellan"  INSTALL_ROOT="/mnt/magellan"
   
 ### linecount of system.tar.gz -1 !  
 CURRENTLINE=0  
 #TOTALLINES=11072 # -> now in images.conf  
23    
24    # default system settings
25  # standard kernel opts  # standard kernel opts
26  KERNELOPTS="quiet video=1024x768"  DEFAULT_KERNELOPTS="quiet video=1024x768"
27    
28  # grub options  # grub options
29  GRUBLEGACYOPTS=""  DEFAULT_GRUBLEGACYOPTS=""
30  GRUB2OPTS=""  DEFAULT_GRUB2OPTS=""
31  GRUB2GFXPAYLOAD="1024x768x16,1024x768"  DEFAULT_GRUB2GFXPAYLOAD="1024x768x16,1024x768"
   
 # fdisk options  
 FDISKPARTIONBELOW256MB=0  
32    
33  # default specialdevices  # default specialdevices
34  SPECIALDEVICE=""  DEFAULT_FORMFACTOR="desktop"
 FORMFACTOR="desktop"  
35    
36  # target filesystem  # target filesystem
37  FORMAT_FILESYSTEM="ext4"  DEFAULT_FORMAT_FILESYSTEM="ext4"
38    
39    # initialize global variables so they are exportable
40    INSTALL_METHOD=""
41    KERNELOPTS=""
42    GRUBLEGACYOPTS=""
43    GRUB2OPTS=""
44    GRUB2GFXPAYLOAD=""
45    FORMFACTOR=""
46    FORMAT_FILESYSTEM=""
47    FORMAT_FILESYSTEM_BOOTHDD=""
48    FORMAT_FILESYSTEM_ROOTHDD=""
49    FDISKPARTIONBELOW256MB=0
50    SPECIALDEVICE=""
51    FLASHDISK=0
52    ### linecount of system.tar.gz -1 !
53    CURRENTLINE=0
54    #TOTALLINES=11072 # -> now in images.conf
55    
56  #################################################  #################################################
57  #  DIALOG BOXES #  #  DIALOG BOXES #
# Line 50  die() Line 62  die()
62   ERROR=$1   ERROR=$1
63   RETVAL=$?   RETVAL=$?
64   dialog_install_failure   dialog_install_failure
65     trap_exit
66   exit 1   exit 1
67  }  }
68    
# Line 73  dialog_warning() Line 86  dialog_warning()
86    
87  dialog_setup_hdd_info()  dialog_setup_hdd_info()
88  {  {
89     case "${INSTALL_METHOD}" in
90     auto)
91     dialog_setup_hdd_info_auto
92     dialog_setup_hdd_create_partitions
93     ;;
94     normal) dialog_setup_hdd_info_normal ;;
95     single) dialog_setup_hdd_info_single ;;
96     flash) dialog_setup_hdd_info_flash ;;
97     esac
98    }
99    
100    dialog_setup_hdd_info_normal()
101    {
102   local SHDD="$(echo ${HDD} | sed 's/\/dev\///')"   local SHDD="$(echo ${HDD} | sed 's/\/dev\///')"
103    
104   dialog \   dialog \
# Line 87  dialog_setup_hdd_info() Line 113  dialog_setup_hdd_info()
113   Bitte ${SHDD}1 als \Z3bootable\Zn markieren." 12 81   Bitte ${SHDD}1 als \Z3bootable\Zn markieren." 12 81
114  }  }
115    
116  dialog_setup_hdd_info_simple()  dialog_setup_hdd_info_single()
117  {  {
118   local SHDD="$(echo $HDD | sed 's/\/dev\///')"   local SHDD="$(echo $HDD | sed 's/\/dev\///')"
119    
# Line 101  dialog_setup_hdd_info_simple() Line 127  dialog_setup_hdd_info_simple()
127   Bitte ${SHDD}1 als \Z3bootable\Zn markieren." 12 81   Bitte ${SHDD}1 als \Z3bootable\Zn markieren." 12 81
128  }  }
129    
130    dialog_setup_hdd_info_flash()
131    {
132     local SHDD="$(echo ${HDD} | sed 's/\/dev\///')"
133    
134     dialog \
135     --colors \
136     --title "[ Festplatten Partitionierung ]" \
137     --backtitle "${TITLE}" \
138     --ok-label "Weiter" \
139     --msgbox "\nBitte legen Sie 2 Partitionen an.\n\n\
140     [ \Z3${SHDD}1\Zn ] Typ: \Z3Linux\Zn mit ca. 50MB\n\
141     [ \Z3${SHDD}2\Zn ] Typ: \Z3Linux \Zn mit dem Rest (min. 256MB)\n\n\
142     Bitte ${SHDD}1 als \Z3bootable\Zn markieren." 12 81
143    }
144    
145  dialog_setup_hdd_info_auto()  dialog_setup_hdd_info_auto()
146  {  {
147   local SHDD="$(echo $HDD | sed 's/\/dev\///')"   local SHDD="$(echo $HDD | sed 's/\/dev\///')"
# Line 125  dialog_setup_system_menu() Line 166  dialog_setup_system_menu()
166   --ok-label "Weiter" \   --ok-label "Weiter" \
167   --stdout \   --stdout \
168   --colors \   --colors \
169   --menu "\nWaehlen Sie die Installations-Methode" 14 70 5 \   --menu "\nWaehlen Sie die Installations-Methode" 14 70 6 \
170   "1" "Automatisches Setup (Empfohlen)" \   "1" "Automatisches Setup (Empfohlen)" \
171   "" "" \   "" "" \
172   "" "\Z1Experten Modi:\Zn" \   "" "\Z1Experten Modi:\Zn" \
173   "2" "Normale IDE-Disk (Manuell)" \   "2" "Normale IDE-Disk (Manuell)" \
174   "3" "Flash-Speicher (Manuell)")   "3" "Normale IDE Disk (Single)" \
175     "4" "Flash SDHC/NAND oder USBStick (Manuell)")
176   RES=$?   RES=$?
177   [[ ${RES} -eq 1 ]] && return 1   [[ ${RES} -eq 1 ]] && return 1
178   if [[ ${RES} -eq 0 ]]   if [[ ${RES} -eq 0 ]]
179   then   then
180   case "${i}" in   case "${i}" in
181   "1") run_install_auto ;;   "1") run_install auto ;;
182   "2") run_install_normal ;;   "2") run_install normal ;;
183   "3") run_install_simple ;;   "3") run_install single ;;
184     "4") run_install flash ;;
185   "") dialog_setup_system_menu;;   "") dialog_setup_system_menu;;
186   esac   esac
187   fi   fi
# Line 149  dialog_hardware_detection() Line 192  dialog_hardware_detection()
192   local i   local i
193   local hwtmp   local hwtmp
194    
195   if [ -x $(which mktemp &> /dev/null) ]   if [ -x $(type -P mktemp) ]
196   then   then
197   hwtmp="$(mktemp)"   hwtmp="$(mktemp)"
198   else   else
# Line 197  dialog_hardware_detection() Line 240  dialog_hardware_detection()
240   then   then
241   echo " \n \\ZnFormfactor Laptop, Powersave Modus 'ondemand' wird aktiviert.\\Zn \\" >> ${hwtmp}   echo " \n \\ZnFormfactor Laptop, Powersave Modus 'ondemand' wird aktiviert.\\Zn \\" >> ${hwtmp}
242   fi   fi
243     if [[ ${FLASHDISK} = 1 ]]
244     then
245     echo " \n \\ZnFlash Speicher erkannt, F2FS wird als Dateisystem benutzt.\\Zn \\" >> ${hwtmp}
246     fi
247    
248   echo " \" 14 70" >> ${hwtmp}   echo " \" 14 70" >> ${hwtmp}
249   chmod a+x ${hwtmp}   chmod a+x ${hwtmp}
# Line 209  dialog_hardware_detection() Line 256  dialog_hardware_detection()
256   fi   fi
257  }  }
258    
259  dialog_setup_hdd_partitions_manuell()  dialog_setup_hdd_partitions()
260  {  {
261   local i   local i
262    
# Line 242  dialog_setup_hdd_partitions_manuell() Line 289  dialog_setup_hdd_partitions_manuell()
289   if [[ ${RES} -eq 0 ]]   if [[ ${RES} -eq 0 ]]
290   then   then
291   dialog_setup_hdd_info   dialog_setup_hdd_info
292   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  
293   fi   fi
294   fi   fi
295  }  }
# Line 401  dialog_main() Line 371  dialog_main()
371   --no-cancel \   --no-cancel \
372   --ok-label "Weiter" \   --ok-label "Weiter" \
373   --stdout \   --stdout \
374   --menu "Konfiguration" 14 70 5 \   --menu "Konfiguration" 14 70 6 \
375   "1" "AutoSta_LX installieren" \   "1" "AutoSta_LX installieren" \
376   "2" "Uebersicht gefundener Laufwerke" \   "2" "Uebersicht gefundener Laufwerke" \
377   "3" "Beenden und neustarten" \   "3" "Beenden und neustarten" \
# Line 438  run_hardware_detection() Line 408  run_hardware_detection()
408   if [[ $(< ${i}) = 1 ]]   if [[ $(< ${i}) = 1 ]]
409   then   then
410   removable=1   removable=1
411     # we assume that all removable disks are flash disks
412     export FLASHDISK=1
413   fi   fi
414   done   done
415    
# Line 530  hdd_size_below_256mb() Line 502  hdd_size_below_256mb()
502   return "${retval}"   return "${retval}"
503  }  }
504    
505  setup_hdd_partitions_auto()  setup_hdd_partitions()
506  {  {
507   ROOTHDD="${HDD}1"   case "${INSTALL_METHOD}" in
508     normal)
509     BOOTHDD="${HDD}1"
510     SWAPHDD="${HDD}2"
511     ROOTHDD="${HDD}3"
512     ;;
513    
514     single|auto)
515     BOOTHDD=""
516     SWAPHDD=""
517     ROOTHDD="${HDD}1"
518     ;;
519    
520     flash)
521     BOOTHDD="${HDD}1"
522     SWAPHDD=""
523     ROOTHDD="${HDD}2"
524     ;;
525     esac
526    
527   # run this only if FDISKPARTITIONBELOW256MB is not already 1   if [[ ${INSTALL_METHOD} = auto ]]
  if [[ ${FDISKPARTIONBELOW256MB} != 1 ]]  
528   then   then
529   if hdd_size_below_256mb ${HDD}   # run this only if FDISKPARTITIONBELOW256MB is not already 1
530     if [[ ${FDISKPARTIONBELOW256MB} != 1 ]]
531   then   then
532   FDISKPARTIONBELOW256MB=1   if hdd_size_below_256mb ${HDD}
533   else   then
534   FDISKPARTIONBELOW256MB=0   FDISKPARTIONBELOW256MB=1
535     else
536     FDISKPARTIONBELOW256MB=0
537     fi
538   fi   fi
  fi  
539    
540   ## delete disk   ## delete disk
541   dd if=/dev/zero of=${HDD} count=1 &> /dev/null || die   dd if=/dev/zero of=${HDD} count=1 &> /dev/null || die
542    
543   if [[ ${FDISKPARTIONBELOW256MB} = 1 ]]   if [[ ${FDISKPARTIONBELOW256MB} = 1 ]]
544   then   then
545   ## setup one bootable partition   ## setup one bootable partition
546   #1. n= new disk   #1. n= new disk
547   #2. p= primary disk   #2. p= primary disk
548   #3. 1= first partition   #3. 1= first partition
549   #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
550   #5. ''= defaul sector end   #5. ''= defaul sector end
551   #6. a= bootable flag   #6. a= bootable flag
552   #7. 1= boot flag for partition 1   #7. 1= boot flag for partition 1
553   #8. w= write/quit   #8. w= write/quit
554   fdisk ${HDD} &> /dev/null << EOF   fdisk ${HDD} &> /dev/null << EOF
555  n  n
556  p  p
557  1  1
# Line 569  a Line 561  a
561  1  1
562  w  w
563  EOF  EOF
564   else   else
565   ## setup one bootable partition   ## setup one bootable partition
566   #1. n= new disk   #1. n= new disk
567   #2. p= primary disk   #2. p= primary disk
568   #3. 1= first partition   #3. 1= first partition
569   #4. ''= default sector start   #4. ''= default sector start
570   #5. ''= defaul sector end   #5. ''= defaul sector end
571   #6. a= bootable flag   #6. a= bootable flag
572   #7. 1= boot flag for partition 1   #7. 1= boot flag for partition 1
573   #8. w= write/quit   #8. w= write/quit
574   fdisk ${HDD} &> /dev/null << EOF   fdisk ${HDD} &> /dev/null << EOF
575  n  n
576  p  p
577  1  1
# Line 589  a Line 581  a
581  1  1
582  w  w
583  EOF  EOF
584     fi
585     else
586     ## hdds partitionieren manuell
587     cfdisk ${HDD} || die
588   fi   fi
589  }  }
590    
 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  
 }  
   
591  setup_hdd_format()  setup_hdd_format()
592  {  {
593   mkswap ${SWAPHDD} || die   if [[ -n ${SWAPHDD} ]]
594   mke2fs -j -q ${BOOTHDD} || die   then
595   mke2fs -j -q ${ROOTHDD} || die   mkswap ${SWAPHDD} || die
596  }   fi
597     if [[ -n ${BOOTHDD} ]]
598  setup_hdd_format_simple()   then
599  {   mkfs.${FORMAT_FILESYSTEM_BOOTHDD} -q ${BOOTHDD} || die
600   mke2fs -j -q ${ROOTHDD} || die   fi
601     if [[ -n ${ROOTHDD} ]]
602     then
603     mkfs.${FORMAT_FILESYSTEM_ROOTHDD} -q ${ROOTHDD} || die
604     fi
605  }  }
606    
607  install_mount_rootfs()  install_mount_rootfs()
608  {  {
609   swapon ${SWAPHDD} || die   local opts
  mount ${ROOTHDD} ${INSTALLPATH} || die  
  install -d ${INSTALLPATH}/boot || die  
  mount ${BOOTHDD} ${INSTALLPATH}/boot || die  
  cd ${INSTALLPATH} || die  
 }  
610    
611  install_mount_rootfs_simple()   if [[ -n ${SWAPHDD} ]]
612  {   then
613   mount ${ROOTHDD} ${INSTALLPATH} || die   swapon ${SWAPHDD} || die
614   install -d ${INSTALLPATH}/boot || die   fi
615   cd ${INSTALLPATH} || die   if [[ -n ${ROOTHDD} ]]
616     then
617     mount -t ${FORMAT_FILESYSTEM_ROOTHDD} ${ROOTHDD} ${INSTALL_ROOT} || die
618     fi
619     if [[ -n ${BOOTHDD} ]]
620     then
621     install -d ${INSTALL_ROOT}/boot || die
622     mount -t ${FORMAT_FILESYSTEM_BOOTHDD} ${BOOTHDD} ${INSTALL_ROOT}/boot || die
623     fi
624    
625     cd ${INSTALL_ROOT} || die
626  }  }
627    
628  install_system_image()  install_system_image()
629  {  {
630   tar xvjpf ${CDPATH}/system/${CDIMAGENAME} -C ${INSTALLPATH}   tar xvjpf ${CDPATH}/system/${CDIMAGENAME} -C ${INSTALL_ROOT}
631  }  }
632    
633  install_bootsector_chroot()  install_bootsector_chroot()
634  {  {
635   local my_roothdd   local my_roothdd
636   local grubconf=${INSTALLPATH}/boot/grub/grub.conf   local grubconf=${INSTALL_ROOT}/boot/grub/grub.conf
637   local grub2conf=/boot/grub/grub.cfg   local grub2conf=/boot/grub/grub.cfg
638     local CONFIG
639    
640   # check for grub2   # check for grub2
641   if [[ -f ${INSTALLPATH}/sbin/grub-mkconfig ]]   if [[ -f ${INSTALL_ROOT}/sbin/grub-mkconfig ]]
642   then   then
643   # needed by grub-mkconfig on the first run   # needed by grub-mkconfig on the first run
644   if [[ ! -f ${INSTALLPATH}/boot/grub/video.lst ]]   if [[ ! -f ${INSTALL_ROOT}/boot/grub/video.lst ]]
645   then   then
646   install -m0644 ${INSTALLPATH}/lib/grub/*/video.lst ${INSTALLPATH}/boot/grub/video.lst || die   install -m0644 ${INSTALL_ROOT}/lib/grub/*/video.lst ${INSTALL_ROOT}/boot/grub/video.lst || die
647   fi   fi
648    
649   # set kernelopts   # set kernelopts
650   if [[ -f ${INSTALLPATH}/etc/conf.d/grub ]]   if [[ -f ${INSTALL_ROOT}/etc/conf.d/grub ]]
651   then   then
652   sed -i "s:^\(export GRUB_CMDLINE_LINUX_DEFAULT=\).*:\1\"${KERNELOPTS}\":" ${INSTALLPATH}/etc/conf.d/grub || die   sed -i "s:^\(export GRUB_CMDLINE_LINUX_DEFAULT=\).*:\1\"${KERNELOPTS}\":" ${INSTALL_ROOT}/etc/conf.d/grub || die
653   sed -i "s:^\(export GRUB_GFXPAYLOAD_LINUX=\).*:\1\"${GRUB2GFXPAYLOAD}\":" ${INSTALLPATH}/etc/conf.d/grub || die   sed -i "s:^\(export GRUB_GFXPAYLOAD_LINUX=\).*:\1\"${GRUB2GFXPAYLOAD}\":" ${INSTALL_ROOT}/etc/conf.d/grub || die
654   else   else
655   echo "export GRUB_CMDLINE_LINUX_DEFAULT=\"${KERNELOPTS}\"" >  ${INSTALLPATH}/etc/conf.d/grub || die   CONFIG=${INSTALL_ROOT}/etc/conf.d/grub
656   echo "export GRUB_GFXPAYLOAD_LINUX=\"${GRUB2GFXPAYLOAD}\"" >>  ${INSTALLPATH}/etc/conf.d/grub || die   clearconfig
657   fi   addconfig "export GRUB_CMDLINE_LINUX_DEFAULT=\"${KERNELOPTS}\""
658   echo 'grub-mkdevicemap' > ${INSTALLPATH}/root/.installrc || die   addconfig "export GRUB_GFXPAYLOAD_LINUX=\"${GRUB2GFXPAYLOAD}\""
659   echo "LC_ALL=C grub-mkconfig -o ${grub2conf}  &> /dev/null" >> ${INSTALLPATH}/root/.installrc || die   fi
660   echo "grub-install --no-floppy ${HDD} &> /dev/null" >> ${INSTALLPATH}/root/.installrc || die   CONFIG=${INSTALL_ROOT}/.installrc
661   echo "exit 0" >> ${INSTALLPATH}/root/.installrc || die   clearconfig
662     addconfig 'grub-mkdevicemap'
663     addconfig "LC_ALL=C grub-mkconfig -o ${grub2conf}  &> /dev/null"
664     addconfig "grub-install --no-floppy ${HDD} &> /dev/null"
665     addconfig "exit 0"
666    
667   # grub-legacy   # grub-legacy
668   else   else
669   ### grubconf schreiben   ### grubconf schreiben
670   source ${INSTALLPATH}/boot/kernelversion   source ${INSTALL_ROOT}/boot/kernelversion
671    
672   #for alx only   #for alx only
673   if [ -e ${INSTALLPATH}/etc/alx_version ]   if [ -e ${INSTALL_ROOT}/etc/alx_version ]
674   then   then
675   OLD_ALXVER="${ALXVER}"   OLD_ALXVER="${ALXVER}"
676   source ${INSTALLPATH}/etc/alx_version   source ${INSTALL_ROOT}/etc/alx_version
677   KRNVER="ALX-${ALXVER}"   KRNVER="ALX-${ALXVER}"
678   ALXVER="${OLD_ALXVER}"   ALXVER="${OLD_ALXVER}"
679   fi   fi
# Line 698  install_bootsector_chroot() Line 690  install_bootsector_chroot()
690   my_roothdd="${ROOTHDD}"   my_roothdd="${ROOTHDD}"
691   fi   fi
692    
693   : > ${grubconf} || die   CONFIG="${grubconf}"
694   echo "default 0" >> ${grubconf} || die   clearconfig
695   echo "timeout 3" >> ${grubconf} || die   addconfig "default 0"
696     addconfig "timeout 3"
697   # using current root password   # using current root password
698   echo "password --md5 $(cat ${INSTALLPATH}/etc/shadow | grep root | cut -d: -f2)"  >> ${grubconf} || die   addconfig "password --md5 $(cat ${INSTALL_ROOT}/etc/shadow | grep root | cut -d: -f2)"
699     addconfig
700   echo  >> ${grubconf} || die   addconfig "# normal boot"
701   echo "# normal boot" >> ${grubconf} || die   addconfig "title ${KRNVER}"
702   echo "title ${KRNVER}" >> ${grubconf} || die   addconfig "root (hd0,0)"
703   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  
704   if is_initrd_supported   if is_initrd_supported
705   then   then
706   echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die   addconfig "initrd /boot/${KRNINITRD}"
707   fi   fi
708     addconfig
709   echo >> ${grubconf} || die   addconfig "# admin boot"
710   echo "# admin boot" >> ${grubconf} || die   addconfig "title ${KRNVER} - Re-run hardware-detection"
711   echo "title ${KRNVER} - Re-run hardware-detection" >> ${grubconf} || die   addconfig "lock"
712   echo "lock"  >> ${grubconf} || die   addconfig "root (hd0,0)"
713   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  
714   if is_initrd_supported   if is_initrd_supported
715   then   then
716   echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die   addconfig "initrd /boot/${KRNINITRD}"
717   fi   fi
718     addconfig
719   echo >> ${grubconf} || die   addconfig "title ${KRNVER} - Reset *all* local settings"
720   echo "title ${KRNVER} - Reset *all* local settings" >> ${grubconf} || die   addconfig "lock"
721   echo "lock"  >> ${grubconf} || die   addconfig "root (hd0,0)"
722   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  
723   if is_initrd_supported   if is_initrd_supported
724   then   then
725   echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die   addconfig "initrd /boot/${KRNINITRD}"
726   fi   fi
727    
728   # write bootsector chrooted (lfs/magellan)   # write bootsector chrooted (lfs/magellan)
729   cat > ${INSTALLPATH}/root/.installrc << CHROOTEOF   CONFIG=${INSTALL_ROOT}/.installrc
730  /usr/sbin/grub --no-floppy --batch << "EOF" 1> /dev/null 2> /dev/null   clearconfig
731  root (hd0,0)   addconfig '/usr/sbin/grub --no-floppy --batch << "EOF" 1> /dev/null 2> /dev/null'
732  setup (hd0)   addconfig 'root (hd0,0)'
733  quit   addconfig 'setup (hd0)'
734  EOF   addconfig 'quit'
735  exit 0   addconfig 'EOF'
736  CHROOTEOF   addconfig 'exit 0'
737   fi   fi
738    
739   ## enters chroot   ## enter chroot
740   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  
741  }  }
742    
743  is_initrd_supported()  is_initrd_supported()
744  {  {
745   # only generate initrds if the cmd exists   # only generate initrds if the cmd exists
746   [[ -x ${INSTALLPATH}/sbin/mkinitrd ]] && return 0   [[ -x ${INSTALL_ROOT}/sbin/mkinitrd ]] && return 0
747   return 1   return 1
748  }  }
749    
750  install_initrd_chroot()  install_initrd_chroot()
751  {  {
752     local CONFIG
753    
754   # only generate initrds if the cmd exists   # only generate initrds if the cmd exists
755   is_initrd_supported || return 0   is_initrd_supported || return 0
756    
757     FSMODS="${FORMAT_FILESYSTEM_BOOTHDD} ${FORMAT_FILESYSTEM_ROOTHDD}"
758   DISKMODS="sd_mod"   DISKMODS="sd_mod"
759   OLDPATAMODS="amd74xx piix sis5513 via82cxxx"   OLDPATAMODS="amd74xx piix sis5513 via82cxxx"
760   PATAMODS="ata_piix pata_amd pata_mpiix pata_oldpiix pata_sis pata_via"   PATAMODS="ata_piix pata_amd pata_mpiix pata_oldpiix pata_sis pata_via"
# Line 791  install_initrd_chroot() Line 777  install_initrd_chroot()
777   fi   fi
778    
779   # install an appropriate uvesafb.conf   # install an appropriate uvesafb.conf
780   install -d ${INSTALLPATH}/etc/modprobe.d || die   CONFIG=${INSTALL_ROOT}/etc/modprobe.d/uvesafb.conf
781   echo "options uvesafb mode_option=1024x768-32@60 scroll=ywrap" > ${INSTALLPATH}/etc/modprobe.d/uvesafb.conf || die   clearconfig
782     addconfig "options uvesafb mode_option=1024x768-32@60 scroll=ywrap"
783    
784   # install an appropriate viafb.conf   # install an appropriate viafb.conf
785   echo "options viafb viafb_mode=1024x768 viafb_refresh=60" > ${INSTALLPATH}/etc/modprobe.d/viafb.conf || die   CONFIG=${INSTALL_ROOT}/etc/modprobe.d/viafb.conf
786     clearconfig
787     addconfig "options viafb viafb_mode=1024x768 viafb_refresh=60"
788    
789   # install an appropriate i810fb.conf   # install an appropriate i810fb.conf
790   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=${INSTALL_ROOT}/etc/modprobe.d/i810fb.conf
791     clearconfig
792   cat > ${INSTALLPATH}/root/.installrc << CHROOTEOF   addconfig "options i810fb xres=1024 yres=768 bpp=16 mtrr=1 hsync1=30 hsync2=62 vsync1=30 vsync2=60"
793  echo "MODULES=\"${FORMAT_FILESYSTEM} ${DISKMODS} ${OLDATAMODS} ${PATAMODS} ${SATAMODS} ${DRMMODS} ${FBMODS} ${OTHERMODS}\"" > /etc/conf.d/mkinitrd  
794  mkinitrd -f /boot/$(readlink /boot/initrd) $(readlink /boot/vmlinuz | sed "s:kernel-::g") > /dev/null   CONFIG=${INSTALL_ROOT}/.installrc
795  exit 0   clearconfig
796  CHROOTEOF   addconfig 'echo "MODULES=\"${FSMODS} ${DISKMODS} ${OLDATAMODS} ${PATAMODS} ${SATAMODS} ${DRMMODS} ${FBMODS} ${OTHERMODS}\"" > /etc/conf.d/mkinitrd'
797     addconfig 'mkinitrd -f /boot/$(readlink /boot/initrd) $(readlink /boot/vmlinuz | sed "s:kernel-::g") > /dev/null'
798   ## enters chroot   addconfig 'exit 0'
799   mount -t proc proc ${INSTALLPATH}/proc   ## enter chroot
800   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  
801  }  }
802    
803  is_uuid_supported()  is_uuid_supported()
804  {  {
805   if [[ -x $(which busybox.mkinitrd &> /dev/null) ]]   # f2fs needs special treatments as the old busybox does not support this fs
806     # use the blkid from util-linux instead of busybox
807     if [[ ${FORMAT_FILESYSTEM} = f2fs ]]
808   then   then
809   # only detect uuids if supported   if [[ -x $(type -P blkid) ]]
  if [[ ! -z $(busybox.mkinitrd | grep blkid) ]]  
810   then   then
811   return 0   return 0
812     fi
813     else
814     if [[ -x $(type -P busybox.mkinitrd) ]]
815     then
816     # only detect uuids if supported
817     if [[ ! -z $(busybox.mkinitrd | grep blkid) ]]
818     then
819     return 0
820     fi
821   fi   fi
822   fi   fi
823    
# Line 836  get_uuid() Line 829  get_uuid()
829   local UUID   local UUID
830   local SEC_TYPE   local SEC_TYPE
831   local TYPE   local TYPE
832     local blkidcmd
833    
834   local dev="$1"   local dev="$1"
835   [[ -z ${dev} ]] && die "no dev given"   [[ -z ${dev} ]] && die "no dev given"
# Line 845  get_uuid() Line 839  get_uuid()
839   then   then
840   eval "${dev}"   eval "${dev}"
841   else   else
842   eval $(busybox.mkinitrd blkid ${dev} | grep "${dev}:" | sed 's/.*:\ //')   # f2fs needs special treatments as the old busybox does not support this fs
843     # use the blkid from util-linux instead of busybox
844     if [[ ${FORMAT_FILESYSTEM} = f2fs ]]
845     then
846     blkidcmd="blkid"
847     else
848     blkidcmd="busybox.mkinitrd blkid"
849     fi
850     eval $(${blkidcmd} ${dev} | grep "${dev}:" | sed 's/.*:\ //')
851   fi   fi
852   echo "${UUID}"   echo "${UUID}"
853  }  }
854    
855  install_system_settings()  install_system_settings()
856  {  {
857   # schreibe fstab   local CONFIG
858   if is_uuid_supported   local fstype
859    
860     # write fstab
861     CONFIG=${INSTALL_ROOT}/etc/fstab
862     clearconfig
863    
864     if [[ -n ${BOOTHDD} ]]
865   then   then
866   echo -e "UUID=$(get_uuid ${BOOTHDD})\t/boot\t${FORMAT_FILESYSTEM}\tnoatime,noauto\t1 1" > ${INSTALLPATH}/etc/fstab || die   if is_uuid_supported
867   echo -e "UUID=$(get_uuid ${ROOTHDD})\t/\t${FORMAT_FILESYSTEM}\tnoatime\t0 0" >> ${INSTALLPATH}/etc/fstab || die   then
868   else   addconfig -e "UUID=$(get_uuid ${BOOTHDD})\t/boot\t${FORMAT_FILESYSTEM_BOOTHDD}\tnoatime,noauto\t1 1"
869   echo -e "${BOOTHDD}\t/boot\t${FORMAT_FILESYSTEM}\tnoatime,noauto\t1 1" > ${INSTALLPATH}/etc/fstab || die   else
870   echo -e "${ROOTHDD}\t/\t${FORMAT_FILESYSTEM}\tnoatime\t0 0" >> ${INSTALLPATH}/etc/fstab || die   addconfig -e "${BOOTHDD}\t/boot\t${FORMAT_FILESYSTEM_BOOTHDD}\tnoatime,noauto\t1 1"
871     fi
872   fi   fi
873    
874     if [[ -n ${ROOTHDD} ]]
875     then
876     if is_uuid_supported
877     then
878     addconfig -e "UUID=$(get_uuid ${ROOTHDD})\t/\t${FORMAT_FILESYSTEM_ROOTHDD}\tnoatime\t0 0"
879     else
880     addconfig -e "${ROOTHDD}\t/\t${FORMAT_FILESYSTEM_ROOTHDD}\tnoatime\t0 0"
881     fi
882     fi
883    
884   # 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
885   #echo -e "UUID='$(get_uuid ${SWAPHDD})'\tswap\tswap\tpri=1\t0 0" >> ${INSTALLPATH}/etc/fstab || die   #addconfig -e "UUID='$(get_uuid ${SWAPHDD})'\tswap\tswap\tpri=1\t0 0"
886   echo -e "proc\t/proc\tproc\tdefaults\t0 0" >> ${INSTALLPATH}/etc/fstab || die   addconfig -e "proc\t/proc\tproc\tdefaults\t0 0"
887   echo -e "shm\t/dev/shm\ttmpfs\tdefaults\t0 0" >> ${INSTALLPATH}/etc/fstab || die   addconfig -e "shm\t/dev/shm\ttmpfs\tdefaults\t0 0"
888    
889   # install network config skeleton   # install network config skeleton
890   install -m0644 ${INSTALLPATH}/etc/alxconfig-ng/skel/net/net.eth0 ${INSTALLPATH}/etc/conf.d/ || die   install -m0644 ${INSTALL_ROOT}/etc/alxconfig-ng/skel/net/net.eth0 ${INSTALL_ROOT}/etc/conf.d/ || die
891    
892   # intel framebufer quirk   # intel framebufer quirk
893   if [[ -e /proc/fb ]]   if [[ -e /proc/fb ]]
# Line 877  install_system_settings() Line 897  install_system_settings()
897   fbdev=$(grep 'inteldrmfb' /proc/fb | sed 's:\([0-9]\).*:\1:')   fbdev=$(grep 'inteldrmfb' /proc/fb | sed 's:\([0-9]\).*:\1:')
898   if [[ ${fbdev} != 0 ]]   if [[ ${fbdev} != 0 ]]
899   then   then
900   sed -i "s:^\(SPLASH_DEV=\).*:\1\"/dev/fb${fbdev}\":" ${INSTALLPATH}/etc/splash/splash.conf || die   sed -i "s:^\(SPLASH_DEV=\).*:\1\"/dev/fb${fbdev}\":" ${INSTALL_ROOT}/etc/splash/splash.conf || die
901   fi   fi
902   fi   fi
903   fi   fi
904  }  }
905    
 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  
 }  
   
906  install_umount_rootfs()  install_umount_rootfs()
907  {  {
908   cd /   cd /
909   umount ${INSTALLPATH}/boot || die   if [[ -n ${BOOTHDD} ]]
910   umount ${INSTALLPATH} || die   then
911   swapoff ${SWAPHDD} || die   umount ${INSTALL_ROOT}/boot || die
912  }   fi
913     if [[ -n ${ROOTHDD} ]]
914  install_umount_rootfs_simple()   then
915  {   umount ${INSTALL_ROOT} || die
916   cd /   fi
917   umount ${INSTALLPATH} || die   if [[ -n ${SWAPHDD} ]]
918     then
919     swapoff ${SWAPHDD} || die
920     fi
921  }  }
922    
923  install_do_reboot()  install_do_reboot()
# Line 919  install_do_reboot() Line 929  install_do_reboot()
929  #     Install Main Scripts #  #     Install Main Scripts #
930  #################################################  #################################################
931    
932  run_install_normal()  run_install()
933  {  {
934     local method="$1"
935    
936     # setup install environment
937     export KERNELOPTS="${DEFAULT_KERNELOPTS}"
938     export GRUBLEGACYOPTS="${GRUBLEGACYOPTS}"
939     export GRUB2OPTS="${GRUB2OPTS}"
940     export GRUB2GFXPAYLOAD="${DEFAULT_GRUB2GFXPAYLOAD}"
941     export FORMFACTOR="${DEFAULT_FORMFACTOR}"
942     export FORMAT_FILESYSTEM="${DEFAULT_FORMAT_FILESYSTEM}"
943    
944     case "${method}" in
945     auto)
946     export FORMAT_FILESYSTEM_BOOTHDD=""
947     export FORMAT_FILESYSTEM_ROOTHDD="${FORMAT_FILESYSTEM}"
948     export INSTALL_METHOD="${method}"
949     ;;
950     normal)
951     export FORMAT_FILESYSTEM_BOOTHDD="${FORMAT_FILESYSTEM}"
952     export FORMAT_FILESYSTEM_ROOTHDD="${FORMAT_FILESYSTEM}"
953     export INSTALL_METHOD="${method}"
954     ;;
955     single)
956     export FORMAT_FILESYSTEM_BOOTHDD=""
957     export FORMAT_FILESYSTEM_ROOTHDD="${FORMAT_FILESYSTEM}"
958     export INSTALL_METHOD="${method}"
959     ;;
960     flash)
961     export FORMAT_FILESYSTEM="f2fs"
962     export FORMAT_FILESYSTEM_BOOTHDD="ext2"
963     export FORMAT_FILESYSTEM_ROOTHDD="${FORMAT_FILESYSTEM}"
964     export INSTALL_METHOD="${method}"
965     ;;
966     *)
967     die "Unknown install method '${method}', aborting."
968     ;;
969     esac
970    
971   dialog_hardware_detection   dialog_hardware_detection
972    
973   dialog_setup_hdd_partitions_manuell   dialog_setup_hdd_partitions
974   dialog_setup_hdd_format   dialog_setup_hdd_format
975   setup_hdd_format > /dev/null   setup_hdd_format > /dev/null
976   install_mount_rootfs   install_mount_rootfs
# Line 941  run_install_normal() Line 988  run_install_normal()
988   dialog_install_successful   dialog_install_successful
989  }  }
990    
991  run_install_simple()  # set some proper traps
992  {  trap "trap_exit" SIGINT SIGQUIT
  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  
 }  
993    
994  dialog_main  dialog_main
995    

Legend:
Removed from v.6822  
changed lines
  Added in v.6843