Skip to content

Instantly share code, notes, and snippets.

@abdul
Created May 28, 2020 15:03
Show Gist options
  • Save abdul/567ad67b9185fc8a5e14a7a45d13741c to your computer and use it in GitHub Desktop.
Save abdul/567ad67b9185fc8a5e14a7a45d13741c to your computer and use it in GitHub Desktop.
Detect different OS and Distros and run package install commands
function install()
{
echo "$1"
package="$1"
case `uname` in
Linux )
LINUX=1
if type "yum" > /dev/null; then
# install foobar here
rpm -qa | grep -qw "$package" || yum install "$package" -y
fi
if type "apt-get" > /dev/null; then
# install foobar here
dpkg -l | grep -qw "$package" || apt-get install "$package" -y;
fi
;;
Darwin )
DARWIN=1
if type "brew" > /dev/null; then
# install foobar here
brew list | grep -qw "$package" || brew install "$package"
fi
;;
* )
# Handle AmgiaOS, CPM, and modified cable modems here.
;;
esac
}
for i in "$@"; do install "$i"; done
@abdul
Copy link
Author

abdul commented May 28, 2020

  1. Download install_pkg.sh
  2. chmod +x install_pkg.sh
  3. ./install_pkg.sh stow vim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment