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 2557 by niro, Mon Jul 4 18:24:30 2011 UTC revision 4853 by niro, Wed May 15 07:25:12 2013 UTC
# Line 34  CURRENTLINE=0 Line 34  CURRENTLINE=0
34  # standard kernel opts  # standard kernel opts
35  KERNELOPTS="quiet video=1024x768"  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    
# 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 $(hwinfo --bios --storage | 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
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   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 532  install_bootsector_chroot() Line 622  install_bootsector_chroot()
622  {  {
623   local my_roothdd   local my_roothdd
624   local grubconf=${INSTALLPATH}/boot/grub/grub.conf   local grubconf=${INSTALLPATH}/boot/grub/grub.conf
625   local grub2conf=${INSTALLPATH}/boot/grub/grub.cfg   local grub2conf=/boot/grub/grub.cfg
626    
627   # check for grub2   # check for grub2
628   if [[ -f ${INSTALLPATH}/sbin/grub-mkconfig ]]   if [[ -f ${INSTALLPATH}/sbin/grub-mkconfig ]]
# Line 540  install_bootsector_chroot() Line 630  install_bootsector_chroot()
630   # needed by grub-mkconfig on the first run   # needed by grub-mkconfig on the first run
631   if [[ ! -f ${INSTALLPATH}/boot/grub/video.lst ]]   if [[ ! -f ${INSTALLPATH}/boot/grub/video.lst ]]
632   then   then
633   install -m0644 ${INSTALLPATH}/lib/grub/*/video.lst /boot/grub/video.lst || die   install -m0644 ${INSTALLPATH}/lib/grub/*/video.lst ${INSTALLPATH}/boot/grub/video.lst || die
634   fi   fi
635    
636   # set kernelopts   # set kernelopts
637   if [[ -f ${INSTALLPATH}/etc/conf.d/grub ]]   if [[ -f ${INSTALLPATH}/etc/conf.d/grub ]]
638   then   then
639   sed -i "s:^\(export GRUB_CMDLINE_LINUX_DEFAULT\)=.*:\1\"${KERNELOPTS}\":" ${INSTALLPATH}/etc/conf.d/grub || die   sed -i "s:^\(export GRUB_CMDLINE_LINUX_DEFAULT=\).*:\1\"${KERNELOPTS}\":" ${INSTALLPATH}/etc/conf.d/grub || die
640   else   else
641   echo "export GRUB_CMDLINE_LINUX_DEFAULT=\"${KERNELOPTS}\"" >  ${INSTALLPATH}/etc/conf.d/grub || die   echo "export GRUB_CMDLINE_LINUX_DEFAULT=\"${KERNELOPTS}\"" >  ${INSTALLPATH}/etc/conf.d/grub || die
642   fi   fi
643   echo 'grub-mkdevicemap' > ${INSTALLPATH}/root/.bashrc || die   echo 'grub-mkdevicemap' > ${INSTALLPATH}/root/.installrc || die
644   echo "LC_ALL=C grub-mkconfig -o ${grub2conf}" >> ${INSTALLPATH}/root/.bashrc || die   echo "LC_ALL=C grub-mkconfig -o ${grub2conf}  &> /dev/null" >> ${INSTALLPATH}/root/.installrc || die
645   echo "grub-install --no-floppy ${HDD}" >> ${INSTALLPATH}/root/.bashrc || die   echo "grub-install --no-floppy ${HDD} &> /dev/null" >> ${INSTALLPATH}/root/.installrc || die
646     echo "exit 0" >> ${INSTALLPATH}/root/.installrc || die
647    
648   # grub-legacy   # grub-legacy
649   else   else
# Line 590  install_bootsector_chroot() Line 681  install_bootsector_chroot()
681   echo "# normal boot" >> ${grubconf} || die   echo "# normal boot" >> ${grubconf} || die
682   echo "title ${KRNVER}" >> ${grubconf} || die   echo "title ${KRNVER}" >> ${grubconf} || die
683   echo "root (hd0,0)" >> ${grubconf} || die   echo "root (hd0,0)" >> ${grubconf} || die
684   echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS}" >> ${grubconf} || die   echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS}" >> ${grubconf} || die
685   if is_initrd_supported   if is_initrd_supported
686   then   then
687   echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die   echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die
# Line 601  install_bootsector_chroot() Line 692  install_bootsector_chroot()
692   echo "title ${KRNVER} - Re-run hardware-detection" >> ${grubconf} || die   echo "title ${KRNVER} - Re-run hardware-detection" >> ${grubconf} || die
693   echo "lock"  >> ${grubconf} || die   echo "lock"  >> ${grubconf} || die
694   echo "root (hd0,0)" >> ${grubconf} || die   echo "root (hd0,0)" >> ${grubconf} || die
695   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
696   if is_initrd_supported   if is_initrd_supported
697   then   then
698   echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die   echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die
# Line 611  install_bootsector_chroot() Line 702  install_bootsector_chroot()
702   echo "title ${KRNVER} - Reset *all* local settings" >> ${grubconf} || die   echo "title ${KRNVER} - Reset *all* local settings" >> ${grubconf} || die
703   echo "lock"  >> ${grubconf} || die   echo "lock"  >> ${grubconf} || die
704   echo "root (hd0,0)" >> ${grubconf} || die   echo "root (hd0,0)" >> ${grubconf} || die
705   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
706   if is_initrd_supported   if is_initrd_supported
707   then   then
708   echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die   echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die
709   fi   fi
710    
711   # bootsector schreiben chrooted schreiben (lfs/magellan)   # bootsector schreiben chrooted schreiben (lfs/magellan)
712   cat > ${INSTALLPATH}/root/.bashrc << CHROOTEOF   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 632  CHROOTEOF Line 723  CHROOTEOF
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 651  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 661  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 719  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()

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