Created
March 5, 2019 11:18
-
-
Save john-auld/237cc08fb8fd3767586c7e71d4bd906c to your computer and use it in GitHub Desktop.
Identify Linux OS
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 | |
detect_os (){ | |
# Check the OS version | |
if [ -f /etc/os-release ]; then | |
source /etc/os-release | |
else | |
# Most likely a Centos5/6 box | |
if [ -f /etc/redhat-release ]; then | |
if grep -iq centos "/etc/redhat-release"; then | |
ID="centos" | |
fi | |
fi | |
fi | |
} | |
##### | |
CentOS 7 | |
cat /etc/os-release | |
NAME="CentOS Linux" | |
VERSION="7 (Core)" | |
ID="centos" | |
ID_LIKE="rhel fedora" | |
VERSION_ID="7" | |
PRETTY_NAME="CentOS Linux 7 (Core)" | |
ANSI_COLOR="0;31" | |
CPE_NAME="cpe:/o:centos:centos:7" | |
HOME_URL="https://www.centos.org/" | |
BUG_REPORT_URL="https://bugs.centos.org/" | |
CENTOS_MANTISBT_PROJECT="CentOS-7" | |
CENTOS_MANTISBT_PROJECT_VERSION="7" | |
REDHAT_SUPPORT_PRODUCT="centos" | |
REDHAT_SUPPORT_PRODUCT_VERSION="7" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
source