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 2555 by niro, Mon Jul 4 18:07:16 2011 UTC revision 6771 by niro, Tue Jul 21 12:26:10 2015 UTC
# Line 32  CURRENTLINE=0 Line 32  CURRENTLINE=0
32  #TOTALLINES=11072 # -> now in images.conf  #TOTALLINES=11072 # -> now in images.conf
33    
34  # standard kernel opts  # standard kernel opts
35  KERNELOPTS="quiet  splash=silent,theme=default"  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
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 radeon gfxcards
508     if [[ ! -z $(echo "${hwinfo}" | grep -i radeon) ]]
509     then
510     # enable full kms support
511     export GRUB2GFXPAYLOAD="keep"
512     fi
513    
514     # check for special devices/clients:
515     # check for laptops and activate cpufreq scaling
516     if [[ $(echo "${hwinfo}" | grep 'Formfactor:' | sed 's:.*Formfactor\:\ \"\(.*\)\":\1:') = laptop ]]
517     then
518     export FORMFACTOR="laptop"
519     export KERNELOPTS="${KERNELOPTS} cpufreq.governor=ondemand"
520   fi   fi
521  }  }
522    
523    hdd_size_below_256mb()
524    {
525     local hdd="$1"
526     local size
527     local retval
528     [[ -z ${hdd} ]] && die "Error: get_hdd_size() no \$hdd given!"
529    
530     size=$(fdisk -l ${hdd} | grep "Disk.*${hdd}" | sed 's:.*,\ \(.*\)\ byte.*:\1:')
531     if [[ ${size} -le 257000000 ]]
532     then
533     retval="0"
534     else
535     retval="1"
536     fi
537    
538     return "${retval}"
539    }
540    
541  setup_hdd_partitions_auto()  setup_hdd_partitions_auto()
542  {  {
543   ROOTHDD="${HDD}1"   ROOTHDD="${HDD}1"
544    
545     # run this only if FDISKPARTITIONBELOW256MB is not already 1
546     if [[ ${FDISKPARTIONBELOW256MB} != 1 ]]
547     then
548     if hdd_size_below_256mb ${HDD}
549     then
550     FDISKPARTIONBELOW256MB=1
551     else
552     FDISKPARTIONBELOW256MB=0
553     fi
554     fi
555    
556   ## delete disk   ## delete disk
557   dd if=/dev/zero of=${HDD} count=1 &> /dev/null || die   dd if=/dev/zero of=${HDD} count=1 &> /dev/null || die
558    
559   ## setup one bootable partition   if [[ ${FDISKPARTIONBELOW256MB} = 1 ]]
560   #1. n= new disk   then
561   #2. p= primary disk   ## setup one bootable partition
562   #3. 1= first partition   #1. n= new disk
563   #4. ''= default sector start   #2. p= primary disk
564   #5. ''= defaul sector end   #3. 1= first partition
565   #6. a= bootable flag   #4. 2= default sector start // small disk needs more space for grub2 mbr sector
566   #7. 1= boot flag for partition 1   #5. ''= defaul sector end
567   #8. w= write/quit   #6. a= bootable flag
568   fdisk ${HDD} &> /dev/null << EOF   #7. 1= boot flag for partition 1
569     #8. w= write/quit
570     fdisk ${HDD} &> /dev/null << EOF
571    n
572    p
573    1
574    2
575    
576    a
577    1
578    w
579    EOF
580     else
581     ## setup one bootable partition
582     #1. n= new disk
583     #2. p= primary disk
584     #3. 1= first partition
585     #4. ''= default sector start
586     #5. ''= defaul sector end
587     #6. a= bootable flag
588     #7. 1= boot flag for partition 1
589     #8. w= write/quit
590     fdisk ${HDD} &> /dev/null << EOF
591  n  n
592  p  p
593  1  1
# Line 475  a Line 597  a
597  1  1
598  w  w
599  EOF  EOF
600     fi
601  }  }
602    
603  setup_hdd_partitions_manuell()  setup_hdd_partitions_manuell()
# Line 532  install_bootsector_chroot() Line 655  install_bootsector_chroot()
655  {  {
656   local my_roothdd   local my_roothdd
657   local grubconf=${INSTALLPATH}/boot/grub/grub.conf   local grubconf=${INSTALLPATH}/boot/grub/grub.conf
658   local grub2conf=${INSTALLPATH}/boot/grub/grub.cfg   local grub2conf=/boot/grub/grub.cfg
659    
660   # check for grub2   # check for grub2
661   if [[ -f ${INSTALLPATH}/sbin/grub-mkconfig ]]   if [[ -f ${INSTALLPATH}/sbin/grub-mkconfig ]]
# Line 540  install_bootsector_chroot() Line 663  install_bootsector_chroot()
663   # needed by grub-mkconfig on the first run   # needed by grub-mkconfig on the first run
664   if [[ ! -f ${INSTALLPATH}/boot/grub/video.lst ]]   if [[ ! -f ${INSTALLPATH}/boot/grub/video.lst ]]
665   then   then
666   install -m0644 ${INSTALLPATH}/lib/grub/*/video.lst /boot/grub/video.lst   install -m0644 ${INSTALLPATH}/lib/grub/*/video.lst ${INSTALLPATH}/boot/grub/video.lst || die
667   fi   fi
668   echo 'grub-mkdevicemap' > ${INSTALLPATH}/root/.bashrc  
669   echo "LC_ALL=C grub-mkconfig -o ${grub2conf}" >> ${INSTALLPATH}/root/.bashrc   # set kernelopts
670   echo "grub-install --no-floppy ${HDD}" >> ${INSTALLPATH}/root/.bashrc   if [[ -f ${INSTALLPATH}/etc/conf.d/grub ]]
671     then
672     sed -i "s:^\(export GRUB_CMDLINE_LINUX_DEFAULT=\).*:\1\"${KERNELOPTS}\":" ${INSTALLPATH}/etc/conf.d/grub || die
673     sed -i "s:^\(export GRUB_GFXPAYLOAD_LINUX=\).*:\1\"${GRUB2GFXPAYLOAD}\":" ${INSTALLPATH}/etc/conf.d/grub || die
674     else
675     echo "export GRUB_CMDLINE_LINUX_DEFAULT=\"${KERNELOPTS}\"" >  ${INSTALLPATH}/etc/conf.d/grub || die
676     echo "export GRUB_GFXPAYLOAD_LINUX=\"${GRUB2GFXPAYLOAD}\"" >>  ${INSTALLPATH}/etc/conf.d/grub || die
677     fi
678     echo 'grub-mkdevicemap' > ${INSTALLPATH}/root/.installrc || die
679     echo "LC_ALL=C grub-mkconfig -o ${grub2conf}  &> /dev/null" >> ${INSTALLPATH}/root/.installrc || die
680     echo "grub-install --no-floppy ${HDD} &> /dev/null" >> ${INSTALLPATH}/root/.installrc || die
681     echo "exit 0" >> ${INSTALLPATH}/root/.installrc || die
682    
683   # grub-legacy   # grub-legacy
684   else   else
# Line 582  install_bootsector_chroot() Line 716  install_bootsector_chroot()
716   echo "# normal boot" >> ${grubconf} || die   echo "# normal boot" >> ${grubconf} || die
717   echo "title ${KRNVER}" >> ${grubconf} || die   echo "title ${KRNVER}" >> ${grubconf} || die
718   echo "root (hd0,0)" >> ${grubconf} || die   echo "root (hd0,0)" >> ${grubconf} || die
719   echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS}" >> ${grubconf} || die   echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS}" >> ${grubconf} || die
720   if is_initrd_supported   if is_initrd_supported
721   then   then
722   echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die   echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die
# Line 593  install_bootsector_chroot() Line 727  install_bootsector_chroot()
727   echo "title ${KRNVER} - Re-run hardware-detection" >> ${grubconf} || die   echo "title ${KRNVER} - Re-run hardware-detection" >> ${grubconf} || die
728   echo "lock"  >> ${grubconf} || die   echo "lock"  >> ${grubconf} || die
729   echo "root (hd0,0)" >> ${grubconf} || die   echo "root (hd0,0)" >> ${grubconf} || die
730   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
731   if is_initrd_supported   if is_initrd_supported
732   then   then
733   echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die   echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die
# Line 603  install_bootsector_chroot() Line 737  install_bootsector_chroot()
737   echo "title ${KRNVER} - Reset *all* local settings" >> ${grubconf} || die   echo "title ${KRNVER} - Reset *all* local settings" >> ${grubconf} || die
738   echo "lock"  >> ${grubconf} || die   echo "lock"  >> ${grubconf} || die
739   echo "root (hd0,0)" >> ${grubconf} || die   echo "root (hd0,0)" >> ${grubconf} || die
740   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
741   if is_initrd_supported   if is_initrd_supported
742   then   then
743   echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die   echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die
744   fi   fi
745    
746   # bootsector schreiben chrooted schreiben (lfs/magellan)   # bootsector schreiben chrooted schreiben (lfs/magellan)
747   cat > ${INSTALLPATH}/root/.bashrc << CHROOTEOF   cat > ${INSTALLPATH}/root/.installrc << CHROOTEOF
748  /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
749  root (hd0,0)  root (hd0,0)
750  setup (hd0)  setup (hd0)
# Line 624  CHROOTEOF Line 758  CHROOTEOF
758   mount -t proc proc ${INSTALLPATH}/proc   mount -t proc proc ${INSTALLPATH}/proc
759   mount -t sysfs sysfs ${INSTALLPATH}/sys   mount -t sysfs sysfs ${INSTALLPATH}/sys
760   mount -o bind /dev ${INSTALLPATH}/dev   mount -o bind /dev ${INSTALLPATH}/dev
761   chroot ${INSTALLPATH} /bin/bash --rcfile /root/.bashrc -i   chroot ${INSTALLPATH} /bin/bash --rcfile /root/.installrc -i
762   umount ${INSTALLPATH}/proc   umount ${INSTALLPATH}/proc
763   umount ${INSTALLPATH}/sys   umount ${INSTALLPATH}/sys
764   umount ${INSTALLPATH}/dev   umount ${INSTALLPATH}/dev
765   rm ${INSTALLPATH}/root/.bashrc   rm ${INSTALLPATH}/root/.installrc
766  }  }
767    
768  is_initrd_supported()  is_initrd_supported()
# Line 643  install_initrd_chroot() Line 777  install_initrd_chroot()
777   # only generate initrds if the cmd exists   # only generate initrds if the cmd exists
778   is_initrd_supported || return 0   is_initrd_supported || return 0
779    
780   cat > ${INSTALLPATH}/root/.bashrc << CHROOTEOF   DISKMODS="sd_mod"
781  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"
782     PATAMODS="ata_piix pata_amd pata_mpiix pata_oldpiix pata_sis pata_via"
783     SATAMODS="sata_via sata_sis sata_nv"
784     DRMMODS="i915 mga nouveau r128 radeon savage sis tdfx ttm via"
785     OTHERMODS=""
786     case ${SPECIALDEVICE} in
787     zotac_intel|i845) FBMODS=""; DRMMODS="i915" ;;
788     zotac_nvidia) FBMODS=""; DRMMODS="nouveau" ;;
789     rangee) FBMODS="" ;; ## fallback to vesafb, viafb does not run on all CLE266 boards
790     # not working with kms enabled drivers -> segfaults
791     #maxdata) FBMODS="i810fb" ;; ## check for maxdata / i810/ i815 Chipsets and disable KMS and use i810fb frambuffer
792     maxdata) FBMODS="" ;;
793     *) FBMODS="uvesafb" ;;
794     esac
795    
796     if [[ ${FORMFACTOR} = laptop ]]
797     then
798     OTHERMODS="acpi-cpufreq cpufreq_ondemand cpufreq_conservative cpufreq_powersave"
799     fi
800    
801     # install an appropriate uvesafb.conf
802     install -d ${INSTALLPATH}/etc/modprobe.d || die
803     echo "options uvesafb mode_option=1024x768-32@60 scroll=ywrap" > ${INSTALLPATH}/etc/modprobe.d/uvesafb.conf || die
804    
805     # install an appropriate viafb.conf
806     echo "options viafb viafb_mode=1024x768 viafb_refresh=60" > ${INSTALLPATH}/etc/modprobe.d/viafb.conf || die
807    
808     # install an appropriate i810fb.conf
809     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
810    
811     cat > ${INSTALLPATH}/root/.installrc << CHROOTEOF
812    echo "MODULES=\"${FORMAT_FILESYSTEM} ${DISKMODS} ${OLDATAMODS} ${PATAMODS} ${SATAMODS} ${DRMMODS} ${FBMODS} ${OTHERMODS}\"" > /etc/conf.d/mkinitrd
813  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
814  exit 0  exit 0
815  CHROOTEOF  CHROOTEOF
# Line 653  CHROOTEOF Line 818  CHROOTEOF
818   mount -t proc proc ${INSTALLPATH}/proc   mount -t proc proc ${INSTALLPATH}/proc
819   mount -t sysfs sysfs ${INSTALLPATH}/sys   mount -t sysfs sysfs ${INSTALLPATH}/sys
820   mount -o bind /dev ${INSTALLPATH}/dev   mount -o bind /dev ${INSTALLPATH}/dev
821   chroot ${INSTALLPATH} /bin/bash --rcfile /root/.bashrc -i   chroot ${INSTALLPATH} /bin/bash --rcfile /root/.installrc -i
822   umount ${INSTALLPATH}/proc   umount ${INSTALLPATH}/proc
823   umount ${INSTALLPATH}/sys   umount ${INSTALLPATH}/sys
824   umount ${INSTALLPATH}/dev   umount ${INSTALLPATH}/dev
825   rm ${INSTALLPATH}/root/.bashrc   rm ${INSTALLPATH}/root/.installrc
826  }  }
827    
828  is_uuid_supported()  is_uuid_supported()
# Line 711  install_system_settings() Line 876  install_system_settings()
876    
877   # install network config skeleton   # install network config skeleton
878   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
879    
880     # intel framebufer quirk
881     if [[ -e /proc/fb ]]
882     then
883     if [[ ! -z $(grep 'inteldrmfb' /proc/fb) ]]
884     then
885     fbdev=$(grep 'inteldrmfb' /proc/fb | sed 's:\([0-9]\).*:\1:')
886     if [[ ${fbdev} != 0 ]]
887     then
888     sed -i "s:^\(SPLASH_DEV=\).*:\1\"/dev/fb${fbdev}\":" ${INSTALLPATH}/etc/splash/splash.conf || die
889     fi
890     fi
891     fi
892  }  }
893    
894  install_system_settings_flash()  install_system_settings_flash()

Legend:
Removed from v.2555  
changed lines
  Added in v.6771