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 6770 by niro, Tue Jul 21 12:25:48 2015 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    GRUB2GFXPAYLOAD="1024x768x16,1024x768"
41    
42    # fdisk options
43    FDISKPARTIONBELOW256MB=0
44    
45  # default specialdevices  # default specialdevices
46  SPECIALDEVICE=""  SPECIALDEVICE=""
47    FORMFACTOR="desktop"
48    
49  # target filesystem  # target filesystem
50  FORMAT_FILESYSTEM="ext4"  FORMAT_FILESYSTEM="ext4"
# Line 136  dialog_setup_system_menu() Line 145  dialog_setup_system_menu()
145   then   then
146   case "${i}" in   case "${i}" in
147   "1") run_install_auto ;;   "1") run_install_auto ;;
148           "2") run_install_normal ;;   "2") run_install_normal ;;
149   "3") run_install_flash ;;   "3") run_install_flash ;;
150   "") dialog_setup_system_menu;;   "") dialog_setup_system_menu;;
151   esac   esac
# Line 199  dialog_hardware_detection() Line 208  dialog_hardware_detection()
208   # other devices   # other devices
209   run_hardware_detection   run_hardware_detection
210   case "${SPECIALDEVICE}" in   case "${SPECIALDEVICE}" in
211   zotac) echo " \n\n\n \\Z2Zotac Device erkannt!\\Zn \\" >> ${hwtmp} ;;   zotac*) echo " \n\n\n \\Z2Zotac Device erkannt.\\Zn \\" >> ${hwtmp} ;;
212   *) echo " \n\n\n \\ZnStandard Device erkannt!\\Zn \\" >> ${hwtmp} ;;   rangee) echo " \n\n\n \\Z2Rangee Device erkannt.\\Zn \\" >> ${hwtmp} ;;
213     maxdata) echo " \n\n\n \\Z2Maxdata Device erkannt.\\Zn \\" >> ${hwtmp} ;;
214     i845) echo " \n\n\n \\Z2Intel i845 Device erkannt.\\Zn \\" >> ${hwtmp} ;;
215     *) echo " \n\n\n \\ZnStandard Device erkannt.\\Zn \\" >> ${hwtmp} ;;
216   esac   esac
217     if [[ ${FORMFACTOR} = laptop ]]
218     then
219     echo " \n \\ZnFormfactor Laptop, Powersave Modus 'ondemand' wird aktiviert.\\Zn \\" >> ${hwtmp}
220     fi
221    
222   echo " \" 13 70" >> ${hwtmp}   echo " \" 14 70" >> ${hwtmp}
223   chmod a+x ${hwtmp}   chmod a+x ${hwtmp}
224   ${hwtmp}   ${hwtmp}
225    
# Line 417  dialog_main() Line 433  dialog_main()
433   if [[ ${RES} -eq 0 ]]   if [[ ${RES} -eq 0 ]]
434   then   then
435   case ${METHOD} in   case ${METHOD} in
436           "1") dialog_setup_system_menu ;;   "1") dialog_setup_system_menu ;;
437   "2") dialog_hardware_detection ;;   "2") dialog_hardware_detection ;;
438   "3") install_do_reboot ;;   "3") install_do_reboot ;;
439   "4") /bin/bash --login -i ;;   "4") /bin/bash --login -i ;;
# Line 431  dialog_main() Line 447  dialog_main()
447  #################################################  #################################################
448  run_hardware_detection()  run_hardware_detection()
449  {  {
450     local hwinfo
451    
452     hwinfo="$(hwinfo --bios --storage --pci --gfxcard --sys)"
453    
454   # check for special devices/clients:   # check for special devices/clients:
455   # 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
456   local removable=0   local removable=0
457   if [[ ! -z $(hwinfo --bios --storage | grep -i zotac) ]]   if [[ ! -z $(echo "${hwinfo}" | grep -i zotac) ]]
458   then   then
459   for i in /sys/block/[hs]d*/removable   for i in /sys/block/[hs]d*/removable
460   do   do
# Line 444  run_hardware_detection() Line 464  run_hardware_detection()
464   fi   fi
465   done   done
466    
467   export KERNELOPTS="${KERNELOPTS} rootdelay=8"   # only add this for grub legacy, grub2 detect these settings on its own
468   export SPECIALDEVICE="zotac"   export GRUBLEGACYOPTS="rootdelay=8"
469     # there are two zotac types in the wild, nvidia based gfx and intel
470     if [[ ! -z $(echo "${hwinfo}" | grep -i nouveau) ]]
471     then
472     export SPECIALDEVICE="zotac_nvidia"
473     else
474     export SPECIALDEVICE="zotac_intel"
475     fi
476   fi   fi
477    
478     # check for special devices/clients:
479     # if a rangee and disk ist smaller then 256mb move partion one block further ahead
480     if [[ ! -z $(echo "${hwinfo}" | grep -i CLE266) ]]
481     then
482     # for a rangee always define partion startblock +1
483     export FDISKPARTIONBELOW256MB="1"
484     export SPECIALDEVICE="rangee"
485     export GRUBLEGACYOPTS=""
486     fi
487    
488     # check for special devices/clients:
489     # check for maxdata / i810/ i815 Chipsets and disable KMS and use i810fb frambuffer
490     if [[ ! -z $(echo "${hwinfo}" | grep -i i810) ]] || [[ ! -z $(echo "${hwinfo}" | grep -i i815) ]]
491     then
492     export SPECIALDEVICE="maxdata"
493     export GRUBLEGACYOPTS=""
494     fi
495    
496     # check for i845 Chipsets and disable KMS and use 915 drm driver
497     if [[ ! -z $(echo "${hwinfo}" | grep -i i845) ]]
498     then
499     export SPECIALDEVICE="i845"
500     # unset default video=1024x768 opt or the drm driver breaks
501     export KERNELOPTS="quiet"
502     export GRUBLEGACYOPTS=""
503     # enable full kms support
504     export GRUB2GFXPAYLOAD="keep"
505     fi
506    
507     # check for special devices/clients:
508     # check for laptops and activate cpufreq scaling
509     if [[ $(echo "${hwinfo}" | grep 'Formfactor:' | sed 's:.*Formfactor\:\ \"\(.*\)\":\1:') = laptop ]]
510     then
511     export FORMFACTOR="laptop"
512     export KERNELOPTS="${KERNELOPTS} cpufreq.governor=ondemand"
513     fi
514    }
515    
516    hdd_size_below_256mb()
517    {
518     local hdd="$1"
519     local size
520     local retval
521     [[ -z ${hdd} ]] && die "Error: get_hdd_size() no \$hdd given!"
522    
523     size=$(fdisk -l ${hdd} | grep "Disk.*${hdd}" | sed 's:.*,\ \(.*\)\ byte.*:\1:')
524     if [[ ${size} -le 257000000 ]]
525     then
526     retval="0"
527     else
528     retval="1"
529     fi
530    
531     return "${retval}"
532  }  }
533    
534  setup_hdd_partitions_auto()  setup_hdd_partitions_auto()
535  {  {
536   ROOTHDD="${HDD}1"   ROOTHDD="${HDD}1"
537    
538     # run this only if FDISKPARTITIONBELOW256MB is not already 1
539     if [[ ${FDISKPARTIONBELOW256MB} != 1 ]]
540     then
541     if hdd_size_below_256mb ${HDD}
542     then
543     FDISKPARTIONBELOW256MB=1
544     else
545     FDISKPARTIONBELOW256MB=0
546     fi
547     fi
548    
549   ## delete disk   ## delete disk
550   dd if=/dev/zero of=${HDD} count=1 &> /dev/null || die   dd if=/dev/zero of=${HDD} count=1 &> /dev/null || die
551    
552   ## setup one bootable partition   if [[ ${FDISKPARTIONBELOW256MB} = 1 ]]
553   #1. n= new disk   then
554   #2. p= primary disk   ## setup one bootable partition
555   #3. 1= first partition   #1. n= new disk
556   #4. ''= default sector start   #2. p= primary disk
557   #5. ''= defaul sector end   #3. 1= first partition
558   #6. a= bootable flag   #4. 2= default sector start // small disk needs more space for grub2 mbr sector
559   #7. 1= boot flag for partition 1   #5. ''= defaul sector end
560   #8. w= write/quit   #6. a= bootable flag
561   fdisk ${HDD} &> /dev/null << EOF   #7. 1= boot flag for partition 1
562     #8. w= write/quit
563     fdisk ${HDD} &> /dev/null << EOF
564    n
565    p
566    1
567    2
568    
569    a
570    1
571    w
572    EOF
573     else
574     ## setup one bootable partition
575     #1. n= new disk
576     #2. p= primary disk
577     #3. 1= first partition
578     #4. ''= default sector start
579     #5. ''= defaul sector end
580     #6. a= bootable flag
581     #7. 1= boot flag for partition 1
582     #8. w= write/quit
583     fdisk ${HDD} &> /dev/null << EOF
584  n  n
585  p  p
586  1  1
# Line 475  a Line 590  a
590  1  1
591  w  w
592  EOF  EOF
593     fi
594  }  }
595    
596  setup_hdd_partitions_manuell()  setup_hdd_partitions_manuell()
# Line 532  install_bootsector_chroot() Line 648  install_bootsector_chroot()
648  {  {
649   local my_roothdd   local my_roothdd
650   local grubconf=${INSTALLPATH}/boot/grub/grub.conf   local grubconf=${INSTALLPATH}/boot/grub/grub.conf
651   local grub2conf=${INSTALLPATH}/boot/grub/grub.cfg   local grub2conf=/boot/grub/grub.cfg
652    
653   # check for grub2   # check for grub2
654   if [[ -f ${INSTALLPATH}/sbin/grub-mkconfig ]]   if [[ -f ${INSTALLPATH}/sbin/grub-mkconfig ]]
# Line 540  install_bootsector_chroot() Line 656  install_bootsector_chroot()
656   # needed by grub-mkconfig on the first run   # needed by grub-mkconfig on the first run
657   if [[ ! -f ${INSTALLPATH}/boot/grub/video.lst ]]   if [[ ! -f ${INSTALLPATH}/boot/grub/video.lst ]]
658   then   then
659   install -m0644 ${INSTALLPATH}/lib/grub/*/video.lst /boot/grub/video.lst   install -m0644 ${INSTALLPATH}/lib/grub/*/video.lst ${INSTALLPATH}/boot/grub/video.lst || die
660   fi   fi
661   echo 'grub-mkdevicemap' > ${INSTALLPATH}/root/.bashrc  
662   echo "LC_ALL=C grub-mkconfig -o ${grub2conf}" >> ${INSTALLPATH}/root/.bashrc   # set kernelopts
663   echo "grub-install --no-floppy ${HDD}" >> ${INSTALLPATH}/root/.bashrc   if [[ -f ${INSTALLPATH}/etc/conf.d/grub ]]
664     then
665     sed -i "s:^\(export GRUB_CMDLINE_LINUX_DEFAULT=\).*:\1\"${KERNELOPTS}\":" ${INSTALLPATH}/etc/conf.d/grub || die
666     sed -i "s:^\(export GRUB_GFXPAYLOAD_LINUX=\).*:\1\"${GRUB2GFXPAYLOAD}\":" ${INSTALLPATH}/etc/conf.d/grub || die
667     else
668     echo "export GRUB_CMDLINE_LINUX_DEFAULT=\"${KERNELOPTS}\"" >  ${INSTALLPATH}/etc/conf.d/grub || die
669     echo "export GRUB_GFXPAYLOAD_LINUX=\"${GRUB2GFXPAYLOAD}\"" >>  ${INSTALLPATH}/etc/conf.d/grub || die
670     fi
671     echo 'grub-mkdevicemap' > ${INSTALLPATH}/root/.installrc || die
672     echo "LC_ALL=C grub-mkconfig -o ${grub2conf}  &> /dev/null" >> ${INSTALLPATH}/root/.installrc || die
673     echo "grub-install --no-floppy ${HDD} &> /dev/null" >> ${INSTALLPATH}/root/.installrc || die
674     echo "exit 0" >> ${INSTALLPATH}/root/.installrc || die
675    
676   # grub-legacy   # grub-legacy
677   else   else
# Line 582  install_bootsector_chroot() Line 709  install_bootsector_chroot()
709   echo "# normal boot" >> ${grubconf} || die   echo "# normal boot" >> ${grubconf} || die
710   echo "title ${KRNVER}" >> ${grubconf} || die   echo "title ${KRNVER}" >> ${grubconf} || die
711   echo "root (hd0,0)" >> ${grubconf} || die   echo "root (hd0,0)" >> ${grubconf} || die
712   echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS}" >> ${grubconf} || die   echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS}" >> ${grubconf} || die
713   if is_initrd_supported   if is_initrd_supported
714   then   then
715   echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die   echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die
# Line 593  install_bootsector_chroot() Line 720  install_bootsector_chroot()
720   echo "title ${KRNVER} - Re-run hardware-detection" >> ${grubconf} || die   echo "title ${KRNVER} - Re-run hardware-detection" >> ${grubconf} || die
721   echo "lock"  >> ${grubconf} || die   echo "lock"  >> ${grubconf} || die
722   echo "root (hd0,0)" >> ${grubconf} || die   echo "root (hd0,0)" >> ${grubconf} || die
723   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
724   if is_initrd_supported   if is_initrd_supported
725   then   then
726   echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die   echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die
# Line 603  install_bootsector_chroot() Line 730  install_bootsector_chroot()
730   echo "title ${KRNVER} - Reset *all* local settings" >> ${grubconf} || die   echo "title ${KRNVER} - Reset *all* local settings" >> ${grubconf} || die
731   echo "lock"  >> ${grubconf} || die   echo "lock"  >> ${grubconf} || die
732   echo "root (hd0,0)" >> ${grubconf} || die   echo "root (hd0,0)" >> ${grubconf} || die
733   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
734   if is_initrd_supported   if is_initrd_supported
735   then   then
736   echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die   echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die
737   fi   fi
738    
739   # bootsector schreiben chrooted schreiben (lfs/magellan)   # bootsector schreiben chrooted schreiben (lfs/magellan)
740   cat > ${INSTALLPATH}/root/.bashrc << CHROOTEOF   cat > ${INSTALLPATH}/root/.installrc << CHROOTEOF
741  /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
742  root (hd0,0)  root (hd0,0)
743  setup (hd0)  setup (hd0)
# Line 624  CHROOTEOF Line 751  CHROOTEOF
751   mount -t proc proc ${INSTALLPATH}/proc   mount -t proc proc ${INSTALLPATH}/proc
752   mount -t sysfs sysfs ${INSTALLPATH}/sys   mount -t sysfs sysfs ${INSTALLPATH}/sys
753   mount -o bind /dev ${INSTALLPATH}/dev   mount -o bind /dev ${INSTALLPATH}/dev
754   chroot ${INSTALLPATH} /bin/bash --rcfile /root/.bashrc -i   chroot ${INSTALLPATH} /bin/bash --rcfile /root/.installrc -i
755   umount ${INSTALLPATH}/proc   umount ${INSTALLPATH}/proc
756   umount ${INSTALLPATH}/sys   umount ${INSTALLPATH}/sys
757   umount ${INSTALLPATH}/dev   umount ${INSTALLPATH}/dev
758   rm ${INSTALLPATH}/root/.bashrc   rm ${INSTALLPATH}/root/.installrc
759  }  }
760    
761  is_initrd_supported()  is_initrd_supported()
# Line 643  install_initrd_chroot() Line 770  install_initrd_chroot()
770   # only generate initrds if the cmd exists   # only generate initrds if the cmd exists
771   is_initrd_supported || return 0   is_initrd_supported || return 0
772    
773   cat > ${INSTALLPATH}/root/.bashrc << CHROOTEOF   DISKMODS="sd_mod"
774  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"
775     PATAMODS="ata_piix pata_amd pata_mpiix pata_oldpiix pata_sis pata_via"
776     SATAMODS="sata_via sata_sis sata_nv"
777     DRMMODS="i915 mga nouveau r128 radeon savage sis tdfx ttm via"
778     OTHERMODS=""
779     case ${SPECIALDEVICE} in
780     zotac_intel|i845) FBMODS=""; DRMMODS="i915" ;;
781     zotac_nvidia) FBMODS=""; DRMMODS="nouveau" ;;
782     rangee) FBMODS="" ;; ## fallback to vesafb, viafb does not run on all CLE266 boards
783     # not working with kms enabled drivers -> segfaults
784     #maxdata) FBMODS="i810fb" ;; ## check for maxdata / i810/ i815 Chipsets and disable KMS and use i810fb frambuffer
785     maxdata) FBMODS="" ;;
786     *) FBMODS="uvesafb" ;;
787     esac
788    
789     if [[ ${FORMFACTOR} = laptop ]]
790     then
791     OTHERMODS="acpi-cpufreq cpufreq_ondemand cpufreq_conservative cpufreq_powersave"
792     fi
793    
794     # install an appropriate uvesafb.conf
795     install -d ${INSTALLPATH}/etc/modprobe.d || die
796     echo "options uvesafb mode_option=1024x768-32@60 scroll=ywrap" > ${INSTALLPATH}/etc/modprobe.d/uvesafb.conf || die
797    
798     # install an appropriate viafb.conf
799     echo "options viafb viafb_mode=1024x768 viafb_refresh=60" > ${INSTALLPATH}/etc/modprobe.d/viafb.conf || die
800    
801     # install an appropriate i810fb.conf
802     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
803    
804     cat > ${INSTALLPATH}/root/.installrc << CHROOTEOF
805    echo "MODULES=\"${FORMAT_FILESYSTEM} ${DISKMODS} ${OLDATAMODS} ${PATAMODS} ${SATAMODS} ${DRMMODS} ${FBMODS} ${OTHERMODS}\"" > /etc/conf.d/mkinitrd
806  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
807  exit 0  exit 0
808  CHROOTEOF  CHROOTEOF
# Line 653  CHROOTEOF Line 811  CHROOTEOF
811   mount -t proc proc ${INSTALLPATH}/proc   mount -t proc proc ${INSTALLPATH}/proc
812   mount -t sysfs sysfs ${INSTALLPATH}/sys   mount -t sysfs sysfs ${INSTALLPATH}/sys
813   mount -o bind /dev ${INSTALLPATH}/dev   mount -o bind /dev ${INSTALLPATH}/dev
814   chroot ${INSTALLPATH} /bin/bash --rcfile /root/.bashrc -i   chroot ${INSTALLPATH} /bin/bash --rcfile /root/.installrc -i
815   umount ${INSTALLPATH}/proc   umount ${INSTALLPATH}/proc
816   umount ${INSTALLPATH}/sys   umount ${INSTALLPATH}/sys
817   umount ${INSTALLPATH}/dev   umount ${INSTALLPATH}/dev
818   rm ${INSTALLPATH}/root/.bashrc   rm ${INSTALLPATH}/root/.installrc
819  }  }
820    
821  is_uuid_supported()  is_uuid_supported()
# Line 711  install_system_settings() Line 869  install_system_settings()
869    
870   # install network config skeleton   # install network config skeleton
871   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
872    
873     # intel framebufer quirk
874     if [[ -e /proc/fb ]]
875     then
876     if [[ ! -z $(grep 'inteldrmfb' /proc/fb) ]]
877     then
878     fbdev=$(grep 'inteldrmfb' /proc/fb | sed 's:\([0-9]\).*:\1:')
879     if [[ ${fbdev} != 0 ]]
880     then
881     sed -i "s:^\(SPLASH_DEV=\).*:\1\"/dev/fb${fbdev}\":" ${INSTALLPATH}/etc/splash/splash.conf || die
882     fi
883     fi
884     fi
885  }  }
886    
887  install_system_settings_flash()  install_system_settings_flash()

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