single log file

This commit is contained in:
farhan 2022-03-03 18:26:00 +00:00
parent 1738fa0068
commit a7073936ce
1 changed files with 28 additions and 9 deletions

View File

@ -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