diff --git a/README.md b/README.md index 676ecba..e05eabb 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,9 @@ # Gentoo installation script +**TL;DR:** Installs gentoo on a new system, suited for both servers and desktops. +Optionally prepares ansible for automatic system configuration. +See [Install](#Install) for usage instructions. + This script will install a minimal bootable gentoo system. If you need advanced features such as an initramfs or a different partitioning scheme, you can definitely use this script but will diff --git a/scripts/functions.sh b/scripts/functions.sh index 8495b5e..5e9ebd4 100644 --- a/scripts/functions.sh +++ b/scripts/functions.sh @@ -268,14 +268,6 @@ extract_stage3() { || die "Could not cd into '$TMP_DIR'" } -disable_logging() { - # Disables logging which is needed before exec-ing - # Restore stdion - exec 1>&3 - # Close fd 3 - exec 3<&- -}; export -f disable_logging - gentoo_umount() { if mountpoint -q -- "$ROOT_MOUNTPOINT"; then einfo "Unmounting root filesystem" @@ -284,12 +276,17 @@ gentoo_umount() { fi } +init_bash() { + source /etc/profile + umask 0077 + export PS1="(chroot) \$PS1" +}; export -f init_bash + env_update() { env-update \ || die "Error in env-update" source /etc/profile \ || die "Could not source /etc/profile" - export PS1="(chroot) \$PS1" } mkdir_or_die() { @@ -304,11 +301,8 @@ touch_or_die() { gentoo_chroot() { if [[ $# -eq 0 ]]; then - cat > "$TMP_DIR/.bashrc" <&1 -# Restore old filedescriptor on certain signals -trap 'exec 1>&3; exit 1' 0 1 2 3 RETURN -# Replace stdout with logfole -exec 1>"$GENTOO_BOOTSTRAP_DIR/log-$LOGDATE.out" -# Link to latest log file -ln -sf "$GENTOO_BOOTSTRAP_DIR/log-$LOGDATE.out" "$GENTOO_BOOTSTRAP_DIR/log.out" - SCRIPT_ALIAS="$(basename "$0")" if [[ "$SCRIPT_ALIAS" == "main.sh" ]]; then SCRIPT_ALIAS="$1" diff --git a/scripts/utils.sh b/scripts/utils.sh index 2dcb21e..2061308 100644 --- a/scripts/utils.sh +++ b/scripts/utils.sh @@ -2,40 +2,20 @@ source "$GENTOO_BOOTSTRAP_DIR/scripts/protection.sh" || exit 1 -echo_console() { - if { true >&3; } 2<> /dev/null; then - echo "$@" >&3 - else - echo "$@" - fi -} - -log_stdout() { - echo "$*" - if { true >&3; } 2<> /dev/null; then - echo "$*" >&3 - fi -} - -log_stderr() { - echo "$*" >&2 - echo "$*" -} - elog() { - log_stdout " * $*" + echo " * $*" } einfo() { - log_stdout " * $*" + echo " * $*" } ewarn() { - log_stderr " * $*" + echo " * $*" >&2 } eerror() { - log_stderr " * ERROR: $*" + echo " * ERROR: $*" >&2 } die() { @@ -82,25 +62,24 @@ try() { cmd_status="$?" if [[ "$cmd_status" != 0 ]]; then - echo_console " * Command failed: \$ $*" - echo_console "Last command failed with exit code $cmd_status" + echo " * Command failed: \$ $*" + echo "Last command failed with exit code $cmd_status" # Prompt until input is valid while true; do - echo_console -n "Specify next action $prompt_parens " + echo -n "Specify next action $prompt_parens " flush_stdin 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'" - echo_console "You will be prompted for action again after exiting this shell." - /bin/bash --init-file <(echo "disable_logging; source $TMP_DIR/.bashrc") + echo "You will be prompted for action again after exiting this shell." + /bin/bash --init-file <(echo "init_bash") ;; r|retry) continue 2 ;; a|abort) die "Installation aborted" ;; c|continue) return 0 ;; - p|print) echo_console "\$ $*" ;; + p|print) echo "\$ $*" ;; *) ;; esac done