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

alx-src/trunk/alxinstall-ng/bin/alxinstall-ng.sh revision 2387 by niro, Wed Jun 15 08:47:04 2011 UTC alx-src/trunk/alxinstall-ng/bin/alxinstall-ng.sh.in revision 3373 by niro, Wed Mar 28 09:50:05 2012 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.6"  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) echo " \n\n\n \\Z2Rangee Device erkannt!\\Zn \\" >> ${hwtmp} ;;
211     maxdata) echo " \n\n\n \\Z2Maxdata 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 --pci)"
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 $(lspci -v | 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     # check for special devices/clients:
476     # check for maxdata / i810/ i815 Chipsets and disable KMS and use i810fb frambuffer
477     if [[ ! -z $(echo "${hwinfo}" | grep -i i810) ]] || [[ ! -z $(echo "${hwinfo}" | grep -i i815) ]]
478     then
479     export SPECIALDEVICE="maxdata"
480     export GRUBLEGACYOPTS=""
481     fi
482    }
483    
484    hdd_size_below_256mb()
485    {
486     local hdd="$1"
487     local size
488     local retval
489     [[ -z ${hdd} ]] && die "Error: get_hdd_size() no \$hdd given!"
490    
491     size=$(fdisk -l ${hdd} | grep "Disk.*${hdd}" | sed 's:.*,\ \(.*\)\ byte.*:\1:')
492     if [[ ${size} -le 257000000 ]]
493     then
494     retval="0"
495     else
496     retval="1"
497     fi
498    
499     return "${retval}"
500  }  }
501    
502  setup_hdd_partitions_auto()  setup_hdd_partitions_auto()
503  {  {
504   ROOTHDD="${HDD}1"   ROOTHDD="${HDD}1"
505    
506     # run this only if FDISKPARTITIONBELOW256MB is not already 1
507     if [[ ${FDISKPARTIONBELOW256MB} != 1 ]]
508     then
509     if hdd_size_below_256mb ${HDD}
510     then
511     FDISKPARTIONBELOW256MB=1
512     else
513     FDISKPARTIONBELOW256MB=0
514     fi
515     fi
516    
517   ## delete disk   ## delete disk
518   dd if=/dev/zero of=${HDD} count=1 &> /dev/null || die   dd if=/dev/zero of=${HDD} count=1 &> /dev/null || die
519    
520   ## setup one bootable partition   if [[ ${FDISKPARTIONBELOW256MB} = 1 ]]
521   #1. n= new disk   then
522   #2. p= primary disk   ## setup one bootable partition
523   #3. 1= first partition   #1. n= new disk
524   #4. ''= default sector start   #2. p= primary disk
525   #5. ''= defaul sector end   #3. 1= first partition
526   #6. a= bootable flag   #4. 2= default sector start // small disk needs more space for grub2 mbr sector
527   #7. 1= boot flag for partition 1   #5. ''= defaul sector end
528   #8. w= write/quit   #6. a= bootable flag
529   fdisk ${HDD} &> /dev/null << EOF   #7. 1= boot flag for partition 1
530     #8. w= write/quit
531     fdisk ${HDD} &> /dev/null << EOF
532    n
533    p
534    1
535    2
536    
537    a
538    1
539    w
540    EOF
541     else
542     ## setup one bootable partition
543     #1. n= new disk
544     #2. p= primary disk
545     #3. 1= first partition
546     #4. ''= default sector start
547     #5. ''= defaul sector end
548     #6. a= bootable flag
549     #7. 1= boot flag for partition 1
550     #8. w= write/quit
551     fdisk ${HDD} &> /dev/null << EOF
552  n  n
553  p  p
554  1  1
# Line 475  a Line 558  a
558  1  1
559  w  w
560  EOF  EOF
561     fi
562  }  }
563    
564  setup_hdd_partitions_manuell()  setup_hdd_partitions_manuell()
# Line 531  install_system_image() Line 615  install_system_image()
615  install_bootsector_chroot()  install_bootsector_chroot()
616  {  {
617   local my_roothdd   local my_roothdd
618     local grubconf=${INSTALLPATH}/boot/grub/grub.conf
619     local grub2conf=/boot/grub/grub.cfg
620    
621   ### grubconf schreiben   # check for grub2
622   source ${INSTALLPATH}/boot/kernelversion   if [[ -f ${INSTALLPATH}/sbin/grub-mkconfig ]]
   
  #for alx only  
  if [ -e ${INSTALLPATH}/etc/alx_version ]  
623   then   then
624   OLD_ALXVER="${ALXVER}"   # needed by grub-mkconfig on the first run
625   source ${INSTALLPATH}/etc/alx_version   if [[ ! -f ${INSTALLPATH}/boot/grub/video.lst ]]
626   KRNVER="ALX-${ALXVER}"   then
627   ALXVER="${OLD_ALXVER}"   install -m0644 ${INSTALLPATH}/lib/grub/*/video.lst ${INSTALLPATH}/boot/grub/video.lst || die
628   fi   fi
629    
630   [[ -z ${KRNVER} ]] && KRNVER="AutoSta_LX"   # set kernelopts
631   [[ -z ${KRNINITRD} ]] && KRNINITRD="initrd"   if [[ -f ${INSTALLPATH}/etc/conf.d/grub ]]
632   [[ -z ${KRNIMG} ]] && KRNIMG="vmlinuz"   then
633     sed -i "s:^\(export GRUB_CMDLINE_LINUX_DEFAULT=\).*:\1\"${KERNELOPTS}\":" ${INSTALLPATH}/etc/conf.d/grub || die
634     else
635     echo "export GRUB_CMDLINE_LINUX_DEFAULT=\"${KERNELOPTS}\"" >  ${INSTALLPATH}/etc/conf.d/grub || die
636     fi
637     echo 'grub-mkdevicemap' > ${INSTALLPATH}/root/.installrc || die
638     echo "LC_ALL=C grub-mkconfig -o ${grub2conf}  &> /dev/null" >> ${INSTALLPATH}/root/.installrc || die
639     echo "grub-install --no-floppy ${HDD} &> /dev/null" >> ${INSTALLPATH}/root/.installrc || die
640     echo "exit 0" >> ${INSTALLPATH}/root/.installrc || die
641    
642   # uuid support   # grub-legacy
  if is_uuid_supported  
  then  
  my_roothdd="UUID=$(get_uuid ${ROOTHDD})"  
643   else   else
644   my_roothdd="${ROOTHDD}"   ### grubconf schreiben
645   fi   source ${INSTALLPATH}/boot/kernelversion
646    
647   local grubconf=${INSTALLPATH}/boot/grub/grub.conf   #for alx only
648   : > ${grubconf} || die   if [ -e ${INSTALLPATH}/etc/alx_version ]
649   echo "default 0" >> ${grubconf} || die   then
650   echo "timeout 3" >> ${grubconf} || die   OLD_ALXVER="${ALXVER}"
651   # using current root password   source ${INSTALLPATH}/etc/alx_version
652   echo "password --md5 $(cat ${INSTALLPATH}/etc/shadow | grep root | cut -d: -f2)"  >> ${grubconf} || die   KRNVER="ALX-${ALXVER}"
653     ALXVER="${OLD_ALXVER}"
654     fi
655    
656   echo  >> ${grubconf} || die   [[ -z ${KRNVER} ]] && KRNVER="AutoSta_LX"
657   echo "# normal boot" >> ${grubconf} || die   [[ -z ${KRNINITRD} ]] && KRNINITRD="initrd"
658   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  
659    
660   echo >> ${grubconf} || die   # uuid support
661   echo "# admin boot" >> ${grubconf} || die   if is_uuid_supported
662   echo "title ${KRNVER} - Re-run hardware-detection" >> ${grubconf} || die   then
663   echo "lock"  >> ${grubconf} || die   my_roothdd="UUID=$(get_uuid ${ROOTHDD})"
664   echo "root (hd0,0)" >> ${grubconf} || die   else
665   echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} hardware-auto-detection" >> ${grubconf} || die   my_roothdd="${ROOTHDD}"
666   if is_initrd_supported   fi
  then  
  echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die  
  fi  
667    
668   echo >> ${grubconf} || die   : > ${grubconf} || die
669   echo "title ${KRNVER} - Reset *all* local settings" >> ${grubconf} || die   echo "default 0" >> ${grubconf} || die
670   echo "lock"  >> ${grubconf} || die   echo "timeout 3" >> ${grubconf} || die
671   echo "root (hd0,0)" >> ${grubconf} || die   # using current root password
672   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
673   if is_initrd_supported  
674   then   echo  >> ${grubconf} || die
675   echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die   echo "# normal boot" >> ${grubconf} || die
676   fi   echo "title ${KRNVER}" >> ${grubconf} || die
677     echo "root (hd0,0)" >> ${grubconf} || die
678     echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS}" >> ${grubconf} || die
679     if is_initrd_supported
680     then
681     echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die
682     fi
683    
684   # bootsector schreiben chrooted schreiben (lfs/magellan)   echo >> ${grubconf} || die
685   cat > ${INSTALLPATH}/root/.bashrc << CHROOTEOF   echo "# admin boot" >> ${grubconf} || die
686     echo "title ${KRNVER} - Re-run hardware-detection" >> ${grubconf} || die
687     echo "lock"  >> ${grubconf} || die
688     echo "root (hd0,0)" >> ${grubconf} || die
689     echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS} hardware-auto-detection" >> ${grubconf} || die
690     if is_initrd_supported
691     then
692     echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die
693     fi
694    
695     echo >> ${grubconf} || die
696     echo "title ${KRNVER} - Reset *all* local settings" >> ${grubconf} || die
697     echo "lock"  >> ${grubconf} || die
698     echo "root (hd0,0)" >> ${grubconf} || die
699     echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS} alx-reset-settings" >> ${grubconf} || die
700     if is_initrd_supported
701     then
702     echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die
703     fi
704    
705     # bootsector schreiben chrooted schreiben (lfs/magellan)
706     cat > ${INSTALLPATH}/root/.installrc << CHROOTEOF
707  /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
708  root (hd0,0)  root (hd0,0)
709  setup (hd0)  setup (hd0)
# Line 603  quit Line 711  quit
711  EOF  EOF
712  exit 0  exit 0
713  CHROOTEOF  CHROOTEOF
714     fi
715    
716   ## enters chroot   ## enters chroot
717   mount -t proc proc ${INSTALLPATH}/proc   mount -t proc proc ${INSTALLPATH}/proc
718   mount -t sysfs sysfs ${INSTALLPATH}/sys   mount -t sysfs sysfs ${INSTALLPATH}/sys
719   mount -o bind /dev ${INSTALLPATH}/dev   mount -o bind /dev ${INSTALLPATH}/dev
720   chroot ${INSTALLPATH} /bin/bash --rcfile /root/.bashrc -i   chroot ${INSTALLPATH} /bin/bash --rcfile /root/.installrc -i
721   umount ${INSTALLPATH}/proc   umount ${INSTALLPATH}/proc
722   umount ${INSTALLPATH}/sys   umount ${INSTALLPATH}/sys
723   umount ${INSTALLPATH}/dev   umount ${INSTALLPATH}/dev
724   rm ${INSTALLPATH}/root/.bashrc   rm ${INSTALLPATH}/root/.installrc
725  }  }
726    
727  is_initrd_supported()  is_initrd_supported()
# Line 627  install_initrd_chroot() Line 736  install_initrd_chroot()
736   # only generate initrds if the cmd exists   # only generate initrds if the cmd exists
737   is_initrd_supported || return 0   is_initrd_supported || return 0
738    
739   cat > ${INSTALLPATH}/root/.bashrc << CHROOTEOF   DISKMODS="sd_mod"
740  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"
741     PATAMODS="ata_piix pata_amd pata_mpiix pata_oldpiix pata_sis pata_via"
742     SATAMODS="sata_via sata_sis sata_nv"
743     DRMMODS="i915 mga nouveau r128 radeon savage sis tdfx ttm via"
744     case ${SPECIALDEVICE} in
745     zotac) FBMODS="" ;;
746     rangee) FBMODS="" ;; ## fallback to vesafb, viafb does not run on all CLE266 boards
747     maxdata) FBMODS="i810fb" ;; ## check for maxdata / i810/ i815 Chipsets and disable KMS and use i810fb frambuffer
748     *) FBMODS="uvesafb" ;;
749     esac
750    
751     # install an appropriate uvesafb.conf
752     install -d ${INSTALLPATH}/etc/modprobe.d || die
753     echo "options uvesafb mode_option=1024x768-32@60 scroll=ywrap" > ${INSTALLPATH}/etc/modprobe.d/uvesafb.conf || die
754    
755     # install an appropriate viafb.conf
756     echo "options viafb viafb_mode=1024x768 viafb_refresh=60" > ${INSTALLPATH}/etc/modprobe.d/viafb.conf || die
757    
758     # install an appropriate i810fb.conf
759     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
760    
761     cat > ${INSTALLPATH}/root/.installrc << CHROOTEOF
762    echo "MODULES=\"${FORMAT_FILESYSTEM} ${DISKMODS} ${OLDATAMODS} ${PATAMODS} ${SATAMODS} ${DRMMODS} ${FBMODS}\"" > /etc/conf.d/mkinitrd
763  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
764  exit 0  exit 0
765  CHROOTEOF  CHROOTEOF
# Line 637  CHROOTEOF Line 768  CHROOTEOF
768   mount -t proc proc ${INSTALLPATH}/proc   mount -t proc proc ${INSTALLPATH}/proc
769   mount -t sysfs sysfs ${INSTALLPATH}/sys   mount -t sysfs sysfs ${INSTALLPATH}/sys
770   mount -o bind /dev ${INSTALLPATH}/dev   mount -o bind /dev ${INSTALLPATH}/dev
771   chroot ${INSTALLPATH} /bin/bash --rcfile /root/.bashrc -i   chroot ${INSTALLPATH} /bin/bash --rcfile /root/.installrc -i
772   umount ${INSTALLPATH}/proc   umount ${INSTALLPATH}/proc
773   umount ${INSTALLPATH}/sys   umount ${INSTALLPATH}/sys
774   umount ${INSTALLPATH}/dev   umount ${INSTALLPATH}/dev
775   rm ${INSTALLPATH}/root/.bashrc   rm ${INSTALLPATH}/root/.installrc
776  }  }
777    
778  is_uuid_supported()  is_uuid_supported()
# Line 743  run_install_normal() Line 874  run_install_normal()
874   install_mount_rootfs   install_mount_rootfs
875   (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
876    
  dialog_install_bootsector  
  install_bootsector_chroot  
   
877   dialog_install_settings   dialog_install_settings
878   sleep 1   sleep 1
879   install_system_settings   install_system_settings
880   install_initrd_chroot   install_initrd_chroot
881    
882     dialog_install_bootsector
883     install_bootsector_chroot
884    
885   install_umount_rootfs   install_umount_rootfs
886   dialog_install_successful   dialog_install_successful
887  }  }
# Line 764  run_install_flash() Line 896  run_install_flash()
896   install_mount_rootfs_flash   install_mount_rootfs_flash
897   (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
898    
  dialog_install_bootsector  
  install_bootsector_chroot  
   
899   dialog_install_settings   dialog_install_settings
900   sleep 1   sleep 1
901   install_system_settings_flash   install_system_settings_flash
902   install_initrd_chroot   install_initrd_chroot
903    
904     dialog_install_bootsector
905     install_bootsector_chroot
906    
907   install_umount_rootfs_flash   install_umount_rootfs_flash
908   dialog_install_successful   dialog_install_successful
909  }  }
# Line 785  run_install_auto() Line 918  run_install_auto()
918   install_mount_rootfs_flash   install_mount_rootfs_flash
919   (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
920    
  dialog_install_bootsector  
  install_bootsector_chroot  
   
921   dialog_install_settings   dialog_install_settings
922   sleep 1   sleep 1
923   install_system_settings_flash   install_system_settings_flash
924   install_initrd_chroot   install_initrd_chroot
925    
926     dialog_install_bootsector
927     install_bootsector_chroot
928    
929   install_umount_rootfs_flash   install_umount_rootfs_flash
930   dialog_install_successful   dialog_install_successful
931  }  }

Legend:
Removed from v.2387  
changed lines
  Added in v.3373