Last active
February 19, 2018 09:59
-
-
Save ayinlaaji/c7d9f9766256a50badeb0c2e1d32d63b to your computer and use it in GitHub Desktop.
Script to determine operation system version
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
#!/bin/bash | |
# Determine OS platform | |
UNAME=$(uname | tr "[:upper:]" "[:lower:]") | |
# If Linux or darwin, try to determine specific distribution | |
if [ "$UNAME" == "linux" ] ; then | |
# If available, use LSB to identify distribution | |
if [ -f /etc/lsb-release -o -d /etc/lsb-release.d ]; then | |
export DISTRO=$(lsb_release -i | cut -d: -f2 | sed s/'^\t'//) | |
# Otherwise, use release info file | |
else | |
export DISTRO=$(ls -d /etc/[A-Za-z]*[_-][rv]e[lr]* | grep -v "lsb" | cut -d'/' -f3 | cut -d'-' -f1 | cut -d'_' -f1) | |
fi | |
echo $DISTRO | |
fi | |
if [ "$UNAME" == "darwin" ] ; then | |
echo $UNAME | |
echo "Na mac be this" | |
fi | |
# For everything else (or if above failed), just use generic identifier | |
[ "$DISTRO" == "" ] && export DISTRO=$UNAME | |
unset UNAME |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment