--- trunk/installer-simple/bin/installer.sh.in 2014/01/08 10:25:50 2480 +++ trunk/installer-simple/bin/installer.sh.in 2014/01/08 12:22:26 2491 @@ -72,9 +72,8 @@ FORMFACTOR="${DEFAULT_FORMFACTOR}" FORMAT_FILESYSTEM="${DEFAULT_FILESYSTEM}" -################################################# -# DIALOG BOXEN # -################################################# + +### helper scripts ### trap_exit() { @@ -88,133 +87,6 @@ exit 1 } -dialog_die() -{ - ERROR="$1" - RETVAL="$?" - dialog_install_failure - exit 1 -} - -dialog_warning() -{ - local retval - - yesnobox $"\Z1 !!! Warning !!! \Zn\n\n\This harddrive will be irreversibly erased.\n\n\Do you want to continue ?" - retval=$? - if [[ ${retval} -eq 1 ]] - then - clear - echo $"The process was aborted." - exit 1 - fi -} - -task_setup_system_menu() -{ - local mode - local retval - - mode="$(dialog_setup_system_menu)" - retval=$? - [[ ${retval} -eq 1 ]] && return 1 - if [[ ${retval} -eq 0 ]] - then - case "${mode}" in - "1") run_install_auto ;; - "2") run_install_normal ;; - "") task_setup_system_menu;; - esac - fi -} - -dialog_hardware_detection() -{ - local message - - run_hardware_detection_disks - - message+=$"Harddrives:\n" - - if [[ ! -z ${ALL_DISKS} ]] - then - for i in ${ALL_DISKS} - do - message+="\Z3${i}\Zn " - done - message+="\n" - fi - - if [[ ! -z ${ALL_CDROMS} ]] - then - message+="\n" - message+=$"Optical disk drives:\n" - for i in ${ALL_CDROMS} - do - message+="\Z3${i}\Zn" - done - message+="\n" - fi - - # other devices - run_hardware_detection - case "${SPECIALDEVICE}" in - zotac*) message+=$"\n\Z2Zotac device detected.\Zn" ;; - rangee) message+=$"\n\Z2Rangee device detected.\Zn" ;; - maxdata) message+=$"\n\Z2Maxdata device detected.\Zn" ;; - *) message+=$"\n\ZnCommon device detected.\Zn" ;; - esac - if [[ ${FORMFACTOR} = laptop ]] - then - message+=$"\n\ZnFormfactor Laptop, activating 'ondemand' powersaving mode.\Zn" - fi - - messagebox -y 12 -h $"Detected hardware:" "${message}" -} - -task_setup_hdd_partitions_manual() -{ - 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 - 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 - fi - fi -} - install_meter() { while [[ ${CURRENTLINE} != ${TOTALLINES} ]] @@ -228,31 +100,30 @@ return 0 } -task_main() +mount_rootfs() { - local method=0 local retval - while [[ ${method} -le 2 ]] - do - method=$(dialog_main) - retval=$? - [[ ${retval} -eq 1 ]] && exit 1 - if [[ ${retval} -eq 0 ]] - then - case ${method} in - "1") task_setup_system_menu ;; - "2") dialog_hardware_detection ;; - "3") install_do_reboot ;; - "4") /bin/bash --login -i ;; - esac - fi - done + 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 + [[ -d ${INSTALLROOT}/boot ]] || install -d ${INSTALLROOT}/boot +} + +umount_rootfs() +{ + is_mounted --location ${INSTALLROOT}/boot && umount ${INSTALLROOT}/boot + is_mounted --location ${INSTALLROOT} && umount ${INSTALLROOT} +} + +install_do_reboot() +{ + reboot } -################################################# -# Install Komandos # -################################################# run_hardware_detection() { local hwinfo @@ -340,7 +211,7 @@ # run this only if FDISKPARTITIONBELOW256MB is not already 1 if [[ ${FDISKPARTIONBELOW256MB} != 1 ]] then - if hdd_size_below_256mb ${HDD} + if device_minimum_size "${HDD}" 256 then FDISKPARTIONBELOW256MB=1 else @@ -415,12 +286,6 @@ mkfs."${FORMAT_FILESYSTEM}" -q "${ROOTHDD}" || dialog_die } -install_mount_rootfs() -{ - is_mounted --location "${INSTALLROOT}" || mount "${ROOTHDD}" "${INSTALLROOT}" - install -d ${INSTALLROOT}/boot || dialog_die -} - install_system_image() { pushd ${INSTALLROOT} > /dev/null @@ -462,29 +327,169 @@ fi } -install_umount_rootfs() + +### installer dialogs ### + +dialog_die() { - is_mounted --location ${INSTALLROOT}/boot && umount ${INSTALLROOT}/boot - is_mounted --location ${INSTALLROOT} && umount ${INSTALLROOT} + ERROR="$1" + RETVAL="$?" + dialog_install_failure + exit 1 } -install_do_reboot() +dialog_warning() { - reboot + local retval + + yesnobox $"\Z1 !!! Warning !!! \Zn\n\n\This harddrive will be irreversibly erased.\n\n\Do you want to continue ?" + retval=$? + if [[ ${retval} -eq 1 ]] + then + clear + echo $"The process was aborted." + exit 1 + fi } -################################################# -# Install Ablauf Scripte # -################################################# + +### installer tasks ### + +task_setup_system_menu() +{ + local mode + local retval + + mode="$(dialog_setup_system_menu)" + retval=$? + [[ ${retval} -eq 1 ]] && return 1 + if [[ ${retval} -eq 0 ]] + then + case "${mode}" in + "1") run_install_auto ;; + "2") run_install_normal ;; + "") task_setup_system_menu;; + esac + fi +} + +task_hardware_detection() +{ + local message + + run_hardware_detection_disks + + message+=$"Harddrives:\n" + + if [[ ! -z ${ALL_DISKS} ]] + then + for i in ${ALL_DISKS} + do + message+="\Z3${i}\Zn " + done + message+="\n" + fi + + if [[ ! -z ${ALL_CDROMS} ]] + then + message+="\n" + message+=$"Optical disk drives:\n" + for i in ${ALL_CDROMS} + do + message+="\Z3${i}\Zn" + done + message+="\n" + fi + + # other devices + run_hardware_detection + case "${SPECIALDEVICE}" in + zotac*) message+=$"\n\Z2Zotac device detected.\Zn" ;; + rangee) message+=$"\n\Z2Rangee device detected.\Zn" ;; + maxdata) message+=$"\n\Z2Maxdata device detected.\Zn" ;; + *) message+=$"\n\ZnCommon device detected.\Zn" ;; + esac + if [[ ${FORMFACTOR} = laptop ]] + then + message+=$"\n\ZnFormfactor Laptop, activating 'ondemand' powersaving mode.\Zn" + fi + + messagebox -y 12 -h $"Detected hardware:" "${message}" +} + +task_setup_hdd_partitions_manual() +{ + 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 + 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 + fi + fi +} + +task_main() +{ + local method=0 + local retval + + while [[ ${method} -le 2 ]] + do + method=$(dialog_main) + retval=$? + [[ ${retval} -eq 1 ]] && exit 1 + if [[ ${retval} -eq 0 ]] + then + case ${method} in + "1") task_setup_system_menu ;; + "2") task_hardware_detection ;; + "3") install_do_reboot ;; + "4") /bin/bash --login -i ;; + esac + fi + done +} run_install_normal() { - dialog_hardware_detection + task_hardware_detection task_setup_hdd_partitions_manual dialog_setup_hdd_format setup_hdd_format > /dev/null - install_mount_rootfs + mount_rootfs (install_system_image > /tmp/install.log) 2> /tmp/install_errors.log | install_meter | dialog_install_system_image dialog_install_settings @@ -501,18 +506,18 @@ bootloader_config bootloader_install - install_umount_rootfs + umount_rootfs dialog_install_successful } run_install_auto() { - dialog_hardware_detection + task_hardware_detection task_setup_hdd_partitions_auto dialog_setup_hdd_format setup_hdd_format > /dev/null - install_mount_rootfs + mount_rootfs (install_system_image > /tmp/install.log) 2> /tmp/install_errors.log | install_meter | dialog_install_system_image dialog_install_settings @@ -529,7 +534,7 @@ bootloader_config bootloader_install - install_umount_rootfs + umount_rootfs dialog_install_successful }