Global Function Tweak and Final Check
This commit is contained in:
@@ -4,7 +4,6 @@
|
|||||||
# NOTE: These package check are only the essentials
|
# NOTE: These package check are only the essentials
|
||||||
|
|
||||||
packages=(
|
packages=(
|
||||||
aylurs-gtk-shell
|
|
||||||
cliphist
|
cliphist
|
||||||
kvantum
|
kvantum
|
||||||
rofi-wayland
|
rofi-wayland
|
||||||
@@ -22,44 +21,69 @@ packages=(
|
|||||||
pyprland
|
pyprland
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Local packages that should be in /usr/local/bin/
|
||||||
|
local_pkgs_installed=(
|
||||||
|
ags
|
||||||
|
)
|
||||||
|
|
||||||
## WARNING: DO NOT EDIT BEYOND THIS LINE IF YOU DON'T KNOW WHAT YOU ARE DOING! ##
|
## WARNING: DO NOT EDIT BEYOND THIS LINE IF YOU DON'T KNOW WHAT YOU ARE DOING! ##
|
||||||
# Determine the directory where the script is located
|
# Determine the directory where the script is located
|
||||||
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
|
||||||
# Change the working directory to the parent directory of the script
|
# Change the working directory to the parent directory of the script
|
||||||
PARENT_DIR="$SCRIPT_DIR/.."
|
PARENT_DIR="$SCRIPT_DIR/.."
|
||||||
cd "$PARENT_DIR" || exit 1
|
cd "$PARENT_DIR" || { echo "${ERROR} Failed to change directory to $PARENT_DIR"; exit 1; }
|
||||||
|
|
||||||
|
# Source the global functions script
|
||||||
source "$(dirname "$(readlink -f "$0")")/Global_functions.sh"
|
source "$(dirname "$(readlink -f "$0")")/Global_functions.sh"
|
||||||
|
|
||||||
# Set the name of the log file to include the current date and time
|
# 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"
|
LOG="Install-Logs/00_CHECK-$(date +%d-%H%M%S)_installed.log"
|
||||||
|
|
||||||
|
printf "\n%s - Final Check if Essential packages were installed \n" "${NOTE}"
|
||||||
printf "\n%s - Final Check if essential packages where installed \n" "${NOTE}"
|
|
||||||
# Initialize an empty array to hold missing packages
|
# Initialize an empty array to hold missing packages
|
||||||
missing=()
|
missing=()
|
||||||
|
local_missing=()
|
||||||
|
|
||||||
|
# Function to check if a package is installed using pacman
|
||||||
|
is_installed_pacman() {
|
||||||
|
pacman -Qi "$1" &>/dev/null
|
||||||
|
}
|
||||||
|
|
||||||
# Loop through each package
|
# Loop through each package
|
||||||
for pkg in "${packages[@]}"; do
|
for pkg in "${packages[@]}"; do
|
||||||
# Check if the package is installed
|
# Check if the package is installed via pacman
|
||||||
if ! pacman -Qi "$pkg" > /dev/null 2>&1; then
|
if ! is_installed_pacman "$pkg"; then
|
||||||
missing+=("$pkg")
|
missing+=("$pkg")
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Check if the missing array is empty or not
|
# Check for local packages
|
||||||
if [ ${#missing[@]} -eq 0 ]; then
|
for pkg1 in "${local_pkgs_installed[@]}"; do
|
||||||
|
if ! [ -f "/usr/local/bin/$pkg1" ]; then
|
||||||
|
local_missing+=("$pkg1")
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Log missing packages
|
||||||
|
if [ ${#missing[@]} -eq 0 ] && [ ${#local_missing[@]} -eq 0 ]; then
|
||||||
echo "${OK} All essential packages are installed." | tee -a "$LOG"
|
echo "${OK} All essential packages are installed." | tee -a "$LOG"
|
||||||
else
|
else
|
||||||
# Message to user on missing packages
|
if [ ${#missing[@]} -ne 0 ]; then
|
||||||
echo "${WARN} The following packages are missing and will be logged:"
|
echo "${WARN} The following packages are not installed and will be logged:"
|
||||||
|
|
||||||
# Log only the missing packages and inform the user
|
|
||||||
for pkg in "${missing[@]}"; do
|
for pkg in "${missing[@]}"; do
|
||||||
echo "$pkg"
|
echo "$pkg"
|
||||||
echo "$pkg" >> "$LOG" # Log the missing package to the file
|
echo "$pkg" >> "$LOG" # Log the missing package to the file
|
||||||
done
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ${#local_missing[@]} -ne 0 ]; then
|
||||||
|
echo "${WARN} The following local packages are missing from /usr/local/bin/ and will be logged:"
|
||||||
|
for pkg1 in "${local_missing[@]}"; do
|
||||||
|
echo "$pkg1 is not installed. Can't find it in /usr/local/bin/"
|
||||||
|
echo "$pkg1" >> "$LOG" # Log the missing local package to the file
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
# Add a timestamp when the missing packages were logged
|
# Add a timestamp when the missing packages were logged
|
||||||
echo "${NOTE} Missing packages logged at $(date)" >> "$LOG"
|
echo "${NOTE} Missing packages logged at $(date)" >> "$LOG"
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ install_package_pacman() {
|
|||||||
sudo pacman -S --noconfirm "$1" 2>&1 | tee -a "$LOG"
|
sudo pacman -S --noconfirm "$1" 2>&1 | tee -a "$LOG"
|
||||||
# Making sure package is installed
|
# Making sure package is installed
|
||||||
if pacman -Q "$1" &>/dev/null ; then
|
if pacman -Q "$1" &>/dev/null ; then
|
||||||
echo -e "${OK} Package ${!YELLOW}$1${RESET} has been successfully installed!"
|
echo -e "\e[1A\e[K${OK} Package ${YELLOW}$1${RESET} has been successfully installed!"
|
||||||
else
|
else
|
||||||
# Something is missing, exiting to review log
|
# Something is missing, exiting to review log
|
||||||
echo -e "${ERROR} $1 failed to install. Please check the $LOG. You may need to install manually."
|
echo -e "${ERROR} $1 failed to install. Please check the $LOG. You may need to install manually."
|
||||||
@@ -54,7 +54,7 @@ install_package() {
|
|||||||
$ISAUR -S --noconfirm "$1" 2>&1 | tee -a "$LOG"
|
$ISAUR -S --noconfirm "$1" 2>&1 | tee -a "$LOG"
|
||||||
# Making sure package is installed
|
# Making sure package is installed
|
||||||
if $ISAUR -Q "$1" &>> /dev/null ; then
|
if $ISAUR -Q "$1" &>> /dev/null ; then
|
||||||
echo -e "\e[1A\e[K${OK} $1 was installed."
|
echo -e "\e[1A\e[K${OK} Package ${YELLOW}$1${RESET} has been successfully installed!"
|
||||||
else
|
else
|
||||||
# Something is missing, exiting to review log
|
# Something is missing, exiting to review log
|
||||||
echo -e "\e[1A\e[K${ERROR} $1 failed to install :( , please check the install.log. You may need to install manually! Sorry I have tried :("
|
echo -e "\e[1A\e[K${ERROR} $1 failed to install :( , please check the install.log. You may need to install manually! Sorry I have tried :("
|
||||||
|
|||||||
Reference in New Issue
Block a user