mirror of
https://github.com/Snigdha-OS/snigdhaos-blackbox.git
synced 2025-09-21 20:15:02 +02:00
⚡️ perf(_blank): more efficient
This commit is contained in:
@@ -1,24 +1,80 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
if [ -e "$1" ]; then
|
# Function to print usage instructions
|
||||||
|
usage() {
|
||||||
|
echo "Usage: $0 [<file1>] <package_list_file> [<service_script_file>]"
|
||||||
|
echo ""
|
||||||
|
echo "Arguments:"
|
||||||
|
echo " <file1> Optional. Any file or directory to check before setup."
|
||||||
|
echo " <package_list_file> Required. A file containing a list of packages to install."
|
||||||
|
echo " <service_script_file> Optional. A script to enable services (if any)."
|
||||||
|
echo ""
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Display help if the user asks for it
|
||||||
|
if [ "$1" == "--help" ]; then
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if package list file is provided and valid
|
||||||
|
if [ -z "$2" ] || [ ! -f "$2" ]; then
|
||||||
|
echo "Error: Package list file is missing or invalid."
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if service script file is provided and valid
|
||||||
|
if [ -n "$3" ] && [ ! -f "$3" ]; then
|
||||||
|
echo "Warning: Service script file ($3) not found. Skipping service enabling."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Step 1: Optional Setup Preparation
|
||||||
|
if [ -n "$1" ] && [ -e "$1" ]; then
|
||||||
echo ""
|
echo ""
|
||||||
echo "Preparing Setup..."
|
echo "Preparing Setup..."
|
||||||
echo ""
|
echo ""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Step 2: Installing Packages
|
||||||
echo ""
|
echo ""
|
||||||
echo "Installing Packages! Please Wait..."
|
echo "Installing Packages! Please Wait..."
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
installable_packages=$(comm -12 <(pacman -Slq | sort) <(sed s/\\s/\\n/g - <$2 | sort))
|
# Generate the list of installable packages
|
||||||
sudo pacman -S --needed $installable_packages && rm $2 || { read -p "Error Occured! Press Enter to Return To Snigdha OS BlackBox"; exit; }
|
installable_packages=$(comm -12 <(pacman -Slq | sort) <(sed 's/\s/\n/g' - <"$2" | sort))
|
||||||
|
|
||||||
if [ -e "$3" ]; then
|
# Check if any valid packages are available
|
||||||
echo ""
|
if [ -z "$installable_packages" ]; then
|
||||||
echo "Enabling Services(If Any)"
|
echo "No packages found to install from the provided list."
|
||||||
echo ""
|
exit 1
|
||||||
sudo bash - <$3
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Attempt to install the packages
|
||||||
|
echo "Installing the following packages: $installable_packages"
|
||||||
|
if ! sudo pacman -S --needed $installable_packages; then
|
||||||
|
echo "Error: Package installation failed. Please check the package list and try again."
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
# Remove the package list file after successful installation
|
||||||
|
rm "$2"
|
||||||
|
echo "Packages installed successfully."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Step 3: Enabling Services (if any)
|
||||||
|
if [ -n "$3" ] && [ -f "$3" ]; then
|
||||||
|
echo ""
|
||||||
|
echo "Enabling Services (If Any)..."
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# Execute the service script with sudo
|
||||||
|
if ! sudo bash - <"$3"; then
|
||||||
|
echo "Error: Failed to enable services from the script. Please check the script."
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "Services enabled successfully."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Final prompt
|
||||||
echo ""
|
echo ""
|
||||||
read -p "Press Enter To Return to Snigdha OS Blackbox."
|
read -p "Press Enter To Return to Snigdha OS Blackbox."
|
||||||
|
Reference in New Issue
Block a user