Created
May 28, 2020 15:03
-
-
Save abdul/567ad67b9185fc8a5e14a7a45d13741c to your computer and use it in GitHub Desktop.
Detect different OS and Distros and run package install commands
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
chmod +x install_pkg.sh
./install_pkg.sh stow vim