Disable logging before chrooting

This commit is contained in:
oddlama 2020-01-02 23:42:45 +01:00
parent a5e8476352
commit b3cf81f95d
No known key found for this signature in database
GPG Key ID: 88EA325D51D53908
2 changed files with 12 additions and 3 deletions

View File

@ -257,6 +257,11 @@ 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
exec 1>&3
}
gentoo_umount() { gentoo_umount() {
einfo "Unmounting root filesystem" einfo "Unmounting root filesystem"
if mountpoint -q -- "$ROOT_MOUNTPOINT"; then if mountpoint -q -- "$ROOT_MOUNTPOINT"; then
@ -293,6 +298,7 @@ gentoo_chroot() {
# 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

@ -108,12 +108,15 @@ main_umount() {
################################################ ################################################
# Main dispatch # Main dispatch
# Redirect output to logfiles einfo "Verbose script output will be logged to: '$GENTOO_BOOTSTRAP_DIR/log-$LOGDATE.out'"
# Save old stdout
exec 3>&1 exec 3>&1
trap 'exec 1>&3' 0 1 2 3 # Restore old filedescriptor on certain signals
trap 'exec 1>&3' 0 1 2 3 RETURN
# Replace stdout with logfole
exec 1>"$GENTOO_BOOTSTRAP_DIR/log-$LOGDATE.out" 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" ln -sf "$GENTOO_BOOTSTRAP_DIR/log-$LOGDATE.out" "$GENTOO_BOOTSTRAP_DIR/log.out"
einfo "Verbose script output is logged to: '$GENTOO_BOOTSTRAP_DIR/log-$LOGDATE.out'"
SCRIPT_ALIAS="$(basename "$0")" SCRIPT_ALIAS="$(basename "$0")"
if [[ "$SCRIPT_ALIAS" == "main.sh" ]]; then if [[ "$SCRIPT_ALIAS" == "main.sh" ]]; then