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 3374 by niro, Wed Mar 28 09:54:00 2012 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=""
# Line 200  dialog_hardware_detection() Line 207  dialog_hardware_detection()
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)"
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 GRUBLEGACYOPTS="rootdelay=8"
462   export SPECIALDEVICE="zotac"   export SPECIALDEVICE="zotac"
463   fi   fi
464    
465     # check for special devices/clients:
466     # if a rangee and disk ist smaller then 256mb move partion one block further ahead
467     if [[ ! -z $(echo "${hwinfo}" | grep -i CLE266) ]]
468     then
469     # for a rangee always define partion startblock +1
470     export FDISKPARTIONBELOW256MB="1"
471     export SPECIALDEVICE="rangee"
472     export GRUBLEGACYOPTS=""
473     fi
474    
475     # check for special devices/clients:
476     # check for maxdata / i810/ i815 Chipsets and disable KMS and use i810fb frambuffer
477     if [[ ! -z $(echo "${hwinfo}" | grep -i i810) ]] || [[ ! -z $(echo "${hwinfo}" | grep -i i815) ]]
478     then
479     export SPECIALDEVICE="maxdata"
480     export GRUBLEGACYOPTS=""
481     fi
482    }
483    
484    hdd_size_below_256mb()
485    {
486     local hdd="$1"
487     local size
488     local retval
489     [[ -z ${hdd} ]] && die "Error: get_hdd_size() no \$hdd given!"
490    
491     size=$(fdisk -l ${hdd} | grep "Disk.*${hdd}" | sed 's:.*,\ \(.*\)\ byte.*:\1:')
492     if [[ ${size} -le 257000000 ]]
493     then
494     retval="0"
495     else
496     retval="1"
497     fi
498    
499     return "${retval}"
500  }  }
501    
502  setup_hdd_partitions_auto()  setup_hdd_partitions_auto()
503  {  {
504   ROOTHDD="${HDD}1"   ROOTHDD="${HDD}1"
505    
506     # run this only if FDISKPARTITIONBELOW256MB is not already 1
507     if [[ ${FDISKPARTIONBELOW256MB} != 1 ]]
508     then
509     if hdd_size_below_256mb ${HDD}
510     then
511     FDISKPARTIONBELOW256MB=1
512     else
513     FDISKPARTIONBELOW256MB=0
514     fi
515     fi
516    
517   ## delete disk   ## delete disk
518   dd if=/dev/zero of=${HDD} count=1 &> /dev/null || die   dd if=/dev/zero of=${HDD} count=1 &> /dev/null || die
519    
520   ## setup one bootable partition   if [[ ${FDISKPARTIONBELOW256MB} = 1 ]]
521   #1. n= new disk   then
522   #2. p= primary disk   ## setup one bootable partition
523   #3. 1= first partition   #1. n= new disk
524   #4. ''= default sector start   #2. p= primary disk
525   #5. ''= defaul sector end   #3. 1= first partition
526   #6. a= bootable flag   #4. 2= default sector start // small disk needs more space for grub2 mbr sector
527   #7. 1= boot flag for partition 1   #5. ''= defaul sector end
528   #8. w= write/quit   #6. a= bootable flag
529   fdisk ${HDD} &> /dev/null << EOF   #7. 1= boot flag for partition 1
530     #8. w= write/quit
531     fdisk ${HDD} &> /dev/null << EOF
532    n
533    p
534    1
535    2
536    
537    a
538    1
539    w
540    EOF
541     else
542     ## setup one bootable partition
543     #1. n= new disk
544     #2. p= primary disk
545     #3. 1= first partition
546     #4. ''= default sector start
547     #5. ''= defaul sector end
548     #6. a= bootable flag
549     #7. 1= boot flag for partition 1
550     #8. w= write/quit
551     fdisk ${HDD} &> /dev/null << EOF
552  n  n
553  p  p
554  1  1
# Line 475  a Line 558  a
558  1  1
559  w  w
560  EOF  EOF
561     fi
562  }  }
563    
564  setup_hdd_partitions_manuell()  setup_hdd_partitions_manuell()
# Line 532  install_bootsector_chroot() Line 616  install_bootsector_chroot()
616  {  {
617   local my_roothdd   local my_roothdd
618   local grubconf=${INSTALLPATH}/boot/grub/grub.conf   local grubconf=${INSTALLPATH}/boot/grub/grub.conf
619   local grub2conf=${INSTALLPATH}/boot/grub/grub.cfg   local grub2conf=/boot/grub/grub.cfg
620    
621   # check for grub2   # check for grub2
622   if [[ -f ${INSTALLPATH}/sbin/grub-mkconfig ]]   if [[ -f ${INSTALLPATH}/sbin/grub-mkconfig ]]
# Line 540  install_bootsector_chroot() Line 624  install_bootsector_chroot()
624   # needed by grub-mkconfig on the first run   # needed by grub-mkconfig on the first run
625   if [[ ! -f ${INSTALLPATH}/boot/grub/video.lst ]]   if [[ ! -f ${INSTALLPATH}/boot/grub/video.lst ]]
626   then   then
627   install -m0644 ${INSTALLPATH}/lib/grub/*/video.lst /boot/grub/video.lst   install -m0644 ${INSTALLPATH}/lib/grub/*/video.lst ${INSTALLPATH}/boot/grub/video.lst || die
628     fi
629    
630     # set kernelopts
631     if [[ -f ${INSTALLPATH}/etc/conf.d/grub ]]
632     then
633     sed -i "s:^\(export GRUB_CMDLINE_LINUX_DEFAULT=\).*:\1\"${KERNELOPTS}\":" ${INSTALLPATH}/etc/conf.d/grub || die
634     else
635     echo "export GRUB_CMDLINE_LINUX_DEFAULT=\"${KERNELOPTS}\"" >  ${INSTALLPATH}/etc/conf.d/grub || die
636   fi   fi
637   echo 'grub-mkdevicemap' > ${INSTALLPATH}/root/.bashrc   echo 'grub-mkdevicemap' > ${INSTALLPATH}/root/.installrc || die
638   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
639   echo "grub-install --no-floppy ${HDD}" >> ${INSTALLPATH}/root/.bashrc   echo "grub-install --no-floppy ${HDD} &> /dev/null" >> ${INSTALLPATH}/root/.installrc || die
640     echo "exit 0" >> ${INSTALLPATH}/root/.installrc || die
641    
642   # grub-legacy   # grub-legacy
643   else   else
# Line 582  install_bootsector_chroot() Line 675  install_bootsector_chroot()
675   echo "# normal boot" >> ${grubconf} || die   echo "# normal boot" >> ${grubconf} || die
676   echo "title ${KRNVER}" >> ${grubconf} || die   echo "title ${KRNVER}" >> ${grubconf} || die
677   echo "root (hd0,0)" >> ${grubconf} || die   echo "root (hd0,0)" >> ${grubconf} || die
678   echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS}" >> ${grubconf} || die   echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS}" >> ${grubconf} || die
679   if is_initrd_supported   if is_initrd_supported
680   then   then
681   echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die   echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die
# Line 593  install_bootsector_chroot() Line 686  install_bootsector_chroot()
686   echo "title ${KRNVER} - Re-run hardware-detection" >> ${grubconf} || die   echo "title ${KRNVER} - Re-run hardware-detection" >> ${grubconf} || die
687   echo "lock"  >> ${grubconf} || die   echo "lock"  >> ${grubconf} || die
688   echo "root (hd0,0)" >> ${grubconf} || die   echo "root (hd0,0)" >> ${grubconf} || die
689   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
690   if is_initrd_supported   if is_initrd_supported
691   then   then
692   echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die   echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die
# Line 603  install_bootsector_chroot() Line 696  install_bootsector_chroot()
696   echo "title ${KRNVER} - Reset *all* local settings" >> ${grubconf} || die   echo "title ${KRNVER} - Reset *all* local settings" >> ${grubconf} || die
697   echo "lock"  >> ${grubconf} || die   echo "lock"  >> ${grubconf} || die
698   echo "root (hd0,0)" >> ${grubconf} || die   echo "root (hd0,0)" >> ${grubconf} || die
699   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
700   if is_initrd_supported   if is_initrd_supported
701   then   then
702   echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die   echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die
703   fi   fi
704    
705   # bootsector schreiben chrooted schreiben (lfs/magellan)   # bootsector schreiben chrooted schreiben (lfs/magellan)
706   cat > ${INSTALLPATH}/root/.bashrc << CHROOTEOF   cat > ${INSTALLPATH}/root/.installrc << CHROOTEOF
707  /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
708  root (hd0,0)  root (hd0,0)
709  setup (hd0)  setup (hd0)
# Line 624  CHROOTEOF Line 717  CHROOTEOF
717   mount -t proc proc ${INSTALLPATH}/proc   mount -t proc proc ${INSTALLPATH}/proc
718   mount -t sysfs sysfs ${INSTALLPATH}/sys   mount -t sysfs sysfs ${INSTALLPATH}/sys
719   mount -o bind /dev ${INSTALLPATH}/dev   mount -o bind /dev ${INSTALLPATH}/dev
720   chroot ${INSTALLPATH} /bin/bash --rcfile /root/.bashrc -i   chroot ${INSTALLPATH} /bin/bash --rcfile /root/.installrc -i
721   umount ${INSTALLPATH}/proc   umount ${INSTALLPATH}/proc
722   umount ${INSTALLPATH}/sys   umount ${INSTALLPATH}/sys
723   umount ${INSTALLPATH}/dev   umount ${INSTALLPATH}/dev
724   rm ${INSTALLPATH}/root/.bashrc   rm ${INSTALLPATH}/root/.installrc
725  }  }
726    
727  is_initrd_supported()  is_initrd_supported()
# Line 643  install_initrd_chroot() Line 736  install_initrd_chroot()
736   # only generate initrds if the cmd exists   # only generate initrds if the cmd exists
737   is_initrd_supported || return 0   is_initrd_supported || return 0
738    
739   cat > ${INSTALLPATH}/root/.bashrc << CHROOTEOF   DISKMODS="sd_mod"
740  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"
741     PATAMODS="ata_piix pata_amd pata_mpiix pata_oldpiix pata_sis pata_via"
742     SATAMODS="sata_via sata_sis sata_nv"
743     DRMMODS="i915 mga nouveau r128 radeon savage sis tdfx ttm via"
744     case ${SPECIALDEVICE} in
745     zotac) FBMODS="" ;;
746     rangee) FBMODS="" ;; ## fallback to vesafb, viafb does not run on all CLE266 boards
747     maxdata) FBMODS="i810fb" ;; ## check for maxdata / i810/ i815 Chipsets and disable KMS and use i810fb frambuffer
748     *) FBMODS="uvesafb" ;;
749     esac
750    
751     # install an appropriate uvesafb.conf
752     install -d ${INSTALLPATH}/etc/modprobe.d || die
753     echo "options uvesafb mode_option=1024x768-32@60 scroll=ywrap" > ${INSTALLPATH}/etc/modprobe.d/uvesafb.conf || die
754    
755     # install an appropriate viafb.conf
756     echo "options viafb viafb_mode=1024x768 viafb_refresh=60" > ${INSTALLPATH}/etc/modprobe.d/viafb.conf || die
757    
758     # install an appropriate i810fb.conf
759     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
760    
761     cat > ${INSTALLPATH}/root/.installrc << CHROOTEOF
762    echo "MODULES=\"${FORMAT_FILESYSTEM} ${DISKMODS} ${OLDATAMODS} ${PATAMODS} ${SATAMODS} ${DRMMODS} ${FBMODS}\"" > /etc/conf.d/mkinitrd
763  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
764  exit 0  exit 0
765  CHROOTEOF  CHROOTEOF
# Line 653  CHROOTEOF Line 768  CHROOTEOF
768   mount -t proc proc ${INSTALLPATH}/proc   mount -t proc proc ${INSTALLPATH}/proc
769   mount -t sysfs sysfs ${INSTALLPATH}/sys   mount -t sysfs sysfs ${INSTALLPATH}/sys
770   mount -o bind /dev ${INSTALLPATH}/dev   mount -o bind /dev ${INSTALLPATH}/dev
771   chroot ${INSTALLPATH} /bin/bash --rcfile /root/.bashrc -i   chroot ${INSTALLPATH} /bin/bash --rcfile /root/.installrc -i
772   umount ${INSTALLPATH}/proc   umount ${INSTALLPATH}/proc
773   umount ${INSTALLPATH}/sys   umount ${INSTALLPATH}/sys
774   umount ${INSTALLPATH}/dev   umount ${INSTALLPATH}/dev
775   rm ${INSTALLPATH}/root/.bashrc   rm ${INSTALLPATH}/root/.installrc
776  }  }
777    
778  is_uuid_supported()  is_uuid_supported()
# Line 711  install_system_settings() Line 826  install_system_settings()
826    
827   # install network config skeleton   # install network config skeleton
828   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
829    
830     # intel framebufer quirk
831     if [[ -e /proc/fb ]]
832     then
833     if [[ ! -z $(grep 'inteldrmfb' /proc/fb) ]]
834     then
835     fbdev=$(grep 'inteldrmfb' /proc/fb | sed 's:\([0-9]\).*:\1:')
836     if [[ ${fbdev} != 0 ]]
837     then
838     sed -i "s:^\(SPLASH_OPTS=\).*:\1\"-d /dev/fb${fbdev}\":" ${INSTALLPATH}/etc/splash/splash.conf || die
839     fi
840     fi
841     fi
842  }  }
843    
844  install_system_settings_flash()  install_system_settings_flash()

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