Skip to content
Snippets Groups Projects
discover_os 1.46 KiB
Newer Older
Pietro Incardona's avatar
Pietro Incardona committed
#! /bin/bash

function discover_os() {
platform=unknown
arch=$(uname -m)

  if [[ "$OSTYPE" == "linux-gnu" ]]; then
        echo -e "We are on\033[1;34m LINUX \033[0m, with architecture \033[1;34m$arch\033[0m"
        platform=linux
  elif [[ "$OSTYPE" == "linux" ]]; then
        echo -e "We are on\033[1;34m LINUX \033[0m, with architecture \033[1;34m$arch\033[0m"
        platform=linux
  elif [[ "$OSTYPE" == "darwin"* ]]; then
        echo -e "We are on\033[1;34m MAC OSX \033[0m, with architecture \033[1;34m$arch\033[0m"
        platform=osx
  elif [[ "$OSTYPE" == "cygwin" ]]; then
        echo -e "We are on\033[1;34m CYGWIN \033[0m, with architecture \033[1;34m$arch\033[0m"
	platform=cygwin
  elif [[ "$OSTYPE" == "msys" ]]; then
        echo -e "We are on\033[1;34m Microsoft Window \033[0m, with architecture \033[1;34m$arch\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, with architecture \033[1;34m$arch\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, with architecture \033[1;34m$arch\033[0m"
        echo "This platform is not supported"
        exit 1
  else
        echo -e "We are on an\033[1;34m unknown OS \033[0m, with architecture \033[1;34m$arch\033[0m"
        echo "This platform is not supported"
        exit 1
  fi


}