Created
October 8, 2013 07:44
-
-
Save josephbolus/6881075 to your computer and use it in GitHub Desktop.
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 | |
############################################################ | |
# Print OS summary (OS, ARCH, VERSION) | |
############################################################ | |
function print_info { | |
echo -n -e '\e[1;36m' | |
echo -n $1 | |
echo -e '\e[0m' | |
} | |
function show_os_arch_version { | |
# Thanks for Mikel (http://unix.stackexchange.com/users/3169/mikel) for the code sample which was later modified a bit | |
# http://unix.stackexchange.com/questions/6345/how-can-i-get-distribution-name-and-version-number-in-a-simple-shell-script | |
ARCH=$(uname -m | sed 's/x86_//;s/i[3-6]86/32/') | |
if [ -f /etc/lsb-release ]; then | |
. /etc/lsb-release | |
OS=$DISTRIB_ID | |
VERSION=$DISTRIB_RELEASE | |
elif [ -f /etc/debian_version ]; then | |
# Work on Debian and Ubuntu alike | |
OS=$(lsb_release -si) | |
VERSION=$(lsb_release -sr) | |
elif [ -f /etc/redhat-release ]; then | |
# Add code for Red Hat and CentOS here | |
OS=Redhat | |
VERSION=$(uname -r) | |
else | |
# Pretty old OS? fallback to compatibility mode | |
OS=$(uname -s) | |
VERSION=$(uname -r) | |
fi | |
OS_SUMMARY=$OS | |
OS_SUMMARY+=" " | |
OS_SUMMARY+=$VERSION | |
OS_SUMMARY+=" " | |
OS_SUMMARY+=$ARCH | |
OS_SUMMARY+="bit" | |
print_info "$OS_SUMMARY" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment