--- alx-src/trunk/alxinstall-ng/bin/alxinstall-ng.sh.in 2015/07/23 08:53:26 6819 +++ alx-src/trunk/alxinstall-ng/bin/alxinstall-ng.sh.in 2015/07/23 12:04:49 6831 @@ -10,36 +10,45 @@ source /mnt/cdrom/system/images.conf # includes +source ${MLIBDIR}/functions/generic.sh source ${MLIBDIR}/functions/hwdetection.sh ### System/Config Version -VERSION="%VERSIONTAG%" +VERSION="@@VERSION@@" TITLE="alxinstall-ng - ${VERSION}" +# locations CDPATH="/mnt/cdrom" INSTALLPATH="/mnt/magellan" -### linecount of system.tar.gz -1 ! -CURRENTLINE=0 -#TOTALLINES=11072 # -> now in images.conf - +# default system settings # standard kernel opts -KERNELOPTS="quiet video=1024x768" +DEFAULT_KERNELOPTS="quiet video=1024x768" # grub options -GRUBLEGACYOPTS="" -GRUB2OPTS="" -GRUB2GFXPAYLOAD="1024x768x16,1024x768" - -# fdisk options -FDISKPARTIONBELOW256MB=0 +DEFAULT_GRUBLEGACYOPTS="" +DEFAULT_GRUB2OPTS="" +DEFAULT_GRUB2GFXPAYLOAD="1024x768x16,1024x768" # default specialdevices -SPECIALDEVICE="" -FORMFACTOR="desktop" +DEFAULT_FORMFACTOR="desktop" # target filesystem -FORMAT_FILESYSTEM="ext4" +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 BOXES # @@ -50,6 +59,7 @@ ERROR=$1 RETVAL=$? dialog_install_failure + trap_exit exit 1 } @@ -73,6 +83,18 @@ 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 \ @@ -87,7 +109,7 @@ Bitte ${SHDD}1 als \Z3bootable\Zn markieren." 12 81 } -dialog_setup_hdd_info_simple() +dialog_setup_hdd_info_single() { local SHDD="$(echo $HDD | sed 's/\/dev\///')" @@ -130,15 +152,15 @@ "" "" \ "" "\Z1Experten Modi:\Zn" \ "2" "Normale IDE-Disk (Manuell)" \ - "3" "Flash-Speicher (Manuell)") + "3" "Normale IDE Disk (Single)") RES=$? [[ ${RES} -eq 1 ]] && return 1 if [[ ${RES} -eq 0 ]] then case "${i}" in - "1") run_install_auto ;; - "2") run_install_normal ;; - "3") run_install_simple ;; + "1") run_install auto ;; + "2") run_install normal ;; + "3") run_install single ;; "") dialog_setup_system_menu;; esac fi @@ -209,7 +231,7 @@ fi } -dialog_setup_hdd_partitions_manuell() +dialog_setup_hdd_partitions() { local i @@ -242,84 +264,7 @@ if [[ ${RES} -eq 0 ]] then dialog_setup_hdd_info - setup_hdd_partitions_manuell - fi - fi -} - -dialog_setup_hdd_partitions_manuell_simple() -{ - local i - - if [[ -z ${ALL_DISKS} ]] - then - dialog \ - --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 "--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 ${ALL_DISKS} - do - echo "\"${i}\" \"\" \\" >> /tmp/hddtmp.sh - done - echo -e "\n" >> /tmp/hddtmp.sh - - chmod a+x /tmp/hddtmp.sh - HDD="$(/tmp/hddtmp.sh)" - RES=$? - [[ ${RES} -eq 1 ]] && return 1 - if [[ ${RES} -eq 0 ]] - then - dialog_setup_hdd_info_simple - setup_hdd_partitions_manuell_simple - fi - fi -} - -dialog_setup_hdd_partitions_auto() -{ - local i - - if [[ -z ${ALL_DISKS} ]] - then - dialog \ - --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 "--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 ${ALL_DISKS} - do - echo "\"${i}\" \"\" \\" >> /tmp/hddtmp.sh - done - echo -e "\n" >> /tmp/hddtmp.sh - - chmod a+x /tmp/hddtmp.sh - HDD="$(/tmp/hddtmp.sh)" - RES=$? - [[ ${RES} -eq 1 ]] && return 1 - if [[ ${RES} -eq 0 ]] - then - dialog_setup_hdd_info_auto - dialog_setup_hdd_create_partitions - setup_hdd_partitions_auto + setup_hdd_partitions fi fi } @@ -365,7 +310,6 @@ return 0 } - dialog_install_bootsector() { dialog \ @@ -427,7 +371,6 @@ run_hardware_detection() { local hwinfo - hwinfo="$(hwinfo --bios --storage --pci --gfxcard --sys)" # check for special devices/clients: @@ -532,36 +475,50 @@ return "${retval}" } -setup_hdd_partitions_auto() +setup_hdd_partitions() { - ROOTHDD="${HDD}1" + case "${INSTALL_METHOD}" in + normal) + BOOTHDD="${HDD}1" + SWAPHDD="${HDD}2" + ROOTHDD="${HDD}3" + ;; + + single|auto) + BOOTHDD="" + SWAPHDD="" + ROOTHDD="${HDD}1" + ;; + esac - # run this only if FDISKPARTITIONBELOW256MB is not already 1 - if [[ ${FDISKPARTIONBELOW256MB} != 1 ]] + if [[ ${INSTALL_METHOD} = auto ]] then - if hdd_size_below_256mb ${HDD} + # run this only if FDISKPARTITIONBELOW256MB is not already 1 + if [[ ${FDISKPARTIONBELOW256MB} != 1 ]] then - FDISKPARTIONBELOW256MB=1 - else - FDISKPARTIONBELOW256MB=0 + if hdd_size_below_256mb ${HDD} + then + FDISKPARTIONBELOW256MB=1 + else + FDISKPARTIONBELOW256MB=0 + fi fi - fi - ## delete disk - dd if=/dev/zero of=${HDD} count=1 &> /dev/null || die + ## delete disk + dd if=/dev/zero of=${HDD} count=1 &> /dev/null || die - 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 + 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 @@ -571,17 +528,17 @@ 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 + 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 @@ -591,52 +548,45 @@ 1 w EOF + fi + else + ## hdds partitionieren manuell + cfdisk ${HDD} || die fi } -setup_hdd_partitions_manuell() -{ - BOOTHDD="${HDD}1" - SWAPHDD="${HDD}2" - ROOTHDD="${HDD}3" - - ## hdds partitionieren manuell - cfdisk ${HDD} || die -} - -setup_hdd_partitions_manuell_simple() -{ - ROOTHDD="${HDD}1" - - ## hdds partitionieren manuell - cfdisk ${HDD} || die -} - setup_hdd_format() { - mkswap ${SWAPHDD} || die - mke2fs -j -q ${BOOTHDD} || die - mke2fs -j -q ${ROOTHDD} || die -} - -setup_hdd_format_simple() -{ - mke2fs -j -q ${ROOTHDD} || die + if [[ -n ${SWAPHDD} ]] + then + mkswap ${SWAPHDD} || die + fi + if [[ -n ${BOOTHDD} ]] + then + mkfs.${FORMAT_FILESYSTEM} -q ${BOOTHDD} || die + fi + if [[ -n ${ROOTHDD} ]] + then + mkfs.${FORMAT_FILESYSTEM} -q ${ROOTHDD} || die + fi } install_mount_rootfs() { - swapon ${SWAPHDD} || die - mount ${ROOTHDD} ${INSTALLPATH} || die - install -d ${INSTALLPATH}/boot || die - mount ${BOOTHDD} ${INSTALLPATH}/boot || die - cd ${INSTALLPATH} || die -} + if [[ -n ${SWAPHDD} ]] + then + swapon ${SWAPHDD} || die + fi + if [[ -n ${ROOTHDD} ]] + then + mount ${ROOTHDD} ${INSTALLPATH} || die + fi + if [[ -n ${BOOTHDD} ]] + then + install -d ${INSTALLPATH}/boot || die + mount ${BOOTHDD} ${INSTALLPATH}/boot || die + fi -install_mount_rootfs_simple() -{ - mount ${ROOTHDD} ${INSTALLPATH} || die - install -d ${INSTALLPATH}/boot || die cd ${INSTALLPATH} || die } @@ -768,6 +718,8 @@ install_initrd_chroot() { + local CONFIG + # only generate initrds if the cmd exists is_initrd_supported || return 0 @@ -793,14 +745,19 @@ fi # install an appropriate uvesafb.conf - install -d ${INSTALLPATH}/etc/modprobe.d || die - echo "options uvesafb mode_option=1024x768-32@60 scroll=ywrap" > ${INSTALLPATH}/etc/modprobe.d/uvesafb.conf || die + CONFIG=${INSTALLPATH}/etc/modprobe.d/uvesafb.conf + clearconfig + addconfig "options uvesafb mode_option=1024x768-32@60 scroll=ywrap" # install an appropriate viafb.conf - echo "options viafb viafb_mode=1024x768 viafb_refresh=60" > ${INSTALLPATH}/etc/modprobe.d/viafb.conf || die + CONFIG=${INSTALLPATH}/etc/modprobe.d/viafb.conf + clearconfig + addconfig "options viafb viafb_mode=1024x768 viafb_refresh=60" # install an appropriate i810fb.conf - 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 + CONFIG=${INSTALLPATH}/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" cat > ${INSTALLPATH}/root/.installrc << CHROOTEOF echo "MODULES=\"${FORMAT_FILESYSTEM} ${DISKMODS} ${OLDATAMODS} ${PATAMODS} ${SATAMODS} ${DRMMODS} ${FBMODS} ${OTHERMODS}\"" > /etc/conf.d/mkinitrd @@ -857,11 +814,23 @@ # schreibe fstab if is_uuid_supported then - echo -e "UUID=$(get_uuid ${BOOTHDD})\t/boot\t${FORMAT_FILESYSTEM}\tnoatime,noauto\t1 1" > ${INSTALLPATH}/etc/fstab || die - echo -e "UUID=$(get_uuid ${ROOTHDD})\t/\t${FORMAT_FILESYSTEM}\tnoatime\t0 0" >> ${INSTALLPATH}/etc/fstab || die + if [[ -n ${BOOTHDD} ]] + then + echo -e "UUID=$(get_uuid ${BOOTHDD})\t/boot\t${FORMAT_FILESYSTEM}\tnoatime,noauto\t1 1" > ${INSTALLPATH}/etc/fstab || die + fi + if [[ -n ${ROOTHDD} ]] + then + echo -e "UUID=$(get_uuid ${ROOTHDD})\t/\t${FORMAT_FILESYSTEM}\tnoatime\t0 0" >> ${INSTALLPATH}/etc/fstab || die + fi else - echo -e "${BOOTHDD}\t/boot\t${FORMAT_FILESYSTEM}\tnoatime,noauto\t1 1" > ${INSTALLPATH}/etc/fstab || die - echo -e "${ROOTHDD}\t/\t${FORMAT_FILESYSTEM}\tnoatime\t0 0" >> ${INSTALLPATH}/etc/fstab || die + if [[ -n ${BOOTHDD} ]] + then + echo -e "${BOOTHDD}\t/boot\t${FORMAT_FILESYSTEM}\tnoatime,noauto\t1 1" > ${INSTALLPATH}/etc/fstab || die + fi + if [[ -n ${ROOTHDD} ]] + then + echo -e "${ROOTHDD}\t/\t${FORMAT_FILESYSTEM}\tnoatime\t0 0" >> ${INSTALLPATH}/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" >> ${INSTALLPATH}/etc/fstab || die @@ -885,31 +854,21 @@ fi } -install_system_settings_simple() -{ - # write fstab - if is_uuid_supported - then - echo -e "UUID=$(get_uuid ${ROOTHDD})\t/\t${FORMAT_FILESYSTEM}\tnoatime\t0 0" > ${INSTALLPATH}/etc/fstab || die - else - echo -e "${ROOTHDD}\t/\t${FORMAT_FILESYSTEM}\tnoatime\t0 0" > ${INSTALLPATH}/etc/fstab || die - fi - echo -e "proc\t/proc\tproc\tdefaults\t0 0" >> ${INSTALLPATH}/etc/fstab || die - echo -e "shm\t/dev/shm\ttmpfs\tdefaults\t0 0" >> ${INSTALLPATH}/etc/fstab || die -} - install_umount_rootfs() { cd / - umount ${INSTALLPATH}/boot || die - umount ${INSTALLPATH} || die - swapoff ${SWAPHDD} || die -} - -install_umount_rootfs_simple() -{ - cd / - umount ${INSTALLPATH} || die + if [[ -n ${BOOTHDD} ]] + then + umount ${INSTALLPATH}/boot || die + fi + if [[ -n ${ROOTHDD} ]] + then + umount ${INSTALLPATH} || die + fi + if [[ -n ${SWAPHDD} ]] + then + swapoff ${SWAPHDD} || die + fi } install_do_reboot() @@ -921,11 +880,37 @@ # Install Main Scripts # ################################################# -run_install_normal() +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_manuell + dialog_setup_hdd_partitions dialog_setup_hdd_format setup_hdd_format > /dev/null install_mount_rootfs @@ -943,49 +928,8 @@ dialog_install_successful } -run_install_simple() -{ - dialog_hardware_detection - - dialog_setup_hdd_partitions_manuell_simple - dialog_setup_hdd_format - setup_hdd_format_simple > /dev/null - install_mount_rootfs_simple - (install_system_image > /tmp/install.log) 2> /tmp/install_errors.log | dialog_install_meter | dialog_install_system_image - - dialog_install_settings - sleep 1 - install_system_settings_simple - install_initrd_chroot - - dialog_install_bootsector - install_bootsector_chroot - - install_umount_rootfs_simple - dialog_install_successful -} - -run_install_auto() -{ - dialog_hardware_detection - - dialog_setup_hdd_partitions_auto - dialog_setup_hdd_format - setup_hdd_format_simple > /dev/null - install_mount_rootfs_simple - (install_system_image > /tmp/install.log) 2> /tmp/install_errors.log | dialog_install_meter | dialog_install_system_image - - dialog_install_settings - sleep 1 - install_system_settings_simple - install_initrd_chroot - - dialog_install_bootsector - install_bootsector_chroot - - install_umount_rootfs_simple - dialog_install_successful -} +# set some proper traps +trap "trap_exit" SIGINT SIGQUIT dialog_main