--- trunk/installer-simple/bin/installer.sh.in 2014/07/03 08:33:54 2655 +++ trunk/installer-simple/bin/installer.sh.in 2015/07/31 09:54:20 2884 @@ -103,19 +103,43 @@ { local retval - if is_mounted --location "${INSTALLROOT}" + if [[ -n ${SWAPHDD} ]] then - echo $"${INSTALLROOT} already mounted" >&2 - else - mount "${ROOTHDD}" "${INSTALLROOT}" || dialog_die $"Could not mount rootfs - drive '${ROOTHDD}' -> '${INSTALLROOT}'" + swapon ${SWAPHDD} || dialog_die $"Could not enable swap space '${SWAPHDD}'" fi + + if [[ -n ${ROOTHDD} ]] + then + if is_mounted --location "${INSTALLROOT}" + then + echo $"${INSTALLROOT} already mounted" >&2 + else + mount "${ROOTHDD}" "${INSTALLROOT}" || dialog_die $"Could not mount rootfs - drive '${ROOTHDD}' -> '${INSTALLROOT}'" + fi + fi + [[ -d ${INSTALLROOT}/boot ]] || install -d ${INSTALLROOT}/boot + + if [[ -n ${BOOTHDD} ]] + then + if is_mounted --location "${INSTALLROOT}"/boot + then + echo $"${INSTALLROOT}/boot already mounted" >&2 + else + mount "${BOOTHDD}" "${INSTALLROOT}"/boot || dialog_die $"Could not mount bootfs - drive '${BOOTHDD}' -> '${INSTALLROOT}/boot'" + fi + fi } umount_rootfs() { is_mounted --location ${INSTALLROOT}/boot && umount ${INSTALLROOT}/boot is_mounted --location ${INSTALLROOT} && umount ${INSTALLROOT} + + if [[ -n ${SWAPHDD} ]] + then + swapoff ${SWAPHDD} || die + fi } install_do_reboot() @@ -196,9 +220,20 @@ export ALL_CDROMS="$(get_hwinfo cdrom)" } -setup_hdd_partitions_auto() +setup_hdd_partitions() { - ROOTHDD="${HDD}1" + case "${INSTALL_METHOD}" in + auto) + BOOTHDD="" + SWAPHDD="" + ROOTHDD="${HDD}1" + ;; + normal) + BOOTHDD="${HDD}1" + SWAPHDD="${HDD}2" + ROOTHDD="${HDD}3" + ;; + esac # sanity check - should not happen if is_mounted --device "${ROOTHDD}" @@ -206,33 +241,43 @@ echo "partition: device ${ROOTHDD} is already mounted, umount it" >&2 umount "${ROOTHDD}" fi - - # run this only if FDISKPARTITIONBELOW256MB is not already 1 - if [[ ${FDISKPARTIONBELOW256MB} != 1 ]] + if [[ -n ${BOOTHDD} ]] then - if device_minimum_size "${HDD}" 256 + if is_mounted --device "${BOOTHDD}" then - FDISKPARTIONBELOW256MB=1 - else - FDISKPARTIONBELOW256MB=0 + echo "partition: device ${BOOTHDD} is already mounted, umount it" >&2 + umount "${BOOTHDD}" fi fi - ## delete disk - dd if=/dev/zero of=${HDD} count=1 &> /dev/null || dialog_die - - if [[ ${FDISKPARTIONBELOW256MB} = 1 ]] + if [[ ${INSTALL_METHOD} = auto ]] 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 + # run this only if FDISKPARTITIONBELOW256MB is not already 1 + if [[ ${FDISKPARTIONBELOW256MB} != 1 ]] + then + if device_minimum_size "${HDD}" 256 + then + FDISKPARTIONBELOW256MB=1 + else + FDISKPARTIONBELOW256MB=0 + fi + fi + + ## delete disk + dd if=/dev/zero of=${HDD} count=1 &> /dev/null || dialog_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 n p 1 @@ -242,17 +287,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 @@ -262,27 +307,51 @@ 1 w EOF + fi + else + cfdisk ${HDD} || dialog_die fi } -setup_hdd_partitions_manual() -{ - ROOTHDD="${HDD}1" - SWAPHDD="" - BOOTHDD="" - cfdisk ${HDD} || dialog_die -} - setup_hdd_format() { - # sanity check - should not happen - if is_mounted --device "${ROOTHDD}" + install -d /tmp + :> /tmp/format.log + + if [[ -n ${SWAPHDD} ]] then - echo "format: device ${ROOTHDD} is already mounted, umount it" >&2 - umount "${ROOTHDD}" + # sanity check - should not happen + if is_mounted --device "${SWAPHDD}" + then + echo "format: device ${SWAPHDD} is already mounted, umount it" >&2 + umount "${SWAPHDD}" + fi + mkswap ${SWAPHDD} || die + fi + + if [[ -n ${BOOTHDD} ]] + then + # sanity check - should not happen + if is_mounted --device "${BOOTHDD}" + then + echo "format: device ${BOOTHDD} is already mounted, umount it" >&2 + umount "${BOOTHDD}" + fi + + mkfs."${FORMAT_FILESYSTEM}" "${BOOTHDD}" &>> /tmp/format.log || dialog_die fi - mkfs."${FORMAT_FILESYSTEM}" -q "${ROOTHDD}" || dialog_die + if [[ -n ${ROOTHDD} ]] + then + # sanity check - should not happen + if is_mounted --device "${ROOTHDD}" + then + echo "format: device ${ROOTHDD} is already mounted, umount it" >&2 + umount "${ROOTHDD}" + fi + + mkfs."${FORMAT_FILESYSTEM}" "${ROOTHDD}" &>> /tmp/format.log || dialog_die + fi } install_system_image() @@ -299,7 +368,18 @@ # write fstab CONFIG="${INSTALLROOT}/etc/fstab" clearconfig - addconfig -e "UUID=$(get_uuid ${ROOTHDD})\t/\t${FORMAT_FILESYSTEM}\tnoatime,noauto\t1 1" + if [[ -n ${BOOTHDD} ]] + then + addconfig -e "UUID=$(get_uuid ${BOOTHDD})\t/\t${FORMAT_FILESYSTEM}\tnoatime\t1 1" + fi + if [[ -n ${ROOTHDD} ]] + then + addconfig -e "UUID=$(get_uuid ${ROOTHDD})\t/\t${FORMAT_FILESYSTEM}\tnoatime\t0 0" + fi + if [[ -n ${SWAPHDD} ]] + then + addconfig -e "UUID='$(get_uuid ${SWAPHDD})'\tswap\tswap\tpri=1\t0 0" + fi addconfig -e "proc\t/proc\tproc\tdefaults\t0 0" addconfig -e "shm\t/dev/shm\ttmpfs\tdefaults\t0 0" @@ -360,8 +440,8 @@ if [[ ${retval} -eq 0 ]] then case "${mode}" in - "1") run_install_auto ;; - "2") run_install_normal ;; + "1") run_install auto ;; + "2") run_install normal ;; "") task_setup_system_menu;; esac fi @@ -411,7 +491,7 @@ messagebox -y 12 -h $"Detected hardware:" "${message}" } -task_setup_hdd_partitions_manual() +task_setup_hdd_partitions() { local i local retval @@ -427,29 +507,7 @@ if [[ ${retval} -eq 0 ]] then dialog_setup_hdd_info - setup_hdd_partitions_manual - fi - fi -} - -task_setup_hdd_partitions_auto() -{ - local i - local retval - - if [[ -z ${ALL_DISKS} ]] - then - dialog_no_harddrive_found - exit 1 - else - HDD=$(dialog_select_target_harddrive) - retval=$? - [[ ${retval} -eq 1 ]] && return 1 - if [[ ${retval} -eq 0 ]] - then - dialog_setup_hdd_info_auto - dialog_setup_hdd_create_partitions - setup_hdd_partitions_auto + setup_hdd_partitions fi fi } @@ -476,39 +534,25 @@ done } -run_install_normal() +run_install() { - task_hardware_detection - - task_setup_hdd_partitions_manual - dialog_setup_hdd_format - setup_hdd_format > /dev/null - mount_rootfs - (install_system_image > /tmp/install.log) 2> /tmp/install_errors.log | install_meter | dialog_install_system_image - - dialog_install_settings - sleep 1 - install_system_settings - if is_initrd_supported - then - dialog_install_initrd - initrd_config - initrd_install - fi - - dialog_install_bootsector - bootloader_config - bootloader_install + local method="$1" - umount_rootfs - dialog_install_successful -} - -run_install_auto() -{ task_hardware_detection - task_setup_hdd_partitions_auto + case "${method}" in + auto) + export INSTALL_METHOD="${method}" + ;; + normal) + export INSTALL_METHOD="${method}" + ;; + *) + die "Unknown install method '${method}', aborting." + ;; + esac + + task_setup_hdd_partitions dialog_setup_hdd_format setup_hdd_format > /dev/null mount_rootfs