Skip to content

Instantly share code, notes, and snippets.

@antevens
Created November 22, 2013 17:02
Show Gist options
  • Save antevens/7603300 to your computer and use it in GitHub Desktop.
Save antevens/7603300 to your computer and use it in GitHub Desktop.
Bash figure out which OS we are running on
# 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