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 4853 by niro, Wed May 15 07:25:12 2013 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 199  dialog_hardware_detection() Line 206  dialog_hardware_detection()
206   # other devices   # other devices
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 --gfxcard)"
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 SPECIALDEVICE="zotac"   export GRUBLEGACYOPTS="rootdelay=8"
462     # there are to zotac types in the wild, nvidia based gfx and intel
463     if [[ ! -z $(echo "${hwinfo}" | grep -i nouveau) ]]
464     then
465     export SPECIALDEVICE="zotac_nvidia"
466     else
467     export SPECIALDEVICE="zotac_intel"
468     fi
469     fi
470    
471     # check for special devices/clients:
472     # if a rangee and disk ist smaller then 256mb move partion one block further ahead
473     if [[ ! -z $(echo "${hwinfo}" | grep -i CLE266) ]]
474     then
475     # for a rangee always define partion startblock +1
476     export FDISKPARTIONBELOW256MB="1"
477     export SPECIALDEVICE="rangee"
478     export GRUBLEGACYOPTS=""
479     fi
480    
481     # check for special devices/clients:
482     # check for maxdata / i810/ i815 Chipsets and disable KMS and use i810fb frambuffer
483     if [[ ! -z $(echo "${hwinfo}" | grep -i i810) ]] || [[ ! -z $(echo "${hwinfo}" | grep -i i815) ]]
484     then
485     export SPECIALDEVICE="maxdata"
486     export GRUBLEGACYOPTS=""
487   fi   fi
488  }  }
489    
490    hdd_size_below_256mb()
491    {
492     local hdd="$1"
493     local size
494     local retval
495     [[ -z ${hdd} ]] && die "Error: get_hdd_size() no \$hdd given!"
496    
497     size=$(fdisk -l ${hdd} | grep "Disk.*${hdd}" | sed 's:.*,\ \(.*\)\ byte.*:\1:')
498     if [[ ${size} -le 257000000 ]]
499     then
500     retval="0"
501     else
502     retval="1"
503     fi
504    
505     return "${retval}"
506    }
507    
508  setup_hdd_partitions_auto()  setup_hdd_partitions_auto()
509  {  {
510   ROOTHDD="${HDD}1"   ROOTHDD="${HDD}1"
511    
512     # run this only if FDISKPARTITIONBELOW256MB is not already 1
513     if [[ ${FDISKPARTIONBELOW256MB} != 1 ]]
514     then
515     if hdd_size_below_256mb ${HDD}
516     then
517     FDISKPARTIONBELOW256MB=1
518     else
519     FDISKPARTIONBELOW256MB=0
520     fi
521     fi
522    
523   ## delete disk   ## delete disk
524   dd if=/dev/zero of=${HDD} count=1 &> /dev/null || die   dd if=/dev/zero of=${HDD} count=1 &> /dev/null || die
525    
526   ## setup one bootable partition   if [[ ${FDISKPARTIONBELOW256MB} = 1 ]]
527   #1. n= new disk   then
528   #2. p= primary disk   ## setup one bootable partition
529   #3. 1= first partition   #1. n= new disk
530   #4. ''= default sector start   #2. p= primary disk
531   #5. ''= defaul sector end   #3. 1= first partition
532   #6. a= bootable flag   #4. 2= default sector start // small disk needs more space for grub2 mbr sector
533   #7. 1= boot flag for partition 1   #5. ''= defaul sector end
534   #8. w= write/quit   #6. a= bootable flag
535   fdisk ${HDD} &> /dev/null << EOF   #7. 1= boot flag for partition 1
536     #8. w= write/quit
537     fdisk ${HDD} &> /dev/null << EOF
538    n
539    p
540    1
541    2
542    
543    a
544    1
545    w
546    EOF
547     else
548     ## setup one bootable partition
549     #1. n= new disk
550     #2. p= primary disk
551     #3. 1= first partition
552     #4. ''= default sector start
553     #5. ''= defaul sector end
554     #6. a= bootable flag
555     #7. 1= boot flag for partition 1
556     #8. w= write/quit
557     fdisk ${HDD} &> /dev/null << EOF
558  n  n
559  p  p
560  1  1
# Line 475  a Line 564  a
564  1  1
565  w  w
566  EOF  EOF
567     fi
568  }  }
569    
570  setup_hdd_partitions_manuell()  setup_hdd_partitions_manuell()
# Line 531  install_system_image() Line 621  install_system_image()
621  install_bootsector_chroot()  install_bootsector_chroot()
622  {  {
623   local my_roothdd   local my_roothdd
624     local grubconf=${INSTALLPATH}/boot/grub/grub.conf
625     local grub2conf=/boot/grub/grub.cfg
626    
627   ### grubconf schreiben   # check for grub2
628   source ${INSTALLPATH}/boot/kernelversion   if [[ -f ${INSTALLPATH}/sbin/grub-mkconfig ]]
   
  #for alx only  
  if [ -e ${INSTALLPATH}/etc/alx_version ]  
629   then   then
630   OLD_ALXVER="${ALXVER}"   # needed by grub-mkconfig on the first run
631   source ${INSTALLPATH}/etc/alx_version   if [[ ! -f ${INSTALLPATH}/boot/grub/video.lst ]]
632   KRNVER="ALX-${ALXVER}"   then
633   ALXVER="${OLD_ALXVER}"   install -m0644 ${INSTALLPATH}/lib/grub/*/video.lst ${INSTALLPATH}/boot/grub/video.lst || die
634   fi   fi
635    
636   [[ -z ${KRNVER} ]] && KRNVER="AutoSta_LX"   # set kernelopts
637   [[ -z ${KRNINITRD} ]] && KRNINITRD="initrd"   if [[ -f ${INSTALLPATH}/etc/conf.d/grub ]]
638   [[ -z ${KRNIMG} ]] && KRNIMG="vmlinuz"   then
639     sed -i "s:^\(export GRUB_CMDLINE_LINUX_DEFAULT=\).*:\1\"${KERNELOPTS}\":" ${INSTALLPATH}/etc/conf.d/grub || die
640     else
641     echo "export GRUB_CMDLINE_LINUX_DEFAULT=\"${KERNELOPTS}\"" >  ${INSTALLPATH}/etc/conf.d/grub || die
642     fi
643     echo 'grub-mkdevicemap' > ${INSTALLPATH}/root/.installrc || die
644     echo "LC_ALL=C grub-mkconfig -o ${grub2conf}  &> /dev/null" >> ${INSTALLPATH}/root/.installrc || die
645     echo "grub-install --no-floppy ${HDD} &> /dev/null" >> ${INSTALLPATH}/root/.installrc || die
646     echo "exit 0" >> ${INSTALLPATH}/root/.installrc || die
647    
648   # uuid support   # grub-legacy
  if is_uuid_supported  
  then  
  my_roothdd="UUID=$(get_uuid ${ROOTHDD})"  
649   else   else
650   my_roothdd="${ROOTHDD}"   ### grubconf schreiben
651   fi   source ${INSTALLPATH}/boot/kernelversion
652    
653   local grubconf=${INSTALLPATH}/boot/grub/grub.conf   #for alx only
654   : > ${grubconf} || die   if [ -e ${INSTALLPATH}/etc/alx_version ]
655   echo "default 0" >> ${grubconf} || die   then
656   echo "timeout 3" >> ${grubconf} || die   OLD_ALXVER="${ALXVER}"
657   # using current root password   source ${INSTALLPATH}/etc/alx_version
658   echo "password --md5 $(cat ${INSTALLPATH}/etc/shadow | grep root | cut -d: -f2)"  >> ${grubconf} || die   KRNVER="ALX-${ALXVER}"
659     ALXVER="${OLD_ALXVER}"
660     fi
661    
662   echo  >> ${grubconf} || die   [[ -z ${KRNVER} ]] && KRNVER="AutoSta_LX"
663   echo "# normal boot" >> ${grubconf} || die   [[ -z ${KRNINITRD} ]] && KRNINITRD="initrd"
664   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  
665    
666   echo >> ${grubconf} || die   # uuid support
667   echo "# admin boot" >> ${grubconf} || die   if is_uuid_supported
668   echo "title ${KRNVER} - Re-run hardware-detection" >> ${grubconf} || die   then
669   echo "lock"  >> ${grubconf} || die   my_roothdd="UUID=$(get_uuid ${ROOTHDD})"
670   echo "root (hd0,0)" >> ${grubconf} || die   else
671   echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} hardware-auto-detection" >> ${grubconf} || die   my_roothdd="${ROOTHDD}"
672   if is_initrd_supported   fi
  then  
  echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die  
  fi  
673    
674   echo >> ${grubconf} || die   : > ${grubconf} || die
675   echo "title ${KRNVER} - Reset *all* local settings" >> ${grubconf} || die   echo "default 0" >> ${grubconf} || die
676   echo "lock"  >> ${grubconf} || die   echo "timeout 3" >> ${grubconf} || die
677   echo "root (hd0,0)" >> ${grubconf} || die   # using current root password
678   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
679   if is_initrd_supported  
680   then   echo  >> ${grubconf} || die
681   echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die   echo "# normal boot" >> ${grubconf} || die
682   fi   echo "title ${KRNVER}" >> ${grubconf} || die
683     echo "root (hd0,0)" >> ${grubconf} || die
684     echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS}" >> ${grubconf} || die
685     if is_initrd_supported
686     then
687     echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die
688     fi
689    
690     echo >> ${grubconf} || die
691     echo "# admin boot" >> ${grubconf} || die
692     echo "title ${KRNVER} - Re-run hardware-detection" >> ${grubconf} || die
693     echo "lock"  >> ${grubconf} || die
694     echo "root (hd0,0)" >> ${grubconf} || die
695     echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS} hardware-auto-detection" >> ${grubconf} || die
696     if is_initrd_supported
697     then
698     echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die
699     fi
700    
701   # bootsector schreiben chrooted schreiben (lfs/magellan)   echo >> ${grubconf} || die
702   cat > ${INSTALLPATH}/root/.bashrc << CHROOTEOF   echo "title ${KRNVER} - Reset *all* local settings" >> ${grubconf} || die
703     echo "lock"  >> ${grubconf} || die
704     echo "root (hd0,0)" >> ${grubconf} || die
705     echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS} alx-reset-settings" >> ${grubconf} || die
706     if is_initrd_supported
707     then
708     echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die
709     fi
710    
711     # bootsector schreiben chrooted schreiben (lfs/magellan)
712     cat > ${INSTALLPATH}/root/.installrc << CHROOTEOF
713  /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
714  root (hd0,0)  root (hd0,0)
715  setup (hd0)  setup (hd0)
# Line 603  quit Line 717  quit
717  EOF  EOF
718  exit 0  exit 0
719  CHROOTEOF  CHROOTEOF
720     fi
721    
722   ## enters chroot   ## enters chroot
723   mount -t proc proc ${INSTALLPATH}/proc   mount -t proc proc ${INSTALLPATH}/proc
724   mount -t sysfs sysfs ${INSTALLPATH}/sys   mount -t sysfs sysfs ${INSTALLPATH}/sys
725   mount -o bind /dev ${INSTALLPATH}/dev   mount -o bind /dev ${INSTALLPATH}/dev
726   chroot ${INSTALLPATH} /bin/bash --rcfile /root/.bashrc -i   chroot ${INSTALLPATH} /bin/bash --rcfile /root/.installrc -i
727   umount ${INSTALLPATH}/proc   umount ${INSTALLPATH}/proc
728   umount ${INSTALLPATH}/sys   umount ${INSTALLPATH}/sys
729   umount ${INSTALLPATH}/dev   umount ${INSTALLPATH}/dev
730   rm ${INSTALLPATH}/root/.bashrc   rm ${INSTALLPATH}/root/.installrc
731  }  }
732    
733  is_initrd_supported()  is_initrd_supported()
# Line 627  install_initrd_chroot() Line 742  install_initrd_chroot()
742   # only generate initrds if the cmd exists   # only generate initrds if the cmd exists
743   is_initrd_supported || return 0   is_initrd_supported || return 0
744    
745   cat > ${INSTALLPATH}/root/.bashrc << CHROOTEOF   DISKMODS="sd_mod"
746  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"
747     PATAMODS="ata_piix pata_amd pata_mpiix pata_oldpiix pata_sis pata_via"
748     SATAMODS="sata_via sata_sis sata_nv"
749     DRMMODS="i915 mga nouveau r128 radeon savage sis tdfx ttm via"
750     case ${SPECIALDEVICE} in
751     zotac_intel) FBMODS=""; DRMMODS="i915" ;;
752     zotac_nvidia) FBMODS=""; DRMMODS="nouveau" ;;
753     rangee) FBMODS="" ;; ## fallback to vesafb, viafb does not run on all CLE266 boards
754     # not working with kms enabled drivers -> segfaults
755     #maxdata) FBMODS="i810fb" ;; ## check for maxdata / i810/ i815 Chipsets and disable KMS and use i810fb frambuffer
756     maxdata) FBMODS="" ;;
757     *) FBMODS="uvesafb" ;;
758     esac
759    
760     # install an appropriate uvesafb.conf
761     install -d ${INSTALLPATH}/etc/modprobe.d || die
762     echo "options uvesafb mode_option=1024x768-32@60 scroll=ywrap" > ${INSTALLPATH}/etc/modprobe.d/uvesafb.conf || die
763    
764     # install an appropriate viafb.conf
765     echo "options viafb viafb_mode=1024x768 viafb_refresh=60" > ${INSTALLPATH}/etc/modprobe.d/viafb.conf || die
766    
767     # install an appropriate i810fb.conf
768     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
769    
770     cat > ${INSTALLPATH}/root/.installrc << CHROOTEOF
771    echo "MODULES=\"${FORMAT_FILESYSTEM} ${DISKMODS} ${OLDATAMODS} ${PATAMODS} ${SATAMODS} ${DRMMODS} ${FBMODS}\"" > /etc/conf.d/mkinitrd
772  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
773  exit 0  exit 0
774  CHROOTEOF  CHROOTEOF
# Line 637  CHROOTEOF Line 777  CHROOTEOF
777   mount -t proc proc ${INSTALLPATH}/proc   mount -t proc proc ${INSTALLPATH}/proc
778   mount -t sysfs sysfs ${INSTALLPATH}/sys   mount -t sysfs sysfs ${INSTALLPATH}/sys
779   mount -o bind /dev ${INSTALLPATH}/dev   mount -o bind /dev ${INSTALLPATH}/dev
780   chroot ${INSTALLPATH} /bin/bash --rcfile /root/.bashrc -i   chroot ${INSTALLPATH} /bin/bash --rcfile /root/.installrc -i
781   umount ${INSTALLPATH}/proc   umount ${INSTALLPATH}/proc
782   umount ${INSTALLPATH}/sys   umount ${INSTALLPATH}/sys
783   umount ${INSTALLPATH}/dev   umount ${INSTALLPATH}/dev
784   rm ${INSTALLPATH}/root/.bashrc   rm ${INSTALLPATH}/root/.installrc
785  }  }
786    
787  is_uuid_supported()  is_uuid_supported()
# Line 695  install_system_settings() Line 835  install_system_settings()
835    
836   # install network config skeleton   # install network config skeleton
837   install -m0644 ${INSTALLPATH}/etc/alxconfig-ng/skel/net/net.eth0 ${INSTALLPATH}/etc/conf.d/ || die   install -m0644 ${INSTALLPATH}/etc/alxconfig-ng/skel/net/net.eth0 ${INSTALLPATH}/etc/conf.d/ || die
838    
839     # intel framebufer quirk
840     if [[ -e /proc/fb ]]
841     then
842     if [[ ! -z $(grep 'inteldrmfb' /proc/fb) ]]
843     then
844     fbdev=$(grep 'inteldrmfb' /proc/fb | sed 's:\([0-9]\).*:\1:')
845     if [[ ${fbdev} != 0 ]]
846     then
847     sed -i "s:^\(SPLASH_DEV=\).*:\1\"/dev/fb${fbdev}\":" ${INSTALLPATH}/etc/splash/splash.conf || die
848     fi
849     fi
850     fi
851  }  }
852    
853  install_system_settings_flash()  install_system_settings_flash()
# Line 743  run_install_normal() Line 896  run_install_normal()
896   install_mount_rootfs   install_mount_rootfs
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   install_system_settings
902   install_initrd_chroot   install_initrd_chroot
903    
904     dialog_install_bootsector
905     install_bootsector_chroot
906    
907   install_umount_rootfs   install_umount_rootfs
908   dialog_install_successful   dialog_install_successful
909  }  }
# Line 764  run_install_flash() Line 918  run_install_flash()
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  }  }
# Line 785  run_install_auto() Line 940  run_install_auto()
940   install_mount_rootfs_flash   install_mount_rootfs_flash
941   (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
942    
  dialog_install_bootsector  
  install_bootsector_chroot  
   
943   dialog_install_settings   dialog_install_settings
944   sleep 1   sleep 1
945   install_system_settings_flash   install_system_settings_flash
946   install_initrd_chroot   install_initrd_chroot
947    
948     dialog_install_bootsector
949     install_bootsector_chroot
950    
951   install_umount_rootfs_flash   install_umount_rootfs_flash
952   dialog_install_successful   dialog_install_successful
953  }  }

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