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 6844 by niro, Thu Jul 23 13:32:03 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 426  dialog_main() Line 396  dialog_main()
396  run_hardware_detection()  run_hardware_detection()
397  {  {
398   local hwinfo   local hwinfo
   
399   hwinfo="$(hwinfo --bios --storage --pci --gfxcard --sys)"   hwinfo="$(hwinfo --bios --storage --pci --gfxcard --sys)"
400    
401   # check for special devices/clients:   # check for special devices/clients:
# Line 439  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 531  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 570  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 590  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   install -d /tmp
594   mke2fs -j -q ${BOOTHDD} || die   :> /tmp/format.log
  mke2fs -j -q ${ROOTHDD} || die  
 }  
595    
596  setup_hdd_format_simple()   if [[ -n ${SWAPHDD} ]]
597  {   then
598   mke2fs -j -q ${ROOTHDD} || die   mkswap ${SWAPHDD} || die
599     fi
600     if [[ -n ${BOOTHDD} ]]
601     then
602     mkfs.${FORMAT_FILESYSTEM_BOOTHDD} ${BOOTHDD} &> /tmp/format.log || die
603     fi
604     if [[ -n ${ROOTHDD} ]]
605     then
606     mkfs.${FORMAT_FILESYSTEM_ROOTHDD} ${ROOTHDD} &> /tmp/format.log || die
607     fi
608  }  }
609    
610  install_mount_rootfs()  install_mount_rootfs()
611  {  {
612   swapon ${SWAPHDD} || die   local opts
  mount ${ROOTHDD} ${INSTALLPATH} || die  
  install -d ${INSTALLPATH}/boot || die  
  mount ${BOOTHDD} ${INSTALLPATH}/boot || die  
  cd ${INSTALLPATH} || die  
 }  
613    
614  install_mount_rootfs_simple()   if [[ -n ${SWAPHDD} ]]
615  {   then
616   mount ${ROOTHDD} ${INSTALLPATH} || die   swapon ${SWAPHDD} || die
617   install -d ${INSTALLPATH}/boot || die   fi
618   cd ${INSTALLPATH} || die   if [[ -n ${ROOTHDD} ]]
619     then
620     mount -t ${FORMAT_FILESYSTEM_ROOTHDD} ${ROOTHDD} ${INSTALL_ROOT} || die
621     fi
622     if [[ -n ${BOOTHDD} ]]
623     then
624     install -d ${INSTALL_ROOT}/boot || die
625     mount -t ${FORMAT_FILESYSTEM_BOOTHDD} ${BOOTHDD} ${INSTALL_ROOT}/boot || die
626     fi
627    
628     cd ${INSTALL_ROOT} || die
629  }  }
630    
631  install_system_image()  install_system_image()
632  {  {
633   tar xvjpf ${CDPATH}/system/${CDIMAGENAME} -C ${INSTALLPATH}   tar xvjpf ${CDPATH}/system/${CDIMAGENAME} -C ${INSTALL_ROOT}
634  }  }
635    
636  install_bootsector_chroot()  install_bootsector_chroot()
637  {  {
638   local my_roothdd   local my_roothdd
639   local grubconf=${INSTALLPATH}/boot/grub/grub.conf   local grubconf=${INSTALL_ROOT}/boot/grub/grub.conf
640   local grub2conf=/boot/grub/grub.cfg   local grub2conf=/boot/grub/grub.cfg
641     local CONFIG
642    
643   # check for grub2   # check for grub2
644   if [[ -f ${INSTALLPATH}/sbin/grub-mkconfig ]]   if [[ -f ${INSTALL_ROOT}/sbin/grub-mkconfig ]]
645   then   then
646   # needed by grub-mkconfig on the first run   # needed by grub-mkconfig on the first run
647   if [[ ! -f ${INSTALLPATH}/boot/grub/video.lst ]]   if [[ ! -f ${INSTALL_ROOT}/boot/grub/video.lst ]]
648   then   then
649   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
650   fi   fi
651    
652   # set kernelopts   # set kernelopts
653   if [[ -f ${INSTALLPATH}/etc/conf.d/grub ]]   if [[ -f ${INSTALL_ROOT}/etc/conf.d/grub ]]
654   then   then
655   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
656   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
657   else   else
658   echo "export GRUB_CMDLINE_LINUX_DEFAULT=\"${KERNELOPTS}\"" >  ${INSTALLPATH}/etc/conf.d/grub || die   CONFIG=${INSTALL_ROOT}/etc/conf.d/grub
659   echo "export GRUB_GFXPAYLOAD_LINUX=\"${GRUB2GFXPAYLOAD}\"" >>  ${INSTALLPATH}/etc/conf.d/grub || die   clearconfig
660   fi   addconfig "export GRUB_CMDLINE_LINUX_DEFAULT=\"${KERNELOPTS}\""
661   echo 'grub-mkdevicemap' > ${INSTALLPATH}/root/.installrc || die   addconfig "export GRUB_GFXPAYLOAD_LINUX=\"${GRUB2GFXPAYLOAD}\""
662   echo "LC_ALL=C grub-mkconfig -o ${grub2conf}  &> /dev/null" >> ${INSTALLPATH}/root/.installrc || die   fi
663   echo "grub-install --no-floppy ${HDD} &> /dev/null" >> ${INSTALLPATH}/root/.installrc || die   CONFIG=${INSTALL_ROOT}/.installrc
664   echo "exit 0" >> ${INSTALLPATH}/root/.installrc || die   clearconfig
665     addconfig 'grub-mkdevicemap'
666     addconfig "LC_ALL=C grub-mkconfig -o ${grub2conf}  &> /dev/null"
667     addconfig "grub-install --no-floppy ${HDD} &> /dev/null"
668     addconfig "exit 0"
669    
670   # grub-legacy   # grub-legacy
671   else   else
672   ### grubconf schreiben   ### grubconf schreiben
673   source ${INSTALLPATH}/boot/kernelversion   source ${INSTALL_ROOT}/boot/kernelversion
674    
675   #for alx only   #for alx only
676   if [ -e ${INSTALLPATH}/etc/alx_version ]   if [ -e ${INSTALL_ROOT}/etc/alx_version ]
677   then   then
678   OLD_ALXVER="${ALXVER}"   OLD_ALXVER="${ALXVER}"
679   source ${INSTALLPATH}/etc/alx_version   source ${INSTALL_ROOT}/etc/alx_version
680   KRNVER="ALX-${ALXVER}"   KRNVER="ALX-${ALXVER}"
681   ALXVER="${OLD_ALXVER}"   ALXVER="${OLD_ALXVER}"
682   fi   fi
# Line 699  install_bootsector_chroot() Line 693  install_bootsector_chroot()
693   my_roothdd="${ROOTHDD}"   my_roothdd="${ROOTHDD}"
694   fi   fi
695    
696   : > ${grubconf} || die   CONFIG="${grubconf}"
697   echo "default 0" >> ${grubconf} || die   clearconfig
698   echo "timeout 3" >> ${grubconf} || die   addconfig "default 0"
699     addconfig "timeout 3"
700   # using current root password   # using current root password
701   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)"
702     addconfig
703   echo  >> ${grubconf} || die   addconfig "# normal boot"
704   echo "# normal boot" >> ${grubconf} || die   addconfig "title ${KRNVER}"
705   echo "title ${KRNVER}" >> ${grubconf} || die   addconfig "root (hd0,0)"
706   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  
707   if is_initrd_supported   if is_initrd_supported
708   then   then
709   echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die   addconfig "initrd /boot/${KRNINITRD}"
710   fi   fi
711     addconfig
712   echo >> ${grubconf} || die   addconfig "# admin boot"
713   echo "# admin boot" >> ${grubconf} || die   addconfig "title ${KRNVER} - Re-run hardware-detection"
714   echo "title ${KRNVER} - Re-run hardware-detection" >> ${grubconf} || die   addconfig "lock"
715   echo "lock"  >> ${grubconf} || die   addconfig "root (hd0,0)"
716   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  
717   if is_initrd_supported   if is_initrd_supported
718   then   then
719   echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die   addconfig "initrd /boot/${KRNINITRD}"
720   fi   fi
721     addconfig
722   echo >> ${grubconf} || die   addconfig "title ${KRNVER} - Reset *all* local settings"
723   echo "title ${KRNVER} - Reset *all* local settings" >> ${grubconf} || die   addconfig "lock"
724   echo "lock"  >> ${grubconf} || die   addconfig "root (hd0,0)"
725   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  
726   if is_initrd_supported   if is_initrd_supported
727   then   then
728   echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die   addconfig "initrd /boot/${KRNINITRD}"
729   fi   fi
730    
731   # write bootsector chrooted (lfs/magellan)   # write bootsector chrooted (lfs/magellan)
732   cat > ${INSTALLPATH}/root/.installrc << CHROOTEOF   CONFIG=${INSTALL_ROOT}/.installrc
733  /usr/sbin/grub --no-floppy --batch << "EOF" 1> /dev/null 2> /dev/null   clearconfig
734  root (hd0,0)   addconfig '/usr/sbin/grub --no-floppy --batch << "EOF" 1> /dev/null 2> /dev/null'
735  setup (hd0)   addconfig 'root (hd0,0)'
736  quit   addconfig 'setup (hd0)'
737  EOF   addconfig 'quit'
738  exit 0   addconfig 'EOF'
739  CHROOTEOF   addconfig 'exit 0'
740   fi   fi
741    
742   ## enters chroot   ## enter chroot
743   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  
744  }  }
745    
746  is_initrd_supported()  is_initrd_supported()
747  {  {
748   # only generate initrds if the cmd exists   # only generate initrds if the cmd exists
749   [[ -x ${INSTALLPATH}/sbin/mkinitrd ]] && return 0   [[ -x ${INSTALL_ROOT}/sbin/mkinitrd ]] && return 0
750   return 1   return 1
751  }  }
752    
753  install_initrd_chroot()  install_initrd_chroot()
754  {  {
755     local CONFIG
756    
757   # only generate initrds if the cmd exists   # only generate initrds if the cmd exists
758   is_initrd_supported || return 0   is_initrd_supported || return 0
759    
760     FSMODS="${FORMAT_FILESYSTEM_BOOTHDD} ${FORMAT_FILESYSTEM_ROOTHDD}"
761   DISKMODS="sd_mod"   DISKMODS="sd_mod"
762   OLDPATAMODS="amd74xx piix sis5513 via82cxxx"   OLDPATAMODS="amd74xx piix sis5513 via82cxxx"
763   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 792  install_initrd_chroot() Line 780  install_initrd_chroot()
780   fi   fi
781    
782   # install an appropriate uvesafb.conf   # install an appropriate uvesafb.conf
783   install -d ${INSTALLPATH}/etc/modprobe.d || die   CONFIG=${INSTALL_ROOT}/etc/modprobe.d/uvesafb.conf
784   echo "options uvesafb mode_option=1024x768-32@60 scroll=ywrap" > ${INSTALLPATH}/etc/modprobe.d/uvesafb.conf || die   clearconfig
785     addconfig "options uvesafb mode_option=1024x768-32@60 scroll=ywrap"
786    
787   # install an appropriate viafb.conf   # install an appropriate viafb.conf
788   echo "options viafb viafb_mode=1024x768 viafb_refresh=60" > ${INSTALLPATH}/etc/modprobe.d/viafb.conf || die   CONFIG=${INSTALL_ROOT}/etc/modprobe.d/viafb.conf
789     clearconfig
790     addconfig "options viafb viafb_mode=1024x768 viafb_refresh=60"
791    
792   # install an appropriate i810fb.conf   # install an appropriate i810fb.conf
793   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
794     clearconfig
795   cat > ${INSTALLPATH}/root/.installrc << CHROOTEOF   addconfig "options i810fb xres=1024 yres=768 bpp=16 mtrr=1 hsync1=30 hsync2=62 vsync1=30 vsync2=60"
796  echo "MODULES=\"${FORMAT_FILESYSTEM} ${DISKMODS} ${OLDATAMODS} ${PATAMODS} ${SATAMODS} ${DRMMODS} ${FBMODS} ${OTHERMODS}\"" > /etc/conf.d/mkinitrd  
797  mkinitrd -f /boot/$(readlink /boot/initrd) $(readlink /boot/vmlinuz | sed "s:kernel-::g") > /dev/null   CONFIG=${INSTALL_ROOT}/.installrc
798  exit 0   clearconfig
799  CHROOTEOF   addconfig 'echo "MODULES=\"${FSMODS} ${DISKMODS} ${OLDATAMODS} ${PATAMODS} ${SATAMODS} ${DRMMODS} ${FBMODS} ${OTHERMODS}\"" > /etc/conf.d/mkinitrd'
800     addconfig 'mkinitrd -f /boot/$(readlink /boot/initrd) $(readlink /boot/vmlinuz | sed "s:kernel-::g") > /dev/null'
801   ## enters chroot   addconfig 'exit 0'
802   mount -t proc proc ${INSTALLPATH}/proc   ## enter chroot
803   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  
804  }  }
805    
806  is_uuid_supported()  is_uuid_supported()
807  {  {
808   if [[ -x $(which busybox.mkinitrd &> /dev/null) ]]   # f2fs needs special treatments as the old busybox does not support this fs
809     # use the blkid from util-linux instead of busybox
810     if [[ ${FORMAT_FILESYSTEM} = f2fs ]]
811   then   then
812   # only detect uuids if supported   if [[ -x $(type -P blkid) ]]
  if [[ ! -z $(busybox.mkinitrd | grep blkid) ]]  
813   then   then
814   return 0   return 0
815     fi
816     else
817     if [[ -x $(type -P busybox.mkinitrd) ]]
818     then
819     # only detect uuids if supported
820     if [[ ! -z $(busybox.mkinitrd | grep blkid) ]]
821     then
822     return 0
823     fi
824   fi   fi
825   fi   fi
826    
# Line 837  get_uuid() Line 832  get_uuid()
832   local UUID   local UUID
833   local SEC_TYPE   local SEC_TYPE
834   local TYPE   local TYPE
835     local blkidcmd
836    
837   local dev="$1"   local dev="$1"
838   [[ -z ${dev} ]] && die "no dev given"   [[ -z ${dev} ]] && die "no dev given"
# Line 846  get_uuid() Line 842  get_uuid()
842   then   then
843   eval "${dev}"   eval "${dev}"
844   else   else
845   eval $(busybox.mkinitrd blkid ${dev} | grep "${dev}:" | sed 's/.*:\ //')   # f2fs needs special treatments as the old busybox does not support this fs
846     # use the blkid from util-linux instead of busybox
847     if [[ ${FORMAT_FILESYSTEM} = f2fs ]]
848     then
849     blkidcmd="blkid"
850     else
851     blkidcmd="busybox.mkinitrd blkid"
852     fi
853     eval $(${blkidcmd} ${dev} | grep "${dev}:" | sed 's/.*:\ //')
854   fi   fi
855   echo "${UUID}"   echo "${UUID}"
856  }  }
857    
858  install_system_settings()  install_system_settings()
859  {  {
860   # schreibe fstab   local CONFIG
861   if is_uuid_supported   local fstype
862    
863     # write fstab
864     CONFIG=${INSTALL_ROOT}/etc/fstab
865     clearconfig
866    
867     if [[ -n ${BOOTHDD} ]]
868   then   then
869   echo -e "UUID=$(get_uuid ${BOOTHDD})\t/boot\t${FORMAT_FILESYSTEM}\tnoatime,noauto\t1 1" > ${INSTALLPATH}/etc/fstab || die   if is_uuid_supported
870   echo -e "UUID=$(get_uuid ${ROOTHDD})\t/\t${FORMAT_FILESYSTEM}\tnoatime\t0 0" >> ${INSTALLPATH}/etc/fstab || die   then
871   else   addconfig -e "UUID=$(get_uuid ${BOOTHDD})\t/boot\t${FORMAT_FILESYSTEM_BOOTHDD}\tnoatime,noauto\t1 1"
872   echo -e "${BOOTHDD}\t/boot\t${FORMAT_FILESYSTEM}\tnoatime,noauto\t1 1" > ${INSTALLPATH}/etc/fstab || die   else
873   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"
874     fi
875   fi   fi
876    
877     if [[ -n ${ROOTHDD} ]]
878     then
879     if is_uuid_supported
880     then
881     addconfig -e "UUID=$(get_uuid ${ROOTHDD})\t/\t${FORMAT_FILESYSTEM_ROOTHDD}\tnoatime\t0 0"
882     else
883     addconfig -e "${ROOTHDD}\t/\t${FORMAT_FILESYSTEM_ROOTHDD}\tnoatime\t0 0"
884     fi
885     fi
886    
887   # 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
888   #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"
889   echo -e "proc\t/proc\tproc\tdefaults\t0 0" >> ${INSTALLPATH}/etc/fstab || die   addconfig -e "proc\t/proc\tproc\tdefaults\t0 0"
890   echo -e "shm\t/dev/shm\ttmpfs\tdefaults\t0 0" >> ${INSTALLPATH}/etc/fstab || die   addconfig -e "shm\t/dev/shm\ttmpfs\tdefaults\t0 0"
891    
892   # install network config skeleton   # install network config skeleton
893   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
894    
895   # intel framebufer quirk   # intel framebufer quirk
896   if [[ -e /proc/fb ]]   if [[ -e /proc/fb ]]
# Line 878  install_system_settings() Line 900  install_system_settings()
900   fbdev=$(grep 'inteldrmfb' /proc/fb | sed 's:\([0-9]\).*:\1:')   fbdev=$(grep 'inteldrmfb' /proc/fb | sed 's:\([0-9]\).*:\1:')
901   if [[ ${fbdev} != 0 ]]   if [[ ${fbdev} != 0 ]]
902   then   then
903   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
904   fi   fi
905   fi   fi
906   fi   fi
907  }  }
908    
 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  
 }  
   
909  install_umount_rootfs()  install_umount_rootfs()
910  {  {
911   cd /   cd /
912   umount ${INSTALLPATH}/boot || die   if [[ -n ${BOOTHDD} ]]
913   umount ${INSTALLPATH} || die   then
914   swapoff ${SWAPHDD} || die   umount ${INSTALL_ROOT}/boot || die
915  }   fi
916     if [[ -n ${ROOTHDD} ]]
917  install_umount_rootfs_simple()   then
918  {   umount ${INSTALL_ROOT} || die
919   cd /   fi
920   umount ${INSTALLPATH} || die   if [[ -n ${SWAPHDD} ]]
921     then
922     swapoff ${SWAPHDD} || die
923     fi
924  }  }
925    
926  install_do_reboot()  install_do_reboot()
# Line 920  install_do_reboot() Line 932  install_do_reboot()
932  #     Install Main Scripts #  #     Install Main Scripts #
933  #################################################  #################################################
934    
935  run_install_normal()  run_install()
936  {  {
937     local method="$1"
938    
939     # setup install environment
940     export KERNELOPTS="${DEFAULT_KERNELOPTS}"
941     export GRUBLEGACYOPTS="${GRUBLEGACYOPTS}"
942     export GRUB2OPTS="${GRUB2OPTS}"
943     export GRUB2GFXPAYLOAD="${DEFAULT_GRUB2GFXPAYLOAD}"
944     export FORMFACTOR="${DEFAULT_FORMFACTOR}"
945     export FORMAT_FILESYSTEM="${DEFAULT_FORMAT_FILESYSTEM}"
946    
947     case "${method}" in
948     auto)
949     export FORMAT_FILESYSTEM_BOOTHDD=""
950     export FORMAT_FILESYSTEM_ROOTHDD="${FORMAT_FILESYSTEM}"
951     export INSTALL_METHOD="${method}"
952     ;;
953     normal)
954     export FORMAT_FILESYSTEM_BOOTHDD="${FORMAT_FILESYSTEM}"
955     export FORMAT_FILESYSTEM_ROOTHDD="${FORMAT_FILESYSTEM}"
956     export INSTALL_METHOD="${method}"
957     ;;
958     single)
959     export FORMAT_FILESYSTEM_BOOTHDD=""
960     export FORMAT_FILESYSTEM_ROOTHDD="${FORMAT_FILESYSTEM}"
961     export INSTALL_METHOD="${method}"
962     ;;
963     flash)
964     export FORMAT_FILESYSTEM="f2fs"
965     export FORMAT_FILESYSTEM_BOOTHDD="ext2"
966     export FORMAT_FILESYSTEM_ROOTHDD="${FORMAT_FILESYSTEM}"
967     export INSTALL_METHOD="${method}"
968     ;;
969     *)
970     die "Unknown install method '${method}', aborting."
971     ;;
972     esac
973    
974   dialog_hardware_detection   dialog_hardware_detection
975    
976   dialog_setup_hdd_partitions_manuell   dialog_setup_hdd_partitions
977   dialog_setup_hdd_format   dialog_setup_hdd_format
978   setup_hdd_format > /dev/null   setup_hdd_format > /dev/null
979   install_mount_rootfs   install_mount_rootfs
# Line 942  run_install_normal() Line 991  run_install_normal()
991   dialog_install_successful   dialog_install_successful
992  }  }
993    
994  run_install_simple()  # set some proper traps
995  {  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  
 }  
996    
997  dialog_main  dialog_main
998    

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