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 #!/bin/bash
# shellcheck disable=SC1090,SC1091
# Find the name of the folder the scripts are in # Find the name of the folder the scripts are in
set -a 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 SCRIPTS_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"/scripts
CONFIGS_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"/configs CONFIGS_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"/configs
set +a 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() { source_file() {
if [[ -f "$1" ]]; then if [[ -f "$1" ]]; then
source "$1" source "$1"
@ -15,6 +22,16 @@ source_file() {
fi 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() { logo() {
echo -ne " echo -ne "
------------------------------------------------------------------------- -------------------------------------------------------------------------
@ -30,24 +47,26 @@ echo -ne "
" "
} }
sequence() { sequence() {
. $SCRIPT_DIR/scripts/startup.sh # Dont need to log user password in plain text . "$SCRIPT_DIR"/scripts/0-preinstall.sh
source_file $CONFIGS_DIR/setup.conf arch-chroot /mnt "$HOME"/ArchTitus/scripts/1-setup.sh
. $SCRIPT_DIR/scripts/0-preinstall.sh |& tee 0-preinstall.log if [[ ! "$DESKTOP_ENV" == server ]]; then
(arch-chroot /mnt $HOME/ArchTitus/scripts/1-setup.sh) |& tee 1-setup.log arch-chroot /mnt /usr/bin/runuser -u "$USERNAME" -- /home/"$USERNAME"/ArchTitus/scripts/2-user.sh
if [[ ! $DESKTOP_ENV == server ]]; then
(arch-chroot /mnt /usr/bin/runuser -u $USERNAME -- /home/$USERNAME/ArchTitus/scripts/2-user.sh) |& tee 2-user.log
fi fi
(arch-chroot /mnt $HOME/ArchTitus/scripts/3-post-setup.sh)|& tee 3-post-setup.log arch-chroot /mnt "$HOME"/ArchTitus/scripts/3-post-setup.sh
cp -v *.log /mnt/home/$USERNAME
} }
clear clear
logo logo
echo -ne " echo -ne "
Scripts are in directory named ArchTitus Scripts are in directory named ArchTitus
" "
sequence . "$SCRIPT_DIR"/scripts/startup.sh
source_file "$CONFIG_FILE"
sequence |& tee "$LOG_FILE"
logo logo
echo -ne " echo -ne "
Done - Please Eject Install Media and Reboot Done - Please Eject Install Media and Reboot
" "
end