Disable logging, as it caused too many side effects. Use tmux or screen on the live system.

This commit is contained in:
oddlama 2020-01-04 14:10:40 +01:00
parent 0c3ca37792
commit dcf4498821
No known key found for this signature in database
GPG Key ID: 88EA325D51D53908
4 changed files with 22 additions and 57 deletions

View File

@ -1,5 +1,9 @@
# Gentoo installation script # 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. This script will install a minimal bootable gentoo system.
If you need advanced features such as an initramfs or a different If you need advanced features such as an initramfs or a different
partitioning scheme, you can definitely use this script but will partitioning scheme, you can definitely use this script but will

View File

@ -268,14 +268,6 @@ extract_stage3() {
|| die "Could not cd into '$TMP_DIR'" || 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() { gentoo_umount() {
if mountpoint -q -- "$ROOT_MOUNTPOINT"; then if mountpoint -q -- "$ROOT_MOUNTPOINT"; then
einfo "Unmounting root filesystem" einfo "Unmounting root filesystem"
@ -284,12 +276,17 @@ gentoo_umount() {
fi fi
} }
init_bash() {
source /etc/profile
umask 0077
export PS1="(chroot) \$PS1"
}; export -f init_bash
env_update() { env_update() {
env-update \ env-update \
|| die "Error in env-update" || die "Error in env-update"
source /etc/profile \ source /etc/profile \
|| die "Could not source /etc/profile" || die "Could not source /etc/profile"
export PS1="(chroot) \$PS1"
} }
mkdir_or_die() { mkdir_or_die() {
@ -304,11 +301,8 @@ touch_or_die() {
gentoo_chroot() { gentoo_chroot() {
if [[ $# -eq 0 ]]; then if [[ $# -eq 0 ]]; then
cat > "$TMP_DIR/.bashrc" <<EOF # Set the PS1 to a recognizable value
# Set the PS1 to a recognizable value gentoo_chroot /bin/bash --init-file <(echo 'init_bash')
export PS1="(chroot) \$PS1"
EOF
gentoo_chroot /bin/bash --init-file "$TMP_DIR/.bashrc"
fi fi
[[ $EXECUTED_IN_CHROOT != true ]] \ [[ $EXECUTED_IN_CHROOT != true ]] \
@ -336,7 +330,6 @@ EOF
# Execute command # Execute command
einfo "Chrooting..." einfo "Chrooting..."
disable_logging
EXECUTED_IN_CHROOT=true \ EXECUTED_IN_CHROOT=true \
TMP_DIR=$TMP_DIR \ TMP_DIR=$TMP_DIR \
exec chroot -- "$ROOT_MOUNTPOINT" "$GENTOO_BOOTSTRAP_DIR/scripts/main_chroot.sh" "$@" \ exec chroot -- "$ROOT_MOUNTPOINT" "$GENTOO_BOOTSTRAP_DIR/scripts/main_chroot.sh" "$@" \

View File

@ -18,7 +18,6 @@ export GENTOO_BOOTSTRAP_DIR_ORIGINAL="$(dirname "$(get_source_dir)")"
export GENTOO_BOOTSTRAP_DIR="$GENTOO_BOOTSTRAP_DIR_ORIGINAL" export GENTOO_BOOTSTRAP_DIR="$GENTOO_BOOTSTRAP_DIR_ORIGINAL"
export GENTOO_BOOTSTRAP_SCRIPT_ACTIVE=true export GENTOO_BOOTSTRAP_SCRIPT_ACTIVE=true
export GENTOO_BOOTSTRAP_SCRIPT_PID=$$ export GENTOO_BOOTSTRAP_SCRIPT_PID=$$
LOGDATE="$(date +%Y%m%d-%H%M%S)"
umask 0077 umask 0077
@ -140,16 +139,6 @@ main_umount() {
# Instantly kill when pressing ctrl-c # Instantly kill when pressing ctrl-c
trap 'kill "$GENTOO_BOOTSTRAP_SCRIPT_PID"' INT trap 'kill "$GENTOO_BOOTSTRAP_SCRIPT_PID"' INT
einfo "Verbose script output will be logged to: '$GENTOO_BOOTSTRAP_DIR/log-$LOGDATE.out'"
# Save old stdout
exec 3>&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")" SCRIPT_ALIAS="$(basename "$0")"
if [[ "$SCRIPT_ALIAS" == "main.sh" ]]; then if [[ "$SCRIPT_ALIAS" == "main.sh" ]]; then
SCRIPT_ALIAS="$1" SCRIPT_ALIAS="$1"

View File

@ -2,40 +2,20 @@
source "$GENTOO_BOOTSTRAP_DIR/scripts/protection.sh" || exit 1 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() { elog() {
log_stdout " * $*" echo " * $*"
} }
einfo() { einfo() {
log_stdout " * $*" echo " * $*"
} }
ewarn() { ewarn() {
log_stderr " * $*" echo " * $*" >&2
} }
eerror() { eerror() {
log_stderr " * ERROR: $*" echo " * ERROR: $*" >&2
} }
die() { die() {
@ -82,25 +62,24 @@ try() {
cmd_status="$?" cmd_status="$?"
if [[ "$cmd_status" != 0 ]]; then if [[ "$cmd_status" != 0 ]]; then
echo_console " * Command failed: \$ $*" echo " * Command failed: \$ $*"
echo_console "Last command failed with exit code $cmd_status" echo "Last command failed with exit code $cmd_status"
# Prompt until input is valid # Prompt until input is valid
while true; do while true; do
echo_console -n "Specify next action $prompt_parens " echo -n "Specify next action $prompt_parens "
flush_stdin flush_stdin
read -r response \ read -r response \
|| die "Error in read" || die "Error in read"
case "${response,,}" in case "${response,,}" in
''|s|shell) ''|s|shell)
echo_console "Hint: The script log is at '$GENTOO_BOOTSTRAP_DIR/log.out'" echo "You will be prompted for action again after exiting this shell."
echo_console "You will be prompted for action again after exiting this shell." /bin/bash --init-file <(echo "init_bash")
/bin/bash --init-file <(echo "disable_logging; source $TMP_DIR/.bashrc")
;; ;;
r|retry) continue 2 ;; r|retry) continue 2 ;;
a|abort) die "Installation aborted" ;; a|abort) die "Installation aborted" ;;
c|continue) return 0 ;; c|continue) return 0 ;;
p|print) echo_console "\$ $*" ;; p|print) echo "\$ $*" ;;
*) ;; *) ;;
esac esac
done done