updated - added final check of install packages

This commit is contained in:
JaKooLit 2024-09-14 00:48:15 +09:00
parent 477545ac2e
commit 8ad8784443
2 changed files with 78 additions and 43 deletions

View File

@ -0,0 +1,66 @@
#!/bin/bash
# 💫 https://github.com/JaKooLit 💫 #
# Final checking if packages are installed
# NOTE: These package check are only the essentials
packages=(
aylurs-gtk-shell
cliphist
kvantum
rofi-wayland
swaync
swww
wallust
waybar
wl-clipboard
wlogout
kitty
hypridle
hyprlock
hyprland
pyprland
)
## WARNING: DO NOT EDIT BEYOND THIS LINE IF YOU DON'T KNOW WHAT YOU ARE DOING! ##
# Determine the directory where the script is located
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Change the working directory to the parent directory of the script
PARENT_DIR="$SCRIPT_DIR/.."
cd "$PARENT_DIR" || exit 1
source "$(dirname "$(readlink -f "$0")")/Global_functions.sh"
# Set the name of the log file to include the current date and time
LOG="Install-Logs/00_CHECK-$(date +%d-%H%M%S)_installed.log"
printf "\n%s - Final Check if packages where installed \n" "${NOTE}"
# Initialize an empty array to hold missing packages
missing=()
# Loop through each package
for pkg in "${packages[@]}"; do
# Check if the package is installed
if ! pacman -Qi "$pkg" > /dev/null 2>&1; then
missing+=("$pkg")
fi
done
# Check if the missing array is empty or not
if [ ${#missing[@]} -eq 0 ]; then
echo "${OK} All packages are installed." | tee -a "$LOG"
else
# Message to user on missing packages
echo "${WARN} The following packages are missing and will be logged:"
# Log only the missing packages and inform the user
for pkg in "${missing[@]}"; do
echo "$pkg"
echo "$pkg" >> "$LOG" # Log the missing package to the file
done
# Add a timestamp when the missing packages were logged
echo "${NOTE} Missing packages logged at $(date)" >> "$LOG"
fi

View File

@ -261,63 +261,32 @@ fi
clear
printf "\n%.0s" {1..3}
# Error-checking section
LOG_DIR="Install-Logs"
ERROR_FILE="$LOG_DIR/00-Error.log"
# Create or clear the error file
: > "$ERROR_FILE"
# Check if the Install-Logs directory exists
if [ -d "$LOG_DIR" ]; then
# Iterate through each file in the Install-Logs directory
for log_file in "$LOG_DIR"/*; do
# Check if it's a file
if [ -f "$log_file" ]; then
# Search for lines containing the word "error" (case-insensitive) in the log file
if grep -i "error" "$log_file" > /dev/null; then
# If errors are found, add the filename to the error file
echo "${WARN} Errors found in file: $(basename "$log_file")" >> "$ERROR_FILE"
fi
fi
done
# Check if the error file has any content
if [ -s "$ERROR_FILE" ]; then
echo "${ERROR} Errors encountered during Installation. See $ERROR_FILE for details."
else
echo "${OK} No errors were found."
fi
else
echo "Directory $LOG_DIR does not exist or could not be found."
fi
# final check essential packages if it is installed
execute_script "01-Final-Check.sh"
printf "\n%.0s" {1..1}
# Check if hyprland or hyprland-git is installed
if pacman -Q hyprland &> /dev/null || pacman -Q hyprland-git &> /dev/null; then
printf "\n${OK} Hyprland is installed. However, there may some errors during installation "
printf "\n${CAT} Please see the errors in Install-Logs as stated above\n"
sleep 2
printf "\n${NOTE} You can start Hyprland by typing Hyprland (IF SDDM is not installed) (note the capital H!).\n"
printf "\n"
printf "\n${NOTE} However, It is highly recommended to reboot your system.\n\n"
printf "\n${OK} Hyprland is installed. However, some essential packages may not be installed."
printf "\n${CAT} Please see above. Simply ignore this message if it states 'All packages are installed.'\n"
sleep 2
printf "\n${NOTE} You can start Hyprland by typing 'Hyprland' (IF SDDM is not installed) (note the capital H!).\n"
printf "\n${NOTE} However, it is highly recommended to reboot your system.\n\n"
# Prompt user to reboot
read -rp "${CAT} Would you like to reboot now? (y/n): " HYP
# Check if the user answered 'y' or 'Y'
if [[ "$HYP" =~ ^[Yy]$ ]]; then
if [[ "$nvidia" == "Y" ]]; then
echo "${NOTE} NVIDIA GPU detected. Rebooting the system..."
systemctl reboot
else
systemctl reboot
fi
fi
systemctl reboot
fi
else
# Print error message if neither package is installed
printf "\n${WARN} Hyprland failed to install. Please check Error Log and Install-Logs directory...\n\n"
printf "\n${WARN} Hyprland failed to install. Please check 00_CHECK-time_installed.log and other files Install-Logs/ directory...\n\n"
exit 1
fi