differentiate between a command and a package

This commit is contained in:
Josh Ashton
2024-02-12 08:54:05 -07:00
parent 43638d26ca
commit 8b50750059
+9 -8
View File
@@ -1,5 +1,6 @@
#!/bin/zsh #!/bin/zsh
COMMAND=$1 COMMAND=$1
PACKAGE=$2
error() { error() {
echo "Your package manager is not supported." echo "Your package manager is not supported."
@@ -16,22 +17,22 @@ then
DISTRO=$(cat /etc/os-release | grep -oP '(?<=^ID=).+' | tr -d '"') DISTRO=$(cat /etc/os-release | grep -oP '(?<=^ID=).+' | tr -d '"')
if [[ $DISTRO == "arch" ]]; then if [[ $DISTRO == "arch" ]]; then
sudo pacman -S $COMMAND sudo pacman -S $PACKAGE
exit 0 exit 0
elif [[ $DISTRO == "archarm" ]]; then elif [[ $DISTRO == "archarm" ]]; then
sudo pacman -S $COMMAND sudo pacman -S $PACKAGE
exit 0 exit 0
elif [[ $DISTRO == "ubuntu" ]]; then elif [[ $DISTRO == "ubuntu" ]]; then
sudo apt-get install $COMMAND sudo apt-get install $PACKAGE
exit 0 exit 0
elif [[ $DISTRO == "fedora" ]]; then elif [[ $DISTRO == "fedora" ]]; then
sudo dnf install $COMMAND sudo dnf install $PACKAGE
exit 0 exit 0
elif [[ $DISTRO == "centos" ]]; then elif [[ $DISTRO == "centos" ]]; then
sudo yum install $COMMAND sudo yum install $PACKAGE
exit 0 exit 0
elif [[ $DISTRO == "debian" ]]; then elif [[ $DISTRO == "debian" ]]; then
sudo apt install $COMMAND sudo apt install $PACKAGE
exit 0 exit 0
else else
error error
@@ -42,11 +43,11 @@ then
if command -v "brew" &> /dev/null if command -v "brew" &> /dev/null
then then
brew install $COMMAND brew install $PACKAGE
elif command -v "port" &> /dev/null elif command -v "port" &> /dev/null
then then
sudo port install $COMMAND sudo port install $PACKAGE
else else
echo "Homebrew or MacPorts not found. Please install one of them before running this script." echo "Homebrew or MacPorts not found. Please install one of them before running this script."