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 2390 by niro, Wed Jun 15 08:58:22 2011 UTC revision 3199 by niro, Wed Sep 14 11:11:55 2011 UTC
# Line 21  cdromdev="$(echo ${cdromdev} | sed 's/ / Line 21  cdromdev="$(echo ${cdromdev} | sed 's/ /
21  ########################################  ########################################
22    
23  ### System/Config Version  ### System/Config Version
24  VERSION="0.3.7"  VERSION="%VERSIONTAG%"
25  TITLE="alxinstall-ng - ${VERSION}"  TITLE="alxinstall-ng - ${VERSION}"
26    
27  CDPATH="/mnt/cdrom"  CDPATH="/mnt/cdrom"
# Line 31  INSTALLPATH="/mnt/magellan" Line 31  INSTALLPATH="/mnt/magellan"
31  CURRENTLINE=0  CURRENTLINE=0
32  #TOTALLINES=11072 # -> now in images.conf  #TOTALLINES=11072 # -> now in images.conf
33    
34  # standart kernel opts  # standard kernel opts
35  KERNELOPTS="quiet"  KERNELOPTS="quiet video=1024x768"
36    
37    # grub options
38    GRUBLEGACYOPTS=""
39    GRUB2OPTS=""
40    
41    # fdisk options
42    FDISKPARTIONBELOW256MB=0
43    
44  # default specialdevices  # default specialdevices
45  SPECIALDEVICE=""  SPECIALDEVICE=""
# Line 200  dialog_hardware_detection() Line 207  dialog_hardware_detection()
207   run_hardware_detection   run_hardware_detection
208   case "${SPECIALDEVICE}" in   case "${SPECIALDEVICE}" in
209   zotac) echo " \n\n\n \\Z2Zotac Device erkannt!\\Zn \\" >> ${hwtmp} ;;   zotac) echo " \n\n\n \\Z2Zotac Device erkannt!\\Zn \\" >> ${hwtmp} ;;
210     "rangee+256mb")  echo " \n\n\n \\Z2Rangee Device mit Flashdisk (=< 256MB) erkannt!\\Zn \\" >> ${hwtmp} ;;
211     rangee) echo " \n\n\n \\Z2Rangee Device erkannt!\\Zn \\" >> ${hwtmp} ;;
212   *) echo " \n\n\n \\ZnStandard Device erkannt!\\Zn \\" >> ${hwtmp} ;;   *) echo " \n\n\n \\ZnStandard Device erkannt!\\Zn \\" >> ${hwtmp} ;;
213   esac   esac
214    
# Line 431  dialog_main() Line 440  dialog_main()
440  #################################################  #################################################
441  run_hardware_detection()  run_hardware_detection()
442  {  {
443     local hwinfo
444    
445     hwinfo="$(hwinfo --bios --storage)"
446    
447   # check for special devices/clients:   # check for special devices/clients:
448   # if zotac a zotac and the disk is a removeable device, then add rootdelay to kernelcmd   # if zotac a zotac and the disk is a removeable device, then add rootdelay to kernelcmd
449   local removable=0   local removable=0
450   if [[ ! -z $(hwinfo --bios --storage | grep -i zotac) ]]   if [[ ! -z $(echo "${hwinfo}" | grep -i zotac) ]]
451   then   then
452   for i in /sys/block/[hs]d*/removable   for i in /sys/block/[hs]d*/removable
453   do   do
# Line 444  run_hardware_detection() Line 457  run_hardware_detection()
457   fi   fi
458   done   done
459    
460   export KERNELOPTS="${KERNELOPTS} rootdelay=8"   # only add this for grub legacy, grub2 detect these settings on its own
461     export GRUBLEGACYOPTS="rootdelay=8"
462   export SPECIALDEVICE="zotac"   export SPECIALDEVICE="zotac"
463   fi   fi
464    
465     # check for special devices/clients:
466     # if a rangee and disk ist smaller then 256mb move partion one block further ahead
467     if [[ ! -z $(echo "${hwinfo}" | grep -i CLE266) ]]
468     then
469     # for a rangee always define partion startblock +1
470     export FDISKPARTIONBELOW256MB="1"
471     export SPECIALDEVICE="rangee"
472     export GRUBLEGACYOPTS=""
473     fi
474    }
475    
476    hdd_size_below_256mb()
477    {
478     local hdd="$1"
479     local size
480     local retval
481     [[ -z ${hdd} ]] && die "Error: get_hdd_size() no \$hdd given!"
482    
483     size=$(fdisk -l ${hdd} | grep "Disk.*${hdd}" | sed 's:.*,\ \(.*\)\ byte.*:\1:')
484     if [[ ${size} -le 257000000 ]]
485     then
486     retval="0"
487     else
488     retval="1"
489     fi
490    
491     return "${retval}"
492  }  }
493    
494  setup_hdd_partitions_auto()  setup_hdd_partitions_auto()
495  {  {
496   ROOTHDD="${HDD}1"   ROOTHDD="${HDD}1"
497    
498     # run this only if FDISKPARTITIONBELOW256MB is not already 1
499     if [[ ${FDISKPARTIONBELOW256MB} != 1 ]]
500     then
501     if hdd_size_below_256mb ${HDD}
502     then
503     FDISKPARTIONBELOW256MB=1
504     else
505     FDISKPARTIONBELOW256MB=0
506     fi
507     fi
508    
509   ## delete disk   ## delete disk
510   dd if=/dev/zero of=${HDD} count=1 &> /dev/null || die   dd if=/dev/zero of=${HDD} count=1 &> /dev/null || die
511    
512   ## setup one bootable partition   if [[ ${FDISKPARTIONBELOW256MB} = 1 ]]
513   #1. n= new disk   then
514   #2. p= primary disk   ## setup one bootable partition
515   #3. 1= first partition   #1. n= new disk
516   #4. ''= default sector start   #2. p= primary disk
517   #5. ''= defaul sector end   #3. 1= first partition
518   #6. a= bootable flag   #4. 2= default sector start // small disk needs more space for grub2 mbr sector
519   #7. 1= boot flag for partition 1   #5. ''= defaul sector end
520   #8. w= write/quit   #6. a= bootable flag
521   fdisk ${HDD} &> /dev/null << EOF   #7. 1= boot flag for partition 1
522     #8. w= write/quit
523     fdisk ${HDD} &> /dev/null << EOF
524    n
525    p
526    1
527    2
528    
529    a
530    1
531    w
532    EOF
533     else
534     ## setup one bootable partition
535     #1. n= new disk
536     #2. p= primary disk
537     #3. 1= first partition
538     #4. ''= default sector start
539     #5. ''= defaul sector end
540     #6. a= bootable flag
541     #7. 1= boot flag for partition 1
542     #8. w= write/quit
543     fdisk ${HDD} &> /dev/null << EOF
544  n  n
545  p  p
546  1  1
# Line 475  a Line 550  a
550  1  1
551  w  w
552  EOF  EOF
553     fi
554  }  }
555    
556  setup_hdd_partitions_manuell()  setup_hdd_partitions_manuell()
# Line 531  install_system_image() Line 607  install_system_image()
607  install_bootsector_chroot()  install_bootsector_chroot()
608  {  {
609   local my_roothdd   local my_roothdd
610     local grubconf=${INSTALLPATH}/boot/grub/grub.conf
611     local grub2conf=/boot/grub/grub.cfg
612    
613   ### grubconf schreiben   # check for grub2
614   source ${INSTALLPATH}/boot/kernelversion   if [[ -f ${INSTALLPATH}/sbin/grub-mkconfig ]]
   
  #for alx only  
  if [ -e ${INSTALLPATH}/etc/alx_version ]  
615   then   then
616   OLD_ALXVER="${ALXVER}"   # needed by grub-mkconfig on the first run
617   source ${INSTALLPATH}/etc/alx_version   if [[ ! -f ${INSTALLPATH}/boot/grub/video.lst ]]
618   KRNVER="ALX-${ALXVER}"   then
619   ALXVER="${OLD_ALXVER}"   install -m0644 ${INSTALLPATH}/lib/grub/*/video.lst ${INSTALLPATH}/boot/grub/video.lst || die
620   fi   fi
621    
622   [[ -z ${KRNVER} ]] && KRNVER="AutoSta_LX"   # set kernelopts
623   [[ -z ${KRNINITRD} ]] && KRNINITRD="initrd"   if [[ -f ${INSTALLPATH}/etc/conf.d/grub ]]
624   [[ -z ${KRNIMG} ]] && KRNIMG="vmlinuz"   then
625     sed -i "s:^\(export GRUB_CMDLINE_LINUX_DEFAULT=\).*:\1\"${KERNELOPTS}\":" ${INSTALLPATH}/etc/conf.d/grub || die
626     else
627     echo "export GRUB_CMDLINE_LINUX_DEFAULT=\"${KERNELOPTS}\"" >  ${INSTALLPATH}/etc/conf.d/grub || die
628     fi
629     echo 'grub-mkdevicemap' > ${INSTALLPATH}/root/.installrc || die
630     echo "LC_ALL=C grub-mkconfig -o ${grub2conf}  &> /dev/null" >> ${INSTALLPATH}/root/.installrc || die
631     echo "grub-install --no-floppy ${HDD} &> /dev/null" >> ${INSTALLPATH}/root/.installrc || die
632     echo "exit 0" >> ${INSTALLPATH}/root/.installrc || die
633    
634   # uuid support   # grub-legacy
  if is_uuid_supported  
  then  
  my_roothdd="UUID=$(get_uuid ${ROOTHDD})"  
635   else   else
636   my_roothdd="${ROOTHDD}"   ### grubconf schreiben
637   fi   source ${INSTALLPATH}/boot/kernelversion
638    
639   local grubconf=${INSTALLPATH}/boot/grub/grub.conf   #for alx only
640   : > ${grubconf} || die   if [ -e ${INSTALLPATH}/etc/alx_version ]
641   echo "default 0" >> ${grubconf} || die   then
642   echo "timeout 3" >> ${grubconf} || die   OLD_ALXVER="${ALXVER}"
643   # using current root password   source ${INSTALLPATH}/etc/alx_version
644   echo "password --md5 $(cat ${INSTALLPATH}/etc/shadow | grep root | cut -d: -f2)"  >> ${grubconf} || die   KRNVER="ALX-${ALXVER}"
645     ALXVER="${OLD_ALXVER}"
646     fi
647    
648   echo  >> ${grubconf} || die   [[ -z ${KRNVER} ]] && KRNVER="AutoSta_LX"
649   echo "# normal boot" >> ${grubconf} || die   [[ -z ${KRNINITRD} ]] && KRNINITRD="initrd"
650   echo "title ${KRNVER}" >> ${grubconf} || die   [[ -z ${KRNIMG} ]] && KRNIMG="vmlinuz"
  echo "root (hd0,0)" >> ${grubconf} || die  
  echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS}" >> ${grubconf} || die  
  if is_initrd_supported  
  then  
  echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die  
  fi  
651    
652   echo >> ${grubconf} || die   # uuid support
653   echo "# admin boot" >> ${grubconf} || die   if is_uuid_supported
654   echo "title ${KRNVER} - Re-run hardware-detection" >> ${grubconf} || die   then
655   echo "lock"  >> ${grubconf} || die   my_roothdd="UUID=$(get_uuid ${ROOTHDD})"
656   echo "root (hd0,0)" >> ${grubconf} || die   else
657   echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} hardware-auto-detection" >> ${grubconf} || die   my_roothdd="${ROOTHDD}"
658   if is_initrd_supported   fi
  then  
  echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die  
  fi  
659    
660   echo >> ${grubconf} || die   : > ${grubconf} || die
661   echo "title ${KRNVER} - Reset *all* local settings" >> ${grubconf} || die   echo "default 0" >> ${grubconf} || die
662   echo "lock"  >> ${grubconf} || die   echo "timeout 3" >> ${grubconf} || die
663   echo "root (hd0,0)" >> ${grubconf} || die   # using current root password
664   echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} alx-reset-settings" >> ${grubconf} || die   echo "password --md5 $(cat ${INSTALLPATH}/etc/shadow | grep root | cut -d: -f2)"  >> ${grubconf} || die
665   if is_initrd_supported  
666   then   echo  >> ${grubconf} || die
667   echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die   echo "# normal boot" >> ${grubconf} || die
668   fi   echo "title ${KRNVER}" >> ${grubconf} || die
669     echo "root (hd0,0)" >> ${grubconf} || die
670     echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS}" >> ${grubconf} || die
671     if is_initrd_supported
672     then
673     echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die
674     fi
675    
676     echo >> ${grubconf} || die
677     echo "# admin boot" >> ${grubconf} || die
678     echo "title ${KRNVER} - Re-run hardware-detection" >> ${grubconf} || die
679     echo "lock"  >> ${grubconf} || die
680     echo "root (hd0,0)" >> ${grubconf} || die
681     echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS} hardware-auto-detection" >> ${grubconf} || die
682     if is_initrd_supported
683     then
684     echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die
685     fi
686    
687     echo >> ${grubconf} || die
688     echo "title ${KRNVER} - Reset *all* local settings" >> ${grubconf} || die
689     echo "lock"  >> ${grubconf} || die
690     echo "root (hd0,0)" >> ${grubconf} || die
691     echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS} alx-reset-settings" >> ${grubconf} || die
692     if is_initrd_supported
693     then
694     echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die
695     fi
696    
697   # bootsector schreiben chrooted schreiben (lfs/magellan)   # bootsector schreiben chrooted schreiben (lfs/magellan)
698   cat > ${INSTALLPATH}/root/.bashrc << CHROOTEOF   cat > ${INSTALLPATH}/root/.installrc << CHROOTEOF
699  /usr/sbin/grub --no-floppy --batch << "EOF" 1> /dev/null 2> /dev/null  /usr/sbin/grub --no-floppy --batch << "EOF" 1> /dev/null 2> /dev/null
700  root (hd0,0)  root (hd0,0)
701  setup (hd0)  setup (hd0)
# Line 603  quit Line 703  quit
703  EOF  EOF
704  exit 0  exit 0
705  CHROOTEOF  CHROOTEOF
706     fi
707    
708   ## enters chroot   ## enters chroot
709   mount -t proc proc ${INSTALLPATH}/proc   mount -t proc proc ${INSTALLPATH}/proc
710   mount -t sysfs sysfs ${INSTALLPATH}/sys   mount -t sysfs sysfs ${INSTALLPATH}/sys
711   mount -o bind /dev ${INSTALLPATH}/dev   mount -o bind /dev ${INSTALLPATH}/dev
712   chroot ${INSTALLPATH} /bin/bash --rcfile /root/.bashrc -i   chroot ${INSTALLPATH} /bin/bash --rcfile /root/.installrc -i
713   umount ${INSTALLPATH}/proc   umount ${INSTALLPATH}/proc
714   umount ${INSTALLPATH}/sys   umount ${INSTALLPATH}/sys
715   umount ${INSTALLPATH}/dev   umount ${INSTALLPATH}/dev
716   rm ${INSTALLPATH}/root/.bashrc   rm ${INSTALLPATH}/root/.installrc
717  }  }
718    
719  is_initrd_supported()  is_initrd_supported()
# Line 627  install_initrd_chroot() Line 728  install_initrd_chroot()
728   # only generate initrds if the cmd exists   # only generate initrds if the cmd exists
729   is_initrd_supported || return 0   is_initrd_supported || return 0
730    
731   cat > ${INSTALLPATH}/root/.bashrc << CHROOTEOF   DISKMODS="sd_mod"
732  echo "MODULES=\"${FORMAT_FILESYSTEM} amd74xx piix sis5513 via82cxxx sd_mod ata_piix pata_amd pata_mpiix pata_oldpiix pata_sis pata_via sata_via sata_sis sata_nv\"" > /etc/conf.d/mkinitrd   OLDPATAMODS="amd74xx piix sis5513 via82cxxx"
733     PATAMODS="ata_piix pata_amd pata_mpiix pata_oldpiix pata_sis pata_via"
734     SATAMODS="sata_via sata_sis sata_nv"
735     DRMMODS="i915 mga nouveau r128 radeon savage sis tdfx ttm via"
736     FBMODS="uvesafb"
737    
738     # install an appropriate uvesafb.conf
739     install -d ${INSTALLPATH}/etc/modprobe.d || die
740     echo "options uvesafb mode_option=1024x768-32@60 scroll=ywrap" > ${INSTALLPATH}/etc/modprobe.d/uvesafb.conf || die
741    
742     cat > ${INSTALLPATH}/root/.installrc << CHROOTEOF
743    echo "MODULES=\"${FORMAT_FILESYSTEM} ${DISKMODS} ${OLDATAMODS} ${PATAMODS} ${SATAMODS} ${DRMMODS} ${FBMODS}\"" > /etc/conf.d/mkinitrd
744  mkinitrd -f /boot/$(readlink /boot/initrd) $(readlink /boot/vmlinuz | sed "s:kernel-::g") > /dev/null  mkinitrd -f /boot/$(readlink /boot/initrd) $(readlink /boot/vmlinuz | sed "s:kernel-::g") > /dev/null
745  exit 0  exit 0
746  CHROOTEOF  CHROOTEOF
# Line 637  CHROOTEOF Line 749  CHROOTEOF
749   mount -t proc proc ${INSTALLPATH}/proc   mount -t proc proc ${INSTALLPATH}/proc
750   mount -t sysfs sysfs ${INSTALLPATH}/sys   mount -t sysfs sysfs ${INSTALLPATH}/sys
751   mount -o bind /dev ${INSTALLPATH}/dev   mount -o bind /dev ${INSTALLPATH}/dev
752   chroot ${INSTALLPATH} /bin/bash --rcfile /root/.bashrc -i   chroot ${INSTALLPATH} /bin/bash --rcfile /root/.installrc -i
753   umount ${INSTALLPATH}/proc   umount ${INSTALLPATH}/proc
754   umount ${INSTALLPATH}/sys   umount ${INSTALLPATH}/sys
755   umount ${INSTALLPATH}/dev   umount ${INSTALLPATH}/dev
756   rm ${INSTALLPATH}/root/.bashrc   rm ${INSTALLPATH}/root/.installrc
757  }  }
758    
759  is_uuid_supported()  is_uuid_supported()
# Line 743  run_install_normal() Line 855  run_install_normal()
855   install_mount_rootfs   install_mount_rootfs
856   (install_system_image > /tmp/install.log) 2> /tmp/install_errors.log | dialog_install_meter | dialog_install_system_image   (install_system_image > /tmp/install.log) 2> /tmp/install_errors.log | dialog_install_meter | dialog_install_system_image
857    
  dialog_install_bootsector  
  install_bootsector_chroot  
   
858   dialog_install_settings   dialog_install_settings
859   sleep 1   sleep 1
860   install_system_settings   install_system_settings
861   install_initrd_chroot   install_initrd_chroot
862    
863     dialog_install_bootsector
864     install_bootsector_chroot
865    
866   install_umount_rootfs   install_umount_rootfs
867   dialog_install_successful   dialog_install_successful
868  }  }
# Line 764  run_install_flash() Line 877  run_install_flash()
877   install_mount_rootfs_flash   install_mount_rootfs_flash
878   (install_system_image > /tmp/install.log) 2> /tmp/install_errors.log | dialog_install_meter | dialog_install_system_image   (install_system_image > /tmp/install.log) 2> /tmp/install_errors.log | dialog_install_meter | dialog_install_system_image
879    
  dialog_install_bootsector  
  install_bootsector_chroot  
   
880   dialog_install_settings   dialog_install_settings
881   sleep 1   sleep 1
882   install_system_settings_flash   install_system_settings_flash
883   install_initrd_chroot   install_initrd_chroot
884    
885     dialog_install_bootsector
886     install_bootsector_chroot
887    
888   install_umount_rootfs_flash   install_umount_rootfs_flash
889   dialog_install_successful   dialog_install_successful
890  }  }
# Line 785  run_install_auto() Line 899  run_install_auto()
899   install_mount_rootfs_flash   install_mount_rootfs_flash
900   (install_system_image > /tmp/install.log) 2> /tmp/install_errors.log | dialog_install_meter | dialog_install_system_image   (install_system_image > /tmp/install.log) 2> /tmp/install_errors.log | dialog_install_meter | dialog_install_system_image
901    
  dialog_install_bootsector  
  install_bootsector_chroot  
   
902   dialog_install_settings   dialog_install_settings
903   sleep 1   sleep 1
904   install_system_settings_flash   install_system_settings_flash
905   install_initrd_chroot   install_initrd_chroot
906    
907     dialog_install_bootsector
908     install_bootsector_chroot
909    
910   install_umount_rootfs_flash   install_umount_rootfs_flash
911   dialog_install_successful   dialog_install_successful
912  }  }

Legend:
Removed from v.2390  
changed lines
  Added in v.3199