From 46900f4934c6b1dd72b5183c72da180b677df759 Mon Sep 17 00:00:00 2001 From: eshanized Date: Fri, 20 Dec 2024 00:30:25 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(=5Fdir):=20error=20logger=20?= =?UTF-8?q?dir?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- usr/lib/snigdhaos-assistant/apply.sh | 32 +++++++++++++++++----------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/usr/lib/snigdhaos-assistant/apply.sh b/usr/lib/snigdhaos-assistant/apply.sh index 664bb99..4d7b9db 100755 --- a/usr/lib/snigdhaos-assistant/apply.sh +++ b/usr/lib/snigdhaos-assistant/apply.sh @@ -2,66 +2,74 @@ # Function to log messages to a log file log_message() { - echo "$(date '+%Y-%m-%d %H:%M:%S') - $1" >> /var/log/snigdha_assistant.log + # This function logs messages with a timestamp to /var/log/snigdhaos_assistant.log + echo "$(date '+%Y-%m-%d %H:%M:%S') - $1" >> /var/log/snigdhaos_assistant.log } # Check if the first file (setup script) exists and execute it if [ -e "$1" ]; then echo "" - echo "Preparing setup ⏳" + echo "Preparing setup ⏳" # Show waiting emoji when preparing setup echo "" log_message "Executing setup script: $1" if ! sudo bash - <$1; then + # If the setup script execution fails, print an error message with a cross emoji echo "❌ Error executing setup script. Check logs for more details." log_message "Error executing setup script: $1" - exit 1 + exit 1 # Exit the script if setup fails fi else + # If the setup script doesn't exist, show a warning with a caution emoji echo "⚠️ Setup script ($1) not found! Skipping setup." log_message "Setup script ($1) not found." fi # Install packages from the second file echo "" -echo "Installing packages 🛠️" +echo "Installing packages 🛠️" # Show tools emoji for package installation echo "" -installable_packages=$(comm -12 <(pacman -Slq | sort) <(sed s/\\s/\\n/g - <$2 | sort)) +installable_packages=$(comm -12 <(pacman -Slq | sort) <(sed s/\\s/\\n/g - <$2 | sort)) # Find common packages between the pacman repo and the list in $2 if [ -z "$installable_packages" ]; then + # If no installable packages are found, show a warning with a caution emoji echo "⚠️ No installable packages found. Skipping package installation." log_message "No installable packages found from $2" else + # If packages are found, list them and show a package emoji echo "📦 The following packages will be installed: $installable_packages" log_message "Installing packages: $installable_packages" if ! sudo pacman -S --needed $installable_packages; then + # If the package installation fails, show an error with a cross emoji echo "❌ Error installing packages. Check logs for more details." log_message "Error installing packages: $installable_packages" - exit 1 + exit 1 # Exit the script if package installation fails fi - rm -f $2 - echo "✅ Packages installed successfully." + rm -f $2 # Remove the file after successful installation + echo "✅ Packages installed successfully." # Show success emoji after installation log_message "Packages installed successfully." fi # Check if the third file (service script) exists and execute it if [ -e "$3" ]; then echo "" - echo "Enabling services ⚙️" + echo "Enabling services ⚙️" # Show gear emoji for service enabling echo "" log_message "Enabling services from: $3" if ! sudo bash - <$3; then + # If enabling services fails, show an error with a cross emoji echo "❌ Error enabling services. Check logs for more details." log_message "Error enabling services from: $3" - exit 1 + exit 1 # Exit the script if enabling services fails fi else + # If the service script doesn't exist, show a warning with a caution emoji echo "⚠️ Service script ($3) not found! Skipping services." log_message "Service script ($3) not found." fi # Final prompt echo "" -read -p "Press enter to return to Snigdha OS Assistant 🛑" +read -p "Press enter to return to Snigdha OS Assistant 🛑" # Show stop sign emoji for returning to the assistant # End of script -log_message "Script execution completed successfully 🎉" +log_message "Script execution completed successfully 🎉" # Log success with a celebration emoji