From a7073936ce60654b8dbb408bd4d94e7d3b5ac475 Mon Sep 17 00:00:00 2001 From: farhan Date: Thu, 3 Mar 2022 18:26:00 +0000 Subject: [PATCH] single log file --- archtitus.sh | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/archtitus.sh b/archtitus.sh index cb1a861..01b5d9b 100755 --- a/archtitus.sh +++ b/archtitus.sh @@ -1,4 +1,5 @@ #!/bin/bash +# shellcheck disable=SC1090,SC1091 # Find the name of the folder the scripts are in set -a @@ -6,6 +7,12 @@ SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) SCRIPTS_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"/scripts CONFIGS_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"/configs set +a + +CONFIG_FILE="$SCRIPT_DIR"/configs/setup.conf +LOG_FILE="$SCRIPT_DIR"/configs/main.log + +[[ -f "$LOG_FILE" ]] && rm -f "$LOG_FILE" + source_file() { if [[ -f "$1" ]]; then source "$1" @@ -15,6 +22,16 @@ source_file() { fi } +end() { + echo "Copying logs" + if [[ "$(find /mnt/var/log -type d | wc -l)" -ne 0 ]]; then + cp -v "$LOG_FILE" /mnt/var/log/ArchTitus.log + else + echo -ne "ERROR! Log directory not found" + exit 0 + fi +} + logo() { echo -ne " ------------------------------------------------------------------------- @@ -30,24 +47,26 @@ echo -ne " " } + sequence() { - . $SCRIPT_DIR/scripts/startup.sh # Dont need to log user password in plain text - source_file $CONFIGS_DIR/setup.conf - . $SCRIPT_DIR/scripts/0-preinstall.sh |& tee 0-preinstall.log - (arch-chroot /mnt $HOME/ArchTitus/scripts/1-setup.sh) |& tee 1-setup.log - if [[ ! $DESKTOP_ENV == server ]]; then - (arch-chroot /mnt /usr/bin/runuser -u $USERNAME -- /home/$USERNAME/ArchTitus/scripts/2-user.sh) |& tee 2-user.log + . "$SCRIPT_DIR"/scripts/0-preinstall.sh + arch-chroot /mnt "$HOME"/ArchTitus/scripts/1-setup.sh + if [[ ! "$DESKTOP_ENV" == server ]]; then + arch-chroot /mnt /usr/bin/runuser -u "$USERNAME" -- /home/"$USERNAME"/ArchTitus/scripts/2-user.sh fi - (arch-chroot /mnt $HOME/ArchTitus/scripts/3-post-setup.sh)|& tee 3-post-setup.log - cp -v *.log /mnt/home/$USERNAME + arch-chroot /mnt "$HOME"/ArchTitus/scripts/3-post-setup.sh } + clear logo echo -ne " Scripts are in directory named ArchTitus " -sequence +. "$SCRIPT_DIR"/scripts/startup.sh +source_file "$CONFIG_FILE" +sequence |& tee "$LOG_FILE" logo echo -ne " Done - Please Eject Install Media and Reboot " +end \ No newline at end of file