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 2554 by niro, Mon Jul 4 18:06:45 2011 UTC revision 5003 by niro, Wed Aug 7 10:42:07 2013 UTC
# 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=""
46    FORMFACTOR="desktop"
47    
48  # target filesystem  # target filesystem
49  FORMAT_FILESYSTEM="ext4"  FORMAT_FILESYSTEM="ext4"
# Line 199  dialog_hardware_detection() Line 207  dialog_hardware_detection()
207   # other devices   # other devices
208   run_hardware_detection   run_hardware_detection
209   case "${SPECIALDEVICE}" in   case "${SPECIALDEVICE}" in
210   zotac) echo " \n\n\n \\Z2Zotac Device erkannt!\\Zn \\" >> ${hwtmp} ;;   zotac*) echo " \n\n\n \\Z2Zotac Device erkannt!\\Zn \\" >> ${hwtmp} ;;
211     rangee) echo " \n\n\n \\Z2Rangee Device erkannt!\\Zn \\" >> ${hwtmp} ;;
212     maxdata) echo " \n\n\n \\Z2Maxdata Device erkannt!\\Zn \\" >> ${hwtmp} ;;
213   *) echo " \n\n\n \\ZnStandard Device erkannt!\\Zn \\" >> ${hwtmp} ;;   *) echo " \n\n\n \\ZnStandard Device erkannt!\\Zn \\" >> ${hwtmp} ;;
214   esac   esac
215     if [[ ${FORMFACTOR} = laptop ]]
216     then
217     echo " \n\n\n \\ZnFormfactor Laptop erkannt, Powersave Modus 'ondemand' wird aktiviert!\\Zn \\" >> ${hwtmp} ;;
218     fi
219    
220   echo " \" 13 70" >> ${hwtmp}   echo " \" 13 70" >> ${hwtmp}
221   chmod a+x ${hwtmp}   chmod a+x ${hwtmp}
# Line 431  dialog_main() Line 445  dialog_main()
445  #################################################  #################################################
446  run_hardware_detection()  run_hardware_detection()
447  {  {
448     local hwinfo
449    
450     hwinfo="$(hwinfo --bios --storage --pci --gfxcard --sys)"
451    
452   # check for special devices/clients:   # check for special devices/clients:
453   # 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
454   local removable=0   local removable=0
455   if [[ ! -z $(hwinfo --bios --storage | grep -i zotac) ]]   if [[ ! -z $(echo "${hwinfo}" | grep -i zotac) ]]
456   then   then
457   for i in /sys/block/[hs]d*/removable   for i in /sys/block/[hs]d*/removable
458   do   do
# Line 444  run_hardware_detection() Line 462  run_hardware_detection()
462   fi   fi
463   done   done
464    
465   export KERNELOPTS="${KERNELOPTS} rootdelay=8"   # only add this for grub legacy, grub2 detect these settings on its own
466   export SPECIALDEVICE="zotac"   export GRUBLEGACYOPTS="rootdelay=8"
467     # there are to zotac types in the wild, nvidia based gfx and intel
468     if [[ ! -z $(echo "${hwinfo}" | grep -i nouveau) ]]
469     then
470     export SPECIALDEVICE="zotac_nvidia"
471     else
472     export SPECIALDEVICE="zotac_intel"
473     fi
474     fi
475    
476     # check for special devices/clients:
477     # if a rangee and disk ist smaller then 256mb move partion one block further ahead
478     if [[ ! -z $(echo "${hwinfo}" | grep -i CLE266) ]]
479     then
480     # for a rangee always define partion startblock +1
481     export FDISKPARTIONBELOW256MB="1"
482     export SPECIALDEVICE="rangee"
483     export GRUBLEGACYOPTS=""
484     fi
485    
486     # check for special devices/clients:
487     # check for maxdata / i810/ i815 Chipsets and disable KMS and use i810fb frambuffer
488     if [[ ! -z $(echo "${hwinfo}" | grep -i i810) ]] || [[ ! -z $(echo "${hwinfo}" | grep -i i815) ]]
489     then
490     export SPECIALDEVICE="maxdata"
491     export GRUBLEGACYOPTS=""
492     fi
493    
494     # check for special devices/clients:
495     # check for laptops and activate cpufreq scaling
496     if [[ $(echo "${hwinfo}" | grep 'Formfactor:' | sed 's:.*Formfactor\:\ \"\(.*\)\":\1:') = laptop ]]
497     then
498     export FORMFACTOR="laptop"
499     export KERNELOPTS="${KERNELOPTS} cpufreq.governor=ondemand"
500     fi
501    }
502    
503    hdd_size_below_256mb()
504    {
505     local hdd="$1"
506     local size
507     local retval
508     [[ -z ${hdd} ]] && die "Error: get_hdd_size() no \$hdd given!"
509    
510     size=$(fdisk -l ${hdd} | grep "Disk.*${hdd}" | sed 's:.*,\ \(.*\)\ byte.*:\1:')
511     if [[ ${size} -le 257000000 ]]
512     then
513     retval="0"
514     else
515     retval="1"
516   fi   fi
517    
518     return "${retval}"
519  }  }
520    
521  setup_hdd_partitions_auto()  setup_hdd_partitions_auto()
522  {  {
523   ROOTHDD="${HDD}1"   ROOTHDD="${HDD}1"
524    
525     # run this only if FDISKPARTITIONBELOW256MB is not already 1
526     if [[ ${FDISKPARTIONBELOW256MB} != 1 ]]
527     then
528     if hdd_size_below_256mb ${HDD}
529     then
530     FDISKPARTIONBELOW256MB=1
531     else
532     FDISKPARTIONBELOW256MB=0
533     fi
534     fi
535    
536   ## delete disk   ## delete disk
537   dd if=/dev/zero of=${HDD} count=1 &> /dev/null || die   dd if=/dev/zero of=${HDD} count=1 &> /dev/null || die
538    
539   ## setup one bootable partition   if [[ ${FDISKPARTIONBELOW256MB} = 1 ]]
540   #1. n= new disk   then
541   #2. p= primary disk   ## setup one bootable partition
542   #3. 1= first partition   #1. n= new disk
543   #4. ''= default sector start   #2. p= primary disk
544   #5. ''= defaul sector end   #3. 1= first partition
545   #6. a= bootable flag   #4. 2= default sector start // small disk needs more space for grub2 mbr sector
546   #7. 1= boot flag for partition 1   #5. ''= defaul sector end
547   #8. w= write/quit   #6. a= bootable flag
548   fdisk ${HDD} &> /dev/null << EOF   #7. 1= boot flag for partition 1
549     #8. w= write/quit
550     fdisk ${HDD} &> /dev/null << EOF
551    n
552    p
553    1
554    2
555    
556    a
557    1
558    w
559    EOF
560     else
561     ## setup one bootable partition
562     #1. n= new disk
563     #2. p= primary disk
564     #3. 1= first partition
565     #4. ''= default sector start
566     #5. ''= defaul sector end
567     #6. a= bootable flag
568     #7. 1= boot flag for partition 1
569     #8. w= write/quit
570     fdisk ${HDD} &> /dev/null << EOF
571  n  n
572  p  p
573  1  1
# Line 475  a Line 577  a
577  1  1
578  w  w
579  EOF  EOF
580     fi
581  }  }
582    
583  setup_hdd_partitions_manuell()  setup_hdd_partitions_manuell()
# Line 532  install_bootsector_chroot() Line 635  install_bootsector_chroot()
635  {  {
636   local my_roothdd   local my_roothdd
637   local grubconf=${INSTALLPATH}/boot/grub/grub.conf   local grubconf=${INSTALLPATH}/boot/grub/grub.conf
638   local grub2conf=${INSTALLPATH}/boot/grub/grub.cfg   local grub2conf=/boot/grub/grub.cfg
639    
640   # check for grub2   # check for grub2
641   if [[ -f ${INSTALLPATH}/sbin/grub-mkconfig ]]   if [[ -f ${INSTALLPATH}/sbin/grub-mkconfig ]]
# Line 540  install_bootsector_chroot() Line 643  install_bootsector_chroot()
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 ${INSTALLPATH}/boot/grub/video.lst ]]
645   then   then
646   install -m0644 ${INSTALLPATH}/lib/grub/*/video.lst /boot/grub/video.lst   install -m0644 ${INSTALLPATH}/lib/grub/*/video.lst ${INSTALLPATH}/boot/grub/video.lst || die
647     fi
648    
649     # set kernelopts
650     if [[ -f ${INSTALLPATH}/etc/conf.d/grub ]]
651     then
652     sed -i "s:^\(export GRUB_CMDLINE_LINUX_DEFAULT=\).*:\1\"${KERNELOPTS}\":" ${INSTALLPATH}/etc/conf.d/grub || die
653     else
654     echo "export GRUB_CMDLINE_LINUX_DEFAULT=\"${KERNELOPTS}\"" >  ${INSTALLPATH}/etc/conf.d/grub || die
655   fi   fi
656   echo 'grub-mkdevicemap' > ${INSTALLPATH}/root/.bashrc   echo 'grub-mkdevicemap' > ${INSTALLPATH}/root/.installrc || die
657   echo "LC_ALL=C grub-mkconfig -o ${grub2conf}" >> ${INSTALLPATH}/root/.bashrc   echo "LC_ALL=C grub-mkconfig -o ${grub2conf}  &> /dev/null" >> ${INSTALLPATH}/root/.installrc || die
658   echo "grub-install --no-floppy ${HDD}" >> ${INSTALLPATH}/root/.bashrc   echo "grub-install --no-floppy ${HDD} &> /dev/null" >> ${INSTALLPATH}/root/.installrc || die
659     echo "exit 0" >> ${INSTALLPATH}/root/.installrc || die
660    
661   # grub-legacy   # grub-legacy
662   else   else
# Line 582  install_bootsector_chroot() Line 694  install_bootsector_chroot()
694   echo "# normal boot" >> ${grubconf} || die   echo "# normal boot" >> ${grubconf} || die
695   echo "title ${KRNVER}" >> ${grubconf} || die   echo "title ${KRNVER}" >> ${grubconf} || die
696   echo "root (hd0,0)" >> ${grubconf} || die   echo "root (hd0,0)" >> ${grubconf} || die
697   echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS}" >> ${grubconf} || die   echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS}" >> ${grubconf} || die
698   if is_initrd_supported   if is_initrd_supported
699   then   then
700   echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die   echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die
# Line 593  install_bootsector_chroot() Line 705  install_bootsector_chroot()
705   echo "title ${KRNVER} - Re-run hardware-detection" >> ${grubconf} || die   echo "title ${KRNVER} - Re-run hardware-detection" >> ${grubconf} || die
706   echo "lock"  >> ${grubconf} || die   echo "lock"  >> ${grubconf} || die
707   echo "root (hd0,0)" >> ${grubconf} || die   echo "root (hd0,0)" >> ${grubconf} || die
708   echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} hardware-auto-detection" >> ${grubconf} || die   echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS} hardware-auto-detection" >> ${grubconf} || die
709   if is_initrd_supported   if is_initrd_supported
710   then   then
711   echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die   echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die
# Line 603  install_bootsector_chroot() Line 715  install_bootsector_chroot()
715   echo "title ${KRNVER} - Reset *all* local settings" >> ${grubconf} || die   echo "title ${KRNVER} - Reset *all* local settings" >> ${grubconf} || die
716   echo "lock"  >> ${grubconf} || die   echo "lock"  >> ${grubconf} || die
717   echo "root (hd0,0)" >> ${grubconf} || die   echo "root (hd0,0)" >> ${grubconf} || die
718   echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} alx-reset-settings" >> ${grubconf} || die   echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS} alx-reset-settings" >> ${grubconf} || die
719   if is_initrd_supported   if is_initrd_supported
720   then   then
721   echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die   echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die
722   fi   fi
723    
724   # bootsector schreiben chrooted schreiben (lfs/magellan)   # bootsector schreiben chrooted schreiben (lfs/magellan)
725   cat > ${INSTALLPATH}/root/.bashrc << CHROOTEOF   cat > ${INSTALLPATH}/root/.installrc << CHROOTEOF
726  /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
727  root (hd0,0)  root (hd0,0)
728  setup (hd0)  setup (hd0)
# Line 624  CHROOTEOF Line 736  CHROOTEOF
736   mount -t proc proc ${INSTALLPATH}/proc   mount -t proc proc ${INSTALLPATH}/proc
737   mount -t sysfs sysfs ${INSTALLPATH}/sys   mount -t sysfs sysfs ${INSTALLPATH}/sys
738   mount -o bind /dev ${INSTALLPATH}/dev   mount -o bind /dev ${INSTALLPATH}/dev
739   chroot ${INSTALLPATH} /bin/bash --rcfile /root/.bashrc -i   chroot ${INSTALLPATH} /bin/bash --rcfile /root/.installrc -i
740   umount ${INSTALLPATH}/proc   umount ${INSTALLPATH}/proc
741   umount ${INSTALLPATH}/sys   umount ${INSTALLPATH}/sys
742   umount ${INSTALLPATH}/dev   umount ${INSTALLPATH}/dev
743   rm ${INSTALLPATH}/root/.bashrc   rm ${INSTALLPATH}/root/.installrc
744  }  }
745    
746  is_initrd_supported()  is_initrd_supported()
# Line 643  install_initrd_chroot() Line 755  install_initrd_chroot()
755   # only generate initrds if the cmd exists   # only generate initrds if the cmd exists
756   is_initrd_supported || return 0   is_initrd_supported || return 0
757    
758   cat > ${INSTALLPATH}/root/.bashrc << CHROOTEOF   DISKMODS="sd_mod"
759  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"
760     PATAMODS="ata_piix pata_amd pata_mpiix pata_oldpiix pata_sis pata_via"
761     SATAMODS="sata_via sata_sis sata_nv"
762     DRMMODS="i915 mga nouveau r128 radeon savage sis tdfx ttm via"
763     OTHERMODS=""
764     case ${SPECIALDEVICE} in
765     zotac_intel) FBMODS=""; DRMMODS="i915" ;;
766     zotac_nvidia) FBMODS=""; DRMMODS="nouveau" ;;
767     rangee) FBMODS="" ;; ## fallback to vesafb, viafb does not run on all CLE266 boards
768     # not working with kms enabled drivers -> segfaults
769     #maxdata) FBMODS="i810fb" ;; ## check for maxdata / i810/ i815 Chipsets and disable KMS and use i810fb frambuffer
770     maxdata) FBMODS="" ;;
771     *) FBMODS="uvesafb" ;;
772     esac
773    
774     if [[ ${FORMFACTOR} = laptop ]]
775     then
776     OTHERMODS="acpi-cpufreq cpufreq_ondemand cpufreq_conservative cpufreq_powersave"
777     fi
778    
779     # install an appropriate uvesafb.conf
780     install -d ${INSTALLPATH}/etc/modprobe.d || die
781     echo "options uvesafb mode_option=1024x768-32@60 scroll=ywrap" > ${INSTALLPATH}/etc/modprobe.d/uvesafb.conf || die
782    
783     # install an appropriate viafb.conf
784     echo "options viafb viafb_mode=1024x768 viafb_refresh=60" > ${INSTALLPATH}/etc/modprobe.d/viafb.conf || die
785    
786     # install an appropriate i810fb.conf
787     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
788    
789     cat > ${INSTALLPATH}/root/.installrc << CHROOTEOF
790    echo "MODULES=\"${FORMAT_FILESYSTEM} ${DISKMODS} ${OLDATAMODS} ${PATAMODS} ${SATAMODS} ${DRMMODS} ${FBMODS} ${OTHERMODS}\"" > /etc/conf.d/mkinitrd
791  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
792  exit 0  exit 0
793  CHROOTEOF  CHROOTEOF
# Line 653  CHROOTEOF Line 796  CHROOTEOF
796   mount -t proc proc ${INSTALLPATH}/proc   mount -t proc proc ${INSTALLPATH}/proc
797   mount -t sysfs sysfs ${INSTALLPATH}/sys   mount -t sysfs sysfs ${INSTALLPATH}/sys
798   mount -o bind /dev ${INSTALLPATH}/dev   mount -o bind /dev ${INSTALLPATH}/dev
799   chroot ${INSTALLPATH} /bin/bash --rcfile /root/.bashrc -i   chroot ${INSTALLPATH} /bin/bash --rcfile /root/.installrc -i
800   umount ${INSTALLPATH}/proc   umount ${INSTALLPATH}/proc
801   umount ${INSTALLPATH}/sys   umount ${INSTALLPATH}/sys
802   umount ${INSTALLPATH}/dev   umount ${INSTALLPATH}/dev
803   rm ${INSTALLPATH}/root/.bashrc   rm ${INSTALLPATH}/root/.installrc
804  }  }
805    
806  is_uuid_supported()  is_uuid_supported()
# Line 711  install_system_settings() Line 854  install_system_settings()
854    
855   # install network config skeleton   # install network config skeleton
856   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
857    
858     # intel framebufer quirk
859     if [[ -e /proc/fb ]]
860     then
861     if [[ ! -z $(grep 'inteldrmfb' /proc/fb) ]]
862     then
863     fbdev=$(grep 'inteldrmfb' /proc/fb | sed 's:\([0-9]\).*:\1:')
864     if [[ ${fbdev} != 0 ]]
865     then
866     sed -i "s:^\(SPLASH_DEV=\).*:\1\"/dev/fb${fbdev}\":" ${INSTALLPATH}/etc/splash/splash.conf || die
867     fi
868     fi
869     fi
870  }  }
871    
872  install_system_settings_flash()  install_system_settings_flash()

Legend:
Removed from v.2554  
changed lines
  Added in v.5003