discover_os 1.16 KB
Newer Older
incardon's avatar
incardon committed
1 2 3 4 5 6 7 8 9
#! /bin/bash

function discover_os() {
platform=unknown


  if [[ "$OSTYPE" == "linux-gnu" ]]; then
        echo -e "We are on\033[1;34m LINUX \033[0m"
        platform=linux
Yaser Afshar's avatar
Yaser Afshar committed
10 11 12
  elif [[ "$OSTYPE" == "linux" ]]; then
        echo -e "We are on\033[1;34m LINUX \033[0m"
        platform=linux
incardon's avatar
incardon committed
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
  elif [[ "$OSTYPE" == "darwin"* ]]; then
        echo -e "We are on\033[1;34m MAC OSX \033[0m"
        platform=osx
  elif [[ "$OSTYPE" == "cygwin" ]]; then
        echo -e "We are on\033[1;34m CYGWIN \033[0m"
        echo "This platform is not supported"
        exit 1
  elif [[ "$OSTYPE" == "msys" ]]; then
        echo -e "We are on\033[1;34m Microsoft Window \033[0m"
        echo "This platform is not supported"
        exit 1
  elif [[ "$OSTYPE" == "win32" ]]; then
        echo -e "We are on\033[1;34m Microsoft Window \033[0m"
        echo "This platform is not supported"
        exit 1
  elif [[ "$OSTYPE" == "freebsd"* ]]; then
        echo -e "We are on\033[1;34m FREEBSD \033[0m"
        echo "This platform is not supported"
        exit 1
  else
        echo -e "We are on an\033[1;34m unknown OS \033[0m"
        echo "This platform is not supported"
        exit 1
  fi
}