Created
November 22, 2013 17:02
-
-
Save antevens/7603300 to your computer and use it in GitHub Desktop.
Bash figure out which OS we are running on
This file contains 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
# Figure out OS | |
osfamily='Unknown' | |
apt-get help > /dev/null 2>&1 && osfamily='Debian' | |
yum help help > /dev/null 2>&1 && osfamily='RedHat' | |
if [ "${OS}" == 'SunOS' ]; then osfamily='Solaris'; fi | |
if [ `echo "${OSTYPE}" | grep 'darwin'` ]; then osfamily='Darwin'; fi | |
if [ "${OSTYPE}" == 'cygwin' ]; then osfamily='Cygwin'; fi | |
echo "Detected OS based on: ${osfamily}" | |
case ${osfamily} in | |
"RedHat") | |
# Redhat based | |
sudo yum install puppet-server | |
;; | |
"Debian") | |
# Debian based | |
sudo apt-get install puppet | |
;; | |
"Darwin") | |
# Mac based | |
......... | |
;; | |
"Solaris") | |
# Solaris | |
.......... | |
;; | |
*) | |
# Unknown, use generic method or exit? | |
.......... | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment