diff --git a/scripts/functions.sh b/scripts/functions.sh index 888aec3..8495b5e 100644 --- a/scripts/functions.sh +++ b/scripts/functions.sh @@ -22,9 +22,16 @@ sync_time() { || die "Could not save time to hardware clock" } +check_config() { + [[ "$KEYMAP" =~ ^[0-9A-Za-z-]*$ ]] \ + || die "KEYMAP contains invalid characters" +} + prepare_installation_environment() { einfo "Preparing installation environment" + check_config + check_has_program gpg check_has_program hwclock check_has_program lsblk diff --git a/scripts/main.sh b/scripts/main.sh index fd34d90..a3c1e55 100755 --- a/scripts/main.sh +++ b/scripts/main.sh @@ -50,7 +50,8 @@ main_install_gentoo_in_chroot() { # Lock the root password, making the account unaccessible for the # period of installation, except by chrooting einfo "Locking root account" - passwd -l root + passwd -l root \ + || die "Could not change root password" einfo "Selecting portage mirrors" # TODO mirrorselect @@ -65,8 +66,7 @@ main_install_gentoo_in_chroot() { # Sync portage einfo "Syncing portage tree" - try emerge-webrsync \ - || die "Failed to sync portage tree" + try emerge-webrsync # Set timezone einfo "Selecting timezone" @@ -82,6 +82,11 @@ main_install_gentoo_in_chroot() { || die "Could not generate locales" try eselect locale set "$LOCALE" + # Set keymap + einfo "Selecting keymap" + sed -i "/keymap=/c\\$KEYMAP" /etc/conf.d/keymaps \ + || die "Could not sed replace in /etc/conf.d/keymaps" + # Update environment env_update @@ -93,8 +98,7 @@ main_install_gentoo_in_chroot() { # Install git (for git portage overlays) einfo "Installing git" - try emerge --verbose dev-vcs/git \ - || die "Error while installing git" + try emerge --verbose dev-vcs/git #get kernel diff --git a/scripts/utils.sh b/scripts/utils.sh index c45a6b5..87ca290 100644 --- a/scripts/utils.sh +++ b/scripts/utils.sh @@ -59,7 +59,8 @@ ask() { local response while true; do flush_stdin - read -r -p "$* (Y/n) " response + read -r -p "$* (Y/n) " response \ + || die "Error in read" case "${response,,}" in '') return 0 ;; y|yes) return 0 ;; @@ -72,7 +73,7 @@ ask() { try() { local response local cmd_status - local prompt_parens="(Shell/retry/cancel/print)" + local prompt_parens="(Shell/retry/abort/continue/print)" # Outer loop, allows us to retry the command while true; do @@ -87,7 +88,8 @@ try() { # Prompt until input is valid while true; do flush_stdin - read -r response + read -r response \ + || die "Error in read" case "${response,,}" in ''|s|shell) echo_console "Hint: The script log is at '$GENTOO_BOOTSTRAP_DIR/log.out'" @@ -95,7 +97,8 @@ try() { /bin/bash --init-file <(echo "disable_logging; source $TMP_DIR/.bashrc") ;; r|retry) continue 2 ;; - c|cancel) die "Installation cancelled" ;; + a|abort) die "Installation aborted" ;; + c|continue) return 0 ;; p|print) echo_console "\$ $*" ;; *) echo_console -n "Response not understood $prompt_parens " ;; esac