Disable logging, as it caused too many side effects. Use tmux or screen on the live system.
This commit is contained in:
parent
0c3ca37792
commit
dcf4498821
|
@ -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
|
||||
|
|
|
@ -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" <<EOF
|
||||
# Set the PS1 to a recognizable value
|
||||
export PS1="(chroot) \$PS1"
|
||||
EOF
|
||||
gentoo_chroot /bin/bash --init-file "$TMP_DIR/.bashrc"
|
||||
gentoo_chroot /bin/bash --init-file <(echo 'init_bash')
|
||||
fi
|
||||
|
||||
[[ $EXECUTED_IN_CHROOT != true ]] \
|
||||
|
@ -336,7 +330,6 @@ EOF
|
|||
|
||||
# Execute command
|
||||
einfo "Chrooting..."
|
||||
disable_logging
|
||||
EXECUTED_IN_CHROOT=true \
|
||||
TMP_DIR=$TMP_DIR \
|
||||
exec chroot -- "$ROOT_MOUNTPOINT" "$GENTOO_BOOTSTRAP_DIR/scripts/main_chroot.sh" "$@" \
|
||||
|
|
|
@ -18,7 +18,6 @@ export GENTOO_BOOTSTRAP_DIR_ORIGINAL="$(dirname "$(get_source_dir)")"
|
|||
export GENTOO_BOOTSTRAP_DIR="$GENTOO_BOOTSTRAP_DIR_ORIGINAL"
|
||||
export GENTOO_BOOTSTRAP_SCRIPT_ACTIVE=true
|
||||
export GENTOO_BOOTSTRAP_SCRIPT_PID=$$
|
||||
LOGDATE="$(date +%Y%m%d-%H%M%S)"
|
||||
|
||||
umask 0077
|
||||
|
||||
|
@ -140,16 +139,6 @@ main_umount() {
|
|||
# Instantly kill when pressing ctrl-c
|
||||
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")"
|
||||
if [[ "$SCRIPT_ALIAS" == "main.sh" ]]; then
|
||||
SCRIPT_ALIAS="$1"
|
||||
|
|
|
@ -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 "[1m *[m $*"
|
||||
echo "[1m *[m $*"
|
||||
}
|
||||
|
||||
einfo() {
|
||||
log_stdout "[1;32m *[m $*"
|
||||
echo "[1;32m *[m $*"
|
||||
}
|
||||
|
||||
ewarn() {
|
||||
log_stderr "[1;33m *[m $*"
|
||||
echo "[1;33m *[m $*" >&2
|
||||
}
|
||||
|
||||
eerror() {
|
||||
log_stderr "[1;31m * ERROR:[m $*"
|
||||
echo "[1;31m * ERROR:[m $*" >&2
|
||||
}
|
||||
|
||||
die() {
|
||||
|
@ -82,25 +62,24 @@ try() {
|
|||
cmd_status="$?"
|
||||
|
||||
if [[ "$cmd_status" != 0 ]]; then
|
||||
echo_console "[1;31m * Command failed: [1;33m\$[m $*"
|
||||
echo_console "Last command failed with exit code $cmd_status"
|
||||
echo "[1;31m * Command failed: [1;33m\$[m $*"
|
||||
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 "[1;33m\$[m $*" ;;
|
||||
p|print) echo "[1;33m\$[m $*" ;;
|
||||
*) ;;
|
||||
esac
|
||||
done
|
||||
|
|
Loading…
Reference in New Issue