--- alx-src/trunk/alxinstall-ng/bin/alxinstall-ng.sh 2005/04/19 17:24:57 268 +++ alx-src/trunk/alxinstall-ng/bin/alxinstall-ng.sh.in 2015/07/23 12:28:10 6835 @@ -1,70 +1,79 @@ #!/bin/sh -# -# $Header: /home/cvsd/alx-cvs/alx-src/alxinstall-ng/bin/alxinstall-ng.sh,v 1.4 2005-04-19 17:24:57 niro Exp $ -# -# AutoSta_LX Installation Script -# version: 0.8b -# -# Niels Rogalla -# -# -# -# Install Navigation Gui -# +# $Id$ -#source /etc/alx_version -#source /opt/alx-config/version +# ignore environment! +LC_ALL=C -#source /etc/alx-config/config.rc +MLIBDIR="/usr/lib/alxinstall-ng" -#images: (get ${CDIMAGENAME}) +# images: (get ${CDIMAGENAME}) source /mnt/cdrom/system/images.conf -#Includes -source /usr/lib/alxinstall-ng/functions/findhdd.sh > /dev/null -### bugfix ############################### -cdromdev="`echo $cdromdev|sed -e 's/ //'`" -######################################## +# includes +source ${MLIBDIR}/functions/generic.sh +source ${MLIBDIR}/functions/hwdetection.sh ### System/Config Version -VERSION="0.1" +VERSION="@@VERSION@@" TITLE="alxinstall-ng - ${VERSION}" -#CONFIGS_TEMPLATE="/opt/alx-config/configs" - +# locations CDPATH="/mnt/cdrom" -INSTALLPATH="/mnt/magellan" +INSTALL_ROOT="/mnt/magellan" -### WICHTIG: anzahl lines in der autosta_lx.tar.gz -1 +# default system settings +# standard kernel opts +DEFAULT_KERNELOPTS="quiet video=1024x768" + +# grub options +DEFAULT_GRUBLEGACYOPTS="" +DEFAULT_GRUB2OPTS="" +DEFAULT_GRUB2GFXPAYLOAD="1024x768x16,1024x768" + +# default specialdevices +DEFAULT_FORMFACTOR="desktop" + +# target filesystem +DEFAULT_FORMAT_FILESYSTEM="ext4" + +# initialize global variables so they are exportable +INSTALL_METHOD="" +KERNELOPTS="" +GRUBLEGACYOPTS="" +GRUB2OPTS="" +GRUB2GFXPAYLOAD="" +FORMFACTOR="" +FORMAT_FILESYSTEM="" +FDISKPARTIONBELOW256MB=0 +SPECIALDEVICE="" +### linecount of system.tar.gz -1 ! CURRENTLINE=0 #TOTALLINES=11072 # -> now in images.conf - ################################################# -# DIALOG BOXEN # +# DIALOG BOXES # ################################################# -die() { - #clear - #echo -e "\nhuch, da ist ein script gestorben -> $?\n" - #read - #exit 0 +die() +{ ERROR=$1 RETVAL=$? dialog_install_failure + trap_exit exit 1 } -dialog_warning() { +dialog_warning() +{ dialog \ - --backtitle "$TITLE" \ + --backtitle "${TITLE}" \ --colors \ --defaultno \ --yesno "\Z1 !!! Achtung !!! \Zn\n\n\ Diese Festplatte wird unwiederruflich geloescht werden.\n\n\ Soll ich wirklich fortfahren ?" 10 70 RES=$? - if [ "$RES" == "1" ] + if [[ ${RES} -eq 1 ]] then clear echo "Der Vorgang wurde abgebrochen." @@ -72,13 +81,26 @@ fi } -dialog_setup_hdd_info(){ - local SHDD="`echo $HDD|sed -e 's/\/dev\///'`" +dialog_setup_hdd_info() +{ + case "${INSTALL_METHOD}" in + auto) + dialog_setup_hdd_info_auto + dialog_setup_hdd_create_partitions + ;; + normal) dialog_setup_hdd_info_normal ;; + single) dialog_setup_hdd_info_single ;; + esac +} + +dialog_setup_hdd_info_normal() +{ + local SHDD="$(echo ${HDD} | sed 's/\/dev\///')" dialog \ --colors \ --title "[ Festplatten Partitionierung ]" \ - --backtitle "$TITLE" \ + --backtitle "${TITLE}" \ --ok-label "Weiter" \ --msgbox "\nBitte legen Sie 3 Partitionen an.\n\n\ [ \Z3${SHDD}1\Zn ] Typ: \Z3Linux\Zn mit ca. 50MB\n\ @@ -87,149 +109,200 @@ Bitte ${SHDD}1 als \Z3bootable\Zn markieren." 12 81 } -dialog_setup_hdd_menu() { +dialog_setup_hdd_info_single() +{ + local SHDD="$(echo $HDD | sed 's/\/dev\///')" + + dialog \ + --colors \ + --title "[ Festplatten Partitionierung ]" \ + --backtitle "${TITLE}" \ + --ok-label "Weiter" \ + --msgbox "\nBitte legen Sie 1 Partition an.\n\n\ + [ \Z3${SHDD}1\Zn ] Typ: \Z3Linux\Zn mit dem gesamten Speicher\n\ + Bitte ${SHDD}1 als \Z3bootable\Zn markieren." 12 81 +} + +dialog_setup_hdd_info_auto() +{ + local SHDD="$(echo $HDD | sed 's/\/dev\///')" - I=`dialog \ - --backtitle "$TITLE" \ + dialog \ + --colors \ + --title "[ Festplatten Partitionierung ]" \ + --backtitle "${TITLE}" \ + --ok-label "Weiter" \ + --msgbox "\nAchtung!\n\ + Alle Daten werden von der Disk [ \Z3${HDD}\Zn ] gelöscht!" 12 81 +} + +dialog_setup_system_menu() +{ + local i + + i=$(dialog \ + --backtitle "${TITLE}" \ --title "[ Festplatten Partitionierung ]" \ --cancel-label "Abbrechen" \ --ok-label "Weiter" \ --stdout \ - --menu "\nWaehlen Sie zwischen Manuell und Automatisch" 14 70 5 \ - "1" "Manuell" \ - "2" "Automatisch"` + --colors \ + --menu "\nWaehlen Sie die Installations-Methode" 14 70 5 \ + "1" "Automatisches Setup (Empfohlen)" \ + "" "" \ + "" "\Z1Experten Modi:\Zn" \ + "2" "Normale IDE-Disk (Manuell)" \ + "3" "Normale IDE Disk (Single)") RES=$? - if [ "$RES" == "1" ];then - return 1 - fi - if [ "$RES" == "0" ];then - case "$I" in - "1") - dialog_setup_hdd_found_manuell - ;; - "2") - dialog_warning - setup_hdd_partitions_silent - ;; + [[ ${RES} -eq 1 ]] && return 1 + if [[ ${RES} -eq 0 ]] + then + case "${i}" in + "1") run_install auto ;; + "2") run_install normal ;; + "3") run_install single ;; + "") dialog_setup_system_menu;; esac fi } -dialog_setup_hdd_found_manuell() { - if [ ! -z "$installdevs" ] +dialog_hardware_detection() +{ + local i + local hwtmp + + if [ -x $(which mktemp &> /dev/null) ] then - installdevs="" + hwtmp="$(mktemp)" + else + hwtmp="/tmp/hwtmp.sh" fi - echo "dialog \\" > /tmp/hddtmp.sh - echo "--backtitle \"$TITLE\" \\" >> /tmp/hddtmp.sh - echo "--ok-label \"Weiter\" \\" >> /tmp/hddtmp.sh - echo "--stdout \\" >> /tmp/hddtmp.sh - echo "--colors \\" >> /tmp/hddtmp.sh - echo "--msgbox \"Gefundene Hardware:\n\n \\" >> /tmp/hddtmp.sh - echo " Festplatten:\n \\" >> /tmp/hddtmp.sh + run_hardware_detection_disks - if [ ! -z "$scsidisks" ] + echo "dialog \\" > ${hwtmp} + echo "--backtitle \"${TITLE}\" \\" >> ${hwtmp} + echo "--ok-label \"Weiter\" \\" >> ${hwtmp} + echo "--stdout \\" >> ${hwtmp} + echo "--colors \\" >> ${hwtmp} + echo "--msgbox \"Gefundene Hardware:\n\n \\" >> ${hwtmp} + echo " Festplatten:\n \\" >> ${hwtmp} + + if [[ ! -z ${ALL_DISKS} ]] then - for I in $scsidisks + for i in ${ALL_DISKS} do - if [ "$I" != "$cdromdev" ] - then - echo " \\Z7SCSI: \\Z3$I\\Zn\n \\" >> /tmp/hddtmp.sh - installdevs="$installdevs $I" - fi + echo " \\Z3${i}\\Zn\n \\" >> ${hwtmp} done fi - if [ ! -z "$idedisks" ] + if [[ ! -z ${ALL_CDROMS} ]] then - for I in $idedisks + echo " \n \\" >> ${hwtmp} + echo " CDROM Laufwerke:\n \\" >> ${hwtmp} + for i in ${ALL_CDROMS} do - if [ "$I" != "$cdromdev" ] - then - echo " \\Z7IDE: \\Z3$I\\Zn\n \\" >> /tmp/hddtmp.sh - installdevs="$installdevs $I" - fi + echo " \\Z3${i}\\Zn\n \\" >> ${hwtmp} done fi - if [ ! -z "$cdromdev" ] + # other devices + run_hardware_detection + case "${SPECIALDEVICE}" in + zotac*) echo " \n \\Z2Zotac Device erkannt.\\Zn \\" >> ${hwtmp} ;; + rangee) echo " \n \\Z2Rangee Device erkannt.\\Zn \\" >> ${hwtmp} ;; + maxdata) echo " \n \\Z2Maxdata Device erkannt.\\Zn \\" >> ${hwtmp} ;; + i845) echo " \n \\Z2Intel i845 Device erkannt.\\Zn \\" >> ${hwtmp} ;; + *) echo " \n \\ZnStandard Device erkannt.\\Zn \\" >> ${hwtmp} ;; + esac + if [[ ${FORMFACTOR} = laptop ]] + then + echo " \n \\ZnFormfactor Laptop, Powersave Modus 'ondemand' wird aktiviert.\\Zn \\" >> ${hwtmp} + fi + + echo " \" 14 70" >> ${hwtmp} + chmod a+x ${hwtmp} + ${hwtmp} + + # remove tmp file + if [[ -f ${hwtmp} ]] then - echo " \n \\" >> /tmp/hddtmp.sh - echo " \\Z7andere Laufwerke:\n \\" >> /tmp/hddtmp.sh - echo " CDROM: \\Z3$cdromdev\\Zn\n \\" >> /tmp/hddtmp.sh + rm ${hwtmp} fi - echo " \" 13 70" >> /tmp/hddtmp.sh - chmod a+x /tmp/hddtmp.sh - /tmp/hddtmp.sh } -dialog_setup_hdd_partitions_manuell() { - if [ -z "$installdevs" ] +dialog_setup_hdd_partitions() +{ + local i + + if [[ -z ${ALL_DISKS} ]] then dialog \ - --backtitle "$TITLE" \ + --backtitle "${TITLE}" \ --ok-label "Beenden" \ --msgbox "Kein geeignetes Laufwerk gefunden.\nDie Installation ist fehlgeschlagen." 6 70 exit 1 else echo "dialog \\" > /tmp/hddtmp.sh - echo "--backtitle \"$TITLE\" \\" >> /tmp/hddtmp.sh + echo "--backtitle \"${TITLE}\" \\" >> /tmp/hddtmp.sh echo "--ok-label \"Weiter\" \\" >> /tmp/hddtmp.sh echo "--cancel-label \"Beenden\" \\" >> /tmp/hddtmp.sh echo "--stdout \\" >> /tmp/hddtmp.sh echo "--menu \"Installations Laufwerk auswaehlen:\" 10 70 3 \\" >> /tmp/hddtmp.sh - for I in $installdevs + for i in ${ALL_DISKS} do - echo "\"$I\" \"\" \\" >> /tmp/hddtmp.sh + echo "\"${i}\" \"\" \\" >> /tmp/hddtmp.sh done echo -e "\n" >> /tmp/hddtmp.sh chmod a+x /tmp/hddtmp.sh - HDD="`/tmp/hddtmp.sh`" + HDD="$(/tmp/hddtmp.sh)" RES=$? - if [ "$RES" == "1" ] - then - return 1 - fi - if [ "$RES" == "0" ] + [[ ${RES} -eq 1 ]] && return 1 + if [[ ${RES} -eq 0 ]] then dialog_setup_hdd_info - setup_hdd_partitions_manuell + setup_hdd_partitions fi fi } -dialog_setup_hdd_partitions_silent() { +dialog_setup_hdd_create_partitions() +{ dialog \ - --backtitle "$TITLE" \ - --infobox "Erstelle Partitionen ..." 3 70 + --backtitle "${TITLE}" \ + --infobox "Erstelle Disk Partitionen ..." 3 70 } -dialog_setup_hdd_format() { +dialog_setup_hdd_format() +{ dialog \ - --backtitle "$TITLE" \ + --backtitle "${TITLE}" \ --infobox "Erstelle Datei-Systeme ..." 3 70 } -dialog_install_settings() { +dialog_install_settings() +{ dialog \ - --backtitle "$TITLE" \ + --backtitle "${TITLE}" \ --infobox "Speichere System-Einstellungen ..." 3 70 } -dialog_install_system_image() { +dialog_install_system_image() +{ dialog \ - --backtitle "$TITLE" \ + --backtitle "${TITLE}" \ --gauge "Kopiere System-Image ..." 6 80 } -dialog_install_meter() { - while [ "${CURRENTLINE}" != "${TOTALLINES}" ] ; do - CURRENTLINE=`grep --count . /tmp/install.log` - PERCENT=`expr ${CURRENTLINE} \* 100 / ${TOTALLINES}` +dialog_install_meter() +{ + while [[ ${CURRENTLINE} != ${TOTALLINES} ]] + do + CURRENTLINE=$(grep -c . /tmp/install.log) + PERCENT=$(( ${CURRENTLINE} * 100 / ${TOTALLINES})) echo ${PERCENT} sleep 1 done @@ -237,83 +310,39 @@ return 0 } - -dialog_install_bootsector() { +dialog_install_bootsector() +{ dialog \ - --backtitle "$TITLE" \ + --backtitle "${TITLE}" \ --infobox "Schreibe den Bootsektor ..." 3 70 } -dialog_install_alxconfig() { - dialog \ - --backtitle "$TITLE" \ - --infobox "Installiere die ALX Setup-Tools ..." 3 70 -} - -dialog_install_kernel_image() { +dialog_install_successful() +{ dialog \ - --backtitle "$TITLE" \ - --infobox "Installiere den System-Kernel ..." 3 70 - -} - -dialog_install_hotfixes() { - dialog \ - --backtitle "$TITLE" \ - --infobox "Installiere Hotfixes ..." 3 70 - -} - -dialog_install_successful() { - dialog \ - --backtitle "$TITLE" \ + --backtitle "${TITLE}" \ --colors \ --msgbox "Die Installation war \Z2erfolgreich\Zn." 5 81 } -dialog_install_failure() { +dialog_install_failure() +{ dialog \ - --backtitle "$TITLE" \ + --backtitle "${TITLE}" \ --colors \ --msgbox "Die Installation ist \Z1Fehlgeschlagen\Zn.\n\n\ - Fehler bei $ERROR, RetVal: $RETVAL \ + Fehler bei ${ERROR}, RetVal: ${RETVAL} \ " 10 81 } -dialog_install_method() { - - METHOD=`dialog \ - --backtitle "$TITLE" \ - --cancel-label "Abbrechen" \ - --ok-label "Weiter" \ - --stdout \ - --menu "Konfiguration" 14 70 5 \ - "1" "Normale Installation" \ - "2" "Silent Installation"` - RES=$? - if [ "$RES" == "1" ];then - return 1 - fi - if [ "$RES" == "0" ];then - case "$METHOD" in - "1") - run_install_normal - ;; - "2") - dialog_warning - run_install_silent - ;; - esac - fi -} - -dialog_main() { +dialog_main() +{ METHOD=0 - while [ $METHOD -le 2 ] + while [[ ${METHOD} -le 2 ]] do - METHOD=`dialog \ - --backtitle "$TITLE" \ + METHOD=$(dialog \ + --backtitle "${TITLE}" \ --no-cancel \ --ok-label "Weiter" \ --stdout \ @@ -321,348 +350,573 @@ "1" "AutoSta_LX installieren" \ "2" "Uebersicht gefundener Laufwerke" \ "3" "Beenden und neustarten" \ - "4" "Beenden und eine Shell starten" ` + "4" "Beenden und eine Shell starten") RES=$? - if [ "$RES" == "1" ];then - exit 1 - fi - if [ "$RES" == "0" ];then - case "$METHOD" in - "1") - #only for now later it will be used again - #with 6.1-r2 only one install method available - #dialog_install_method - run_install_normal - ;; - "2") dialog_setup_hdd_found_manuell - ;; - "3") install_do_reboot - ;; - "4") /bin/bash --login -i - ;; + [[ ${RES} -eq 1 ]] && exit 1 + if [[ ${RES} -eq 0 ]] + then + case ${METHOD} in + "1") dialog_setup_system_menu ;; + "2") dialog_hardware_detection ;; + "3") install_do_reboot ;; + "4") /bin/bash --login -i ;; esac fi done } ################################################# -# Install Komandos # +# Install Commands # ################################################# -setup_hdd_partitions_manuell() { - BOOTHDD="${HDD}1" - SWAPHDD="${HDD}2" - ROOTHDD="${HDD}3" - - ## hdds partitionieren manuell - cfdisk $HDD || die -} +run_hardware_detection() +{ + local hwinfo + hwinfo="$(hwinfo --bios --storage --pci --gfxcard --sys)" + + # check for special devices/clients: + # if zotac a zotac and the disk is a removeable device, then add rootdelay to kernelcmd + local removable=0 + if [[ ! -z $(echo "${hwinfo}" | grep -i zotac) ]] + then + for i in /sys/block/[hs]d*/removable + do + if [[ $(< ${i}) = 1 ]] + then + removable=1 + fi + done -setup_hdd_partitions_silent() { - ## hdds löschen - dd if=/dev/zero of=$HDD bs=1024k count=1 || die - ## hdds partitionieren silent - fdisk $HDD < $CONFIGS_TEMPLATE/fdisksettings #1> /dev/null 3> /dev/null || die - - read -} + # only add this for grub legacy, grub2 detect these settings on its own + export GRUBLEGACYOPTS="rootdelay=8" + # there are two zotac types in the wild, nvidia based gfx and intel + if [[ ! -z $(echo "${hwinfo}" | grep -i nouveau) ]] + then + export SPECIALDEVICE="zotac_nvidia" + else + export SPECIALDEVICE="zotac_intel" + fi + fi -setup_hdd_format() { - mkswap $SWAPHDD || die - mke2fs -j -q $BOOTHDD || die - mke2fs -j -q $ROOTHDD || die -} + # check for special devices/clients: + # if a rangee and disk ist smaller then 256mb move partion one block further ahead + if [[ ! -z $(echo "${hwinfo}" | grep -i CLE266) ]] + then + # for a rangee always define partion startblock +1 + export FDISKPARTIONBELOW256MB="1" + export SPECIALDEVICE="rangee" + export GRUBLEGACYOPTS="" + fi -install_mount_rootfs() { - swapon $SWAPHDD || die - mount $ROOTHDD $INSTALLPATH || die - install -d $INSTALLPATH/boot || die - mount $BOOTHDD $INSTALLPATH/boot || die - cd $INSTALLPATH || die -} + # check for special devices/clients: + # check for maxdata / i810/ i815 Chipsets and disable KMS and use i810fb frambuffer + if [[ ! -z $(echo "${hwinfo}" | grep -i i810) ]] || [[ ! -z $(echo "${hwinfo}" | grep -i i815) ]] + then + export SPECIALDEVICE="maxdata" + export GRUBLEGACYOPTS="" + fi -install_system_image() { - #tar xvzpf $CDPATH/system/autosta_lx.tar.gz - tar xvjpf ${CDPATH}/system/${CDIMAGENAME} -C ${INSTALLPATH} -} + # check for i845 Chipsets and disable KMS and use 915 drm driver + if [[ ! -z $(echo "${hwinfo}" | grep -i i845) ]] + then + export SPECIALDEVICE="i845" + # unset default video=1024x768 opt or the drm driver breaks + export KERNELOPTS="quiet" + export GRUBLEGACYOPTS="" + # enable full kms support + export GRUB2GFXPAYLOAD="keep" + fi + # check for radeon gfxcards + if [[ ! -z $(echo "${hwinfo}" | grep -i radeon) ]] + then + # enable full kms support + export GRUB2GFXPAYLOAD="keep" + fi -install_kernel_image() { - declare -i CPUTYPE=`cat /proc/cpuinfo |grep "cpu family"|cut -d ' ' -f3` + # check for special devices/clients: + # check for laptops and activate cpufreq scaling + if [[ $(echo "${hwinfo}" | grep 'Formfactor:' | sed 's:.*Formfactor\:\ \"\(.*\)\":\1:') = laptop ]] + then + export FORMFACTOR="laptop" + export KERNELOPTS="${KERNELOPTS} cpufreq.governor=ondemand" + fi +} - if [ $CPUTYPE -le 5 ];then - #echo -e "\033[1;6m\033[36m""i386 Architektur gefunden.""\033[0m" - #echo -e "Installiere i386 Kernel..." +run_hardware_detection_disks() +{ + local bootdev - lastdir="`pwd`" + # all disks but exclude ramdisks + export ALL_DISKS=$(get_hwinfo disk | sed '/\/dev\/ram[0-9].*/d') + # remove the boot device from ALL_DISKS if it was an usbstick + if [[ $(grep '[[:space:]]/mnt/cdrom[[:space:]]' /proc/mounts | cut -d' ' -f3) != iso9660 ]] + then + bootdev="$(grep '[[:space:]]/mnt/cdrom[[:space:]]' /proc/mounts | cut -d' ' -f1 | sed 's:[0-9]::g')" + export ALL_DISKS=$(echo "${ALL_DISKS}" | grep -v "${bootdev}") + fi + export ALL_CDROMS="$(get_hwinfo cdrom)" +} - mkdir -p $INSTALLPATH/INSTALL/kernel || die - cd $INSTALLPATH/INSTALL/kernel || die - tar xzpf $CDPATH/kernels/kernel-i386.tar.gz || die - source $INSTALLPATH/INSTALL/kernel/kernelversion || die +hdd_size_below_256mb() +{ + local hdd="$1" + local size + local retval + [[ -z ${hdd} ]] && die "Error: get_hdd_size() no \$hdd given!" - cp -aRf $INSTALLPATH/INSTALL/kernel/$KRNLIB $INSTALLPATH/lib/modules || die - cp -aRf $INSTALLPATH/INSTALL/kernel/$KRNIMG $INSTALLPATH/boot || die - cp -aRf $INSTALLPATH/INSTALL/kernel/$KRNINITRD $INSTALLPATH/boot || die - cp -aRf $INSTALLPATH/INSTALL/kernel/kernelversion $INSTALLPATH/boot || die + size=$(fdisk -l ${hdd} | grep "Disk.*${hdd}" | sed 's:.*,\ \(.*\)\ byte.*:\1:') + if [[ ${size} -le 257000000 ]] + then + retval="0" + else + retval="1" + fi - cd $lastdir || die + return "${retval}" +} - elif [ $CPUTYPE -ge 6 ];then - #echo -e "\033[1;6m\033[36m""i686 Architektur gefunden.""\033[0m" - #echo -e "Installiere i686 Kernel..." +setup_hdd_partitions() +{ + case "${INSTALL_METHOD}" in + normal) + BOOTHDD="${HDD}1" + SWAPHDD="${HDD}2" + ROOTHDD="${HDD}3" + ;; - lastdir="`pwd`" + single|auto) + BOOTHDD="" + SWAPHDD="" + ROOTHDD="${HDD}1" + ;; + esac - mkdir -p $INSTALLPATH/INSTALL/kernel || die - cd $INSTALLPATH/INSTALL/kernel || die - tar xzpf $CDPATH/kernels/kernel-i686.tar.gz || die - source $INSTALLPATH/INSTALL/kernel/kernelversion || die + if [[ ${INSTALL_METHOD} = auto ]] + then + # run this only if FDISKPARTITIONBELOW256MB is not already 1 + if [[ ${FDISKPARTIONBELOW256MB} != 1 ]] + then + if hdd_size_below_256mb ${HDD} + then + FDISKPARTIONBELOW256MB=1 + else + FDISKPARTIONBELOW256MB=0 + fi + fi - cp -aRf $INSTALLPATH/INSTALL/kernel/$KRNLIB $INSTALLPATH/lib/modules || die - cp -aRf $INSTALLPATH/INSTALL/kernel/$KRNIMG $INSTALLPATH/boot || die - cp -aRf $INSTALLPATH/INSTALL/kernel/$KRNINITRD $INSTALLPATH/boot || die - cp -aRf $INSTALLPATH/INSTALL/kernel/kernelversion $INSTALLPATH/boot || die + ## delete disk + dd if=/dev/zero of=${HDD} count=1 &> /dev/null || die - cd $lastdir || die - fi + if [[ ${FDISKPARTIONBELOW256MB} = 1 ]] + then + ## setup one bootable partition + #1. n= new disk + #2. p= primary disk + #3. 1= first partition + #4. 2= default sector start // small disk needs more space for grub2 mbr sector + #5. ''= defaul sector end + #6. a= bootable flag + #7. 1= boot flag for partition 1 + #8. w= write/quit + fdisk ${HDD} &> /dev/null << EOF +n +p +1 +2 + +a +1 +w +EOF + else + ## setup one bootable partition + #1. n= new disk + #2. p= primary disk + #3. 1= first partition + #4. ''= default sector start + #5. ''= defaul sector end + #6. a= bootable flag + #7. 1= boot flag for partition 1 + #8. w= write/quit + fdisk ${HDD} &> /dev/null << EOF +n +p +1 + + +a +1 +w +EOF + fi + else + ## hdds partitionieren manuell + cfdisk ${HDD} || die + fi } -install_bootsector() { - ### grubconf schreiben - source $INSTALLPATH/INSTALL/kernel/kernelversion - - if [ -z $KRNVER ] +setup_hdd_format() +{ + if [[ -n ${SWAPHDD} ]] then - KRNVER="AutoSta_LX" + mkswap ${SWAPHDD} || die fi - - if [ -z $KRNIMG ] + if [[ -n ${BOOTHDD} ]] then - KRNIMG="bzImage" + mkfs.${FORMAT_FILESYSTEM} -q ${BOOTHDD} || die fi - - if [ -z $KRNINITRD ] + if [[ -n ${ROOTHDD} ]] then - KRNINITRD="initrd" + mkfs.${FORMAT_FILESYSTEM} -q ${ROOTHDD} || die fi - - echo -e "default 0" > $INSTALLPATH/boot/grub/grub.conf || die - echo -e "timeout 03" >> $INSTALLPATH/boot/grub/grub.conf ||die - #no support for splash image in 6.1-r2 - #echo -e "splashimage=(hd0,0)/boot/grub/splash.xpm.gz" >> $INSTALLPATH/boot/grub/grub.conf || die - echo -e "\ntitle=${KRNVER}" >> $INSTALLPATH/boot/grub/grub.conf || die - echo -e "root (hd0,0)" >> $INSTALLPATH/boot/grub/grub.conf || die - - #s3 cards don't support this - #echo -e "kernel (hd0,0)/boot/${KRNIMG} root=$ROOTHDD vga=0x317 video:vesa:ywrap,mtrr splash=silent quiet" >> $INSTALLPATH/boot/grub/grub.conf || die - #that's more safer: - echo -e "kernel (hd0,0)/boot/${KRNIMG} root=$ROOTHDD quiet" >> $INSTALLPATH/boot/grub/grub.conf || die - - #not needed without bootsplash support - #echo -e "initrd=/boot/${KRNINITRD}" >> $INSTALLPATH/boot/grub/grub.conf || die - - ### bootsector schreiben - #grub --no-floppy < $CONFIGS_TEMPLATE/grubsettings || die - /sbin/grub --no-floppy --batch << "EOF" 1> /dev/null 2> /dev/null || die -root (hd0,0) -setup (hd0) -quit -EOF } -install_bootsector_chroot() { - ### grubconf schreiben - #source $INSTALLPATH/INSTALL/kernel/kernelversion - source $INSTALLPATH/boot/kernelversion - - #for alx only - if [ -e ${INSTALLPATH}/etc/alx_version ] +install_mount_rootfs() +{ + if [[ -n ${SWAPHDD} ]] then - OLD_ALXVER="${ALXVER}" - source ${INSTALLPATH}/etc/alx_version - KRNVER="ALX-${ALXVER}" - ALXVER="${OLD_ALXVER}" + swapon ${SWAPHDD} || die fi - - if [ -z "$KRNVER" ] + if [[ -n ${ROOTHDD} ]] then - KRNVER="AutoSta_LX" + mount ${ROOTHDD} ${INSTALL_ROOT} || die fi - - if [ -z "$KRNIMG" ] + if [[ -n ${BOOTHDD} ]] then - KRNIMG="bzImage" + install -d ${INSTALL_ROOT}/boot || die + mount ${BOOTHDD} ${INSTALL_ROOT}/boot || die fi - if [ -z "$KRNINITRD" ] - then - KRNINITRD="initrd" - fi + cd ${INSTALL_ROOT} || die +} - echo -e "default 0" > $INSTALLPATH/boot/grub/grub.conf || die - echo -e "timeout 0" >> $INSTALLPATH/boot/grub/grub.conf ||die - - #no support for splash image in 6.1-r2 - #echo -e "splashimage=(hd0,0)/boot/grub/splash.xpm.gz" >> $INSTALLPATH/boot/grub/grub.conf || die - - echo -e "\ntitle=${KRNVER}" >> $INSTALLPATH/boot/grub/grub.conf || die - echo -e "root (hd0,0)" >> $INSTALLPATH/boot/grub/grub.conf || die - - #s3 cards don't support this - #echo -e "kernel (hd0,0)/boot/${KRNIMG} root=$ROOTHDD vga=0x317 video:vesa:ywrap,mtrr splash=silent quiet" >> $INSTALLPATH/boot/grub/grub.conf || die - #that's more safer: - echo -e "kernel (hd0,0)/boot/${KRNIMG} root=$ROOTHDD quiet" >> $INSTALLPATH/boot/grub/grub.conf || die - - #not needed without bootsplash support - #echo -e "initrd=/boot/${KRNINITRD}" >> $INSTALLPATH/boot/grub/grub.conf || die +install_system_image() +{ + tar xvjpf ${CDPATH}/system/${CDIMAGENAME} -C ${INSTALL_ROOT} +} +install_bootsector_chroot() +{ + local my_roothdd + local grubconf=${INSTALL_ROOT}/boot/grub/grub.conf + local grub2conf=/boot/grub/grub.cfg + local CONFIG - ### bootsector schreiben chrooted schreiben (gentoo) - if [ -f $INSTALLPATH/sbin/grub ] + # check for grub2 + if [[ -f ${INSTALL_ROOT}/sbin/grub-mkconfig ]] then - cat > $INSTALLPATH/root/.bashrc << CHROOTEOF -/sbin/grub --no-floppy --batch << "EOF" 1> /dev/null 2> /dev/null -root (hd0,0) -setup (hd0) -quit -EOF -exit 0 -CHROOTEOF - fi + # needed by grub-mkconfig on the first run + if [[ ! -f ${INSTALL_ROOT}/boot/grub/video.lst ]] + then + install -m0644 ${INSTALL_ROOT}/lib/grub/*/video.lst ${INSTALL_ROOT}/boot/grub/video.lst || die + fi + + # set kernelopts + if [[ -f ${INSTALL_ROOT}/etc/conf.d/grub ]] + then + sed -i "s:^\(export GRUB_CMDLINE_LINUX_DEFAULT=\).*:\1\"${KERNELOPTS}\":" ${INSTALL_ROOT}/etc/conf.d/grub || die + sed -i "s:^\(export GRUB_GFXPAYLOAD_LINUX=\).*:\1\"${GRUB2GFXPAYLOAD}\":" ${INSTALL_ROOT}/etc/conf.d/grub || die + else + echo "export GRUB_CMDLINE_LINUX_DEFAULT=\"${KERNELOPTS}\"" > ${INSTALL_ROOT}/etc/conf.d/grub || die + echo "export GRUB_GFXPAYLOAD_LINUX=\"${GRUB2GFXPAYLOAD}\"" >> ${INSTALL_ROOT}/etc/conf.d/grub || die + fi + CONFIG=${INSTALL_ROOT}/.installrc + clearconfig + addconfig 'grub-mkdevicemap' + addconfig "LC_ALL=C grub-mkconfig -o ${grub2conf} &> /dev/null" + addconfig "grub-install --no-floppy ${HDD} &> /dev/null" + addconfig "exit 0" + + # grub-legacy + else + ### grubconf schreiben + source ${INSTALL_ROOT}/boot/kernelversion - ### bootsector schreiben chrooted schreiben (lfs/magellan) - if [ -f $INSTALLPATH/usr/sbin/grub ] + #for alx only + if [ -e ${INSTALL_ROOT}/etc/alx_version ] + then + OLD_ALXVER="${ALXVER}" + source ${INSTALL_ROOT}/etc/alx_version + KRNVER="ALX-${ALXVER}" + ALXVER="${OLD_ALXVER}" + fi + + [[ -z ${KRNVER} ]] && KRNVER="AutoSta_LX" + [[ -z ${KRNINITRD} ]] && KRNINITRD="initrd" + [[ -z ${KRNIMG} ]] && KRNIMG="vmlinuz" + + # uuid support + if is_uuid_supported + then + my_roothdd="UUID=$(get_uuid ${ROOTHDD})" + else + my_roothdd="${ROOTHDD}" + fi + + CONFIG="${grubconf}" + clearconfig + addconfig "default 0" + addconfig "timeout 3" + # using current root password + addconfig "password --md5 $(cat ${INSTALL_ROOT}/etc/shadow | grep root | cut -d: -f2)" + addconfig + addconfig "# normal boot" + addconfig "title ${KRNVER}" + addconfig "root (hd0,0)" + addconfig "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS}" + if is_initrd_supported + then + addconfig "initrd /boot/${KRNINITRD}" + fi + addconfig + addconfig "# admin boot" + addconfig "title ${KRNVER} - Re-run hardware-detection" + addconfig "lock" + addconfig "root (hd0,0)" + addconfig "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS} hardware-auto-detection" + if is_initrd_supported + then + addconfig "initrd /boot/${KRNINITRD}" + fi + addconfig + addconfig "title ${KRNVER} - Reset *all* local settings" + addconfig "lock" + addconfig "root (hd0,0)" + addconfig "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS} alx-reset-settings" + if is_initrd_supported + then + addconfig "initrd /boot/${KRNINITRD}" + fi + + # write bootsector chrooted (lfs/magellan) + CONFIG=${INSTALL_ROOT}/.installrc + clearconfig + addconfig '/usr/sbin/grub --no-floppy --batch << "EOF" 1> /dev/null 2> /dev/null' + addconfig 'root (hd0,0)' + addconfig 'setup (hd0)' + addconfig 'quit' + addconfig 'EOF' + addconfig 'exit 0' + fi + + ## enter chroot + enter_chroot_installrc +} + +is_initrd_supported() +{ + # only generate initrds if the cmd exists + [[ -x ${INSTALL_ROOT}/sbin/mkinitrd ]] && return 0 + return 1 +} + +install_initrd_chroot() +{ + local CONFIG + + # only generate initrds if the cmd exists + is_initrd_supported || return 0 + + DISKMODS="sd_mod" + OLDPATAMODS="amd74xx piix sis5513 via82cxxx" + PATAMODS="ata_piix pata_amd pata_mpiix pata_oldpiix pata_sis pata_via" + SATAMODS="sata_via sata_sis sata_nv" + DRMMODS="i915 mga nouveau r128 radeon savage sis tdfx ttm via" + OTHERMODS="" + case ${SPECIALDEVICE} in + zotac_intel|i845) FBMODS=""; DRMMODS="i915" ;; + zotac_nvidia) FBMODS=""; DRMMODS="nouveau" ;; + rangee) FBMODS="" ;; ## fallback to vesafb, viafb does not run on all CLE266 boards + # not working with kms enabled drivers -> segfaults + #maxdata) FBMODS="i810fb" ;; ## check for maxdata / i810/ i815 Chipsets and disable KMS and use i810fb frambuffer + maxdata) FBMODS="" ;; + *) FBMODS="uvesafb" ;; + esac + + if [[ ${FORMFACTOR} = laptop ]] + then + OTHERMODS="acpi-cpufreq cpufreq_ondemand cpufreq_conservative cpufreq_powersave" + fi + + # install an appropriate uvesafb.conf + CONFIG=${INSTALL_ROOT}/etc/modprobe.d/uvesafb.conf + clearconfig + addconfig "options uvesafb mode_option=1024x768-32@60 scroll=ywrap" + + # install an appropriate viafb.conf + CONFIG=${INSTALL_ROOT}/etc/modprobe.d/viafb.conf + clearconfig + addconfig "options viafb viafb_mode=1024x768 viafb_refresh=60" + + # install an appropriate i810fb.conf + CONFIG=${INSTALL_ROOT}/etc/modprobe.d/i810fb.conf + clearconfig + addconfig "options i810fb xres=1024 yres=768 bpp=16 mtrr=1 hsync1=30 hsync2=62 vsync1=30 vsync2=60" + + CONFIG=${INSTALL_ROOT}/.installrc + clearconfig + addconfig 'echo "MODULES=\"${FORMAT_FILESYSTEM} ${DISKMODS} ${OLDATAMODS} ${PATAMODS} ${SATAMODS} ${DRMMODS} ${FBMODS} ${OTHERMODS}\"" > /etc/conf.d/mkinitrd' + addconfig 'mkinitrd -f /boot/$(readlink /boot/initrd) $(readlink /boot/vmlinuz | sed "s:kernel-::g") > /dev/null' + addconfig 'exit 0' + ## enter chroot + enter_chroot_installrc +} + +is_uuid_supported() +{ + if [[ -x $(which busybox.mkinitrd &> /dev/null) ]] then - cat > $INSTALLPATH/root/.bashrc << CHROOTEOF -/usr/sbin/grub --no-floppy --batch << "EOF" 1> /dev/null 2> /dev/null -root (hd0,0) -setup (hd0) -quit -EOF -exit 0 -CHROOTEOF + # only detect uuids if supported + if [[ ! -z $(busybox.mkinitrd | grep blkid) ]] + then + return 0 + fi fi - ##enters chroot - mount -t proc none $INSTALLPATH/proc - # bind /dev to get the devices right, - # if bootet from a 2.6 kernel with udev - mount -o bind /dev $INSTALLPATH/dev - chroot $INSTALLPATH /bin/bash --rcfile /root/.bashrc -i - umount $INSTALLPATH/proc - umount $INSTALLPATH/dev - rm $INSTALLPATH/root/.bashrc + return 1 } -install_alxconfig(){ - lastdir="`pwd`" +get_uuid() +{ + local UUID + local SEC_TYPE + local TYPE - mkdir -p $INSTALLPATH/opt/alx-config || die - cd $INSTALLPATH/opt/alx-config || die - tar xzpf $CDPATH/alx-config/alx-config.tar.gz || die - chmod a+x $INSTALLPATH/opt/alx-config/Configurator/config_functions.sh || die - chmod a+x $INSTALLPATH/opt/alx-config/Configurator/config_menu.sh || die - ln -sf /opt/alx-config/Configurator/config_menu.sh $INSTALLPATH/bin/ALXConfig || die + local dev="$1" + [[ -z ${dev} ]] && die "no dev given" - cd $lastdir || die + # check if given device is already an UUID + if [[ ${dev/UUID=/}x != ${dev}x ]] + then + eval "${dev}" + else + eval $(busybox.mkinitrd blkid ${dev} | grep "${dev}:" | sed 's/.*:\ //') + fi + echo "${UUID}" } +install_system_settings() +{ + # schreibe fstab + if is_uuid_supported + then + if [[ -n ${BOOTHDD} ]] + then + echo -e "UUID=$(get_uuid ${BOOTHDD})\t/boot\t${FORMAT_FILESYSTEM}\tnoatime,noauto\t1 1" > ${INSTALL_ROOT}/etc/fstab || die + fi + if [[ -n ${ROOTHDD} ]] + then + echo -e "UUID=$(get_uuid ${ROOTHDD})\t/\t${FORMAT_FILESYSTEM}\tnoatime\t0 0" >> ${INSTALL_ROOT}/etc/fstab || die + fi + else + if [[ -n ${BOOTHDD} ]] + then + echo -e "${BOOTHDD}\t/boot\t${FORMAT_FILESYSTEM}\tnoatime,noauto\t1 1" > ${INSTALL_ROOT}/etc/fstab || die + fi + if [[ -n ${ROOTHDD} ]] + then + echo -e "${ROOTHDD}\t/\t${FORMAT_FILESYSTEM}\tnoatime\t0 0" >> ${INSTALL_ROOT}/etc/fstab || die + fi + fi + # not needed busybox loads all with swapon -a, even if not mentioned in fstab + #echo -e "UUID='$(get_uuid ${SWAPHDD})'\tswap\tswap\tpri=1\t0 0" >> ${INSTALL_ROOT}/etc/fstab || die + echo -e "proc\t/proc\tproc\tdefaults\t0 0" >> ${INSTALL_ROOT}/etc/fstab || die + echo -e "shm\t/dev/shm\ttmpfs\tdefaults\t0 0" >> ${INSTALL_ROOT}/etc/fstab || die -install_system_settings(){ - ### schreibe fstab - echo -e "$BOOTHDD\t/boot\text3\tnoatime,noauto\t1 1" > $INSTALLPATH/etc/fstab || die - echo -e "$ROOTHDD\t/\text3\tnoatime\t0 0" >> $INSTALLPATH/etc/fstab || die - echo -e "$SWAPHDD\tswap\tswap\tpri=1\t0 0" >> $INSTALLPATH/etc/fstab || die - echo -e "none\t/proc\tproc\tdefaults\t0 0" >> $INSTALLPATH/etc/fstab || die - - #deprecated - #echo -e "devpts\t/dev/pts\tdevpts\tgid=4,mode=620\t0 0" >> $INSTALLPATH/etc/fstab || die - - echo -e "none\t/dev/shm\ttmpfs\tdefaults\t0 0" >> $INSTALLPATH/etc/fstab || die - echo -e "none\t/proc/bus/usb\tusbfs\tdefaults\t0 0" >> $INSTALLPATH/etc/fstab || die -} + # install network config skeleton + install -m0644 ${INSTALL_ROOT}/etc/alxconfig-ng/skel/net/net.eth0 ${INSTALL_ROOT}/etc/conf.d/ || die -install_hotfixes(){ - if [ -f $CDPATH/hotfixes/hotfixes.sh ] + # intel framebufer quirk + if [[ -e /proc/fb ]] then - dialog_hotfixes - sleep1 - $CDPATH/hotfixes/hotfixes.sh + if [[ ! -z $(grep 'inteldrmfb' /proc/fb) ]] + then + fbdev=$(grep 'inteldrmfb' /proc/fb | sed 's:\([0-9]\).*:\1:') + if [[ ${fbdev} != 0 ]] + then + sed -i "s:^\(SPLASH_DEV=\).*:\1\"/dev/fb${fbdev}\":" ${INSTALL_ROOT}/etc/splash/splash.conf || die + fi + fi fi } -install_umount_rootfs() { +install_umount_rootfs() +{ cd / - umount $INSTALLPATH/boot || die - umount $INSTALLPATH || die - swapoff $SWAPHDD || die + if [[ -n ${BOOTHDD} ]] + then + umount ${INSTALL_ROOT}/boot || die + fi + if [[ -n ${ROOTHDD} ]] + then + umount ${INSTALL_ROOT} || die + fi + if [[ -n ${SWAPHDD} ]] + then + swapoff ${SWAPHDD} || die + fi } -install_do_reboot() { - - #only for now later it will be used again - #with 6.1-r2 these options are not available - #cd / - #umount $CDPATH - #eject - #clear - +install_do_reboot() +{ reboot } ################################################# -# Install Ablauf Scripte # +# Install Main Scripts # ################################################# -run_install_normal() { - #only for now later it will be used again - #with 6.1-r2 only one install method available - #dialog_setup_hdd_menu - dialog_setup_hdd_found_manuell - - dialog_setup_hdd_partitions_manuell +run_install() +{ + local method="$1" + + # setup install environment + export KERNELOPTS="${DEFAULT_KERNELOPTS}" + export GRUBLEGACYOPTS="${GRUBLEGACYOPTS}" + export GRUB2OPTS="${GRUB2OPTS}" + export GRUB2GFXPAYLOAD="${DEFAULT_GRUB2GFXPAYLOAD}" + export FORMFACTOR="${DEFAULT_FORMFACTOR}" + export FORMAT_FILESYSTEM="${DEFAULT_FORMAT_FILESYSTEM}" + + case "${method}" in + auto) + export INSTALL_METHOD="${method}" + ;; + normal) + export INSTALL_METHOD="${method}" + ;; + single) + export INSTALL_METHOD="${method}" + ;; + *) + echo "Unknown install method '${method}', aborting." + exit 1 + ;; + esac + + dialog_hardware_detection + + dialog_setup_hdd_partitions dialog_setup_hdd_format setup_hdd_format > /dev/null install_mount_rootfs (install_system_image > /tmp/install.log) 2> /tmp/install_errors.log | dialog_install_meter | dialog_install_system_image - - #only for now later it will be used again - #with 6.1-r2 variable kernels are not available - #dialog_install_kernel_image - #install_kernel_image - - dialog_install_bootsector - install_bootsector_chroot - - #only for now later it will be used again - #with 6.1-r2 highest version of alx-config is already included - #dialog_install_alxconfig - #sleep 1 - #install_alxconfig - + dialog_install_settings sleep 1 install_system_settings - install_hotfixes + install_initrd_chroot + + dialog_install_bootsector + install_bootsector_chroot + install_umount_rootfs dialog_install_successful } -run_install_silent() { - echo "starting silent install ..." - sleep 1 -} - -run_install_unattended() { - echo "starting unattended install ..." - sleep 1 -} +# set some proper traps +trap "trap_exit" SIGINT SIGQUIT -if [ "$1" == "unattended" ] -then - run_install_unattended -else - dialog_main -fi +dialog_main exit 0