Created
January 8, 2014 21:02
-
-
Save coderofsalvation/8324609 to your computer and use it in GitHub Desktop.
return distro name in a lower string
This file contains hidden or 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
# return distro name in a lower string | |
function getdistro() | |
{ | |
_distro_var_DIST_INFO="/etc/lsb-release" | |
if [ -r "$_distro_var_DIST_INFO" ]; then | |
. "$_distro_var_DIST_INFO" | |
fi | |
if [ -z "$DISTRIB_ID" ]; then | |
_distro_var_DISTRIB_ID="Unknown"; | |
if [ -f /etc/arch-release ]; then | |
_distro_var_DISTRIB_ID="Arch" | |
elif [ -r /etc/knoppix-version ]; then | |
_distro_var_DISTRIB_ID="Knoppix" | |
elif [ -r /etc/sidux-version ]; then | |
_distro_var_DISTRIB_ID="Sidux" | |
elif [ -r /etc/debian_version ]; then | |
_distro_var_DISTRIB_ID="Debian" | |
elif [ -r /etc/issue ]; then | |
_distro_var_DISTRIB_ID=$(cat /etc/issue.net | awk '{print $1}') | |
if [ X"$_distro_var_DISTRIB_ID" = X"Ubuntu" ]; then | |
_distro_var_DISTRIB_ID=Ubuntu | |
fi | |
elif [ -r /etc/gentoo-release ]; then | |
_distro_var_DISTRIB_ID="Gentoo" | |
elif [ -f /etc/lfs-version ]; then | |
_distro_var_DISTRIB_ID="LFS" | |
elif [ -r /etc/pclinuxos-release ]; then | |
_distro_var_DISTRIB_ID="PCLinuxOS" | |
elif [ -f /etc/mandriva-release ] || [ -f /etc/mandrake-release ]; then | |
_distro_var_DISTRIB_ID="Mandriva" | |
elif [ -f /etc/redhat-release ]; then | |
_distro_var_DISTRIB_ID="RedHat" | |
elif [ -f /etc/fedora-release ]; then | |
_distro_var_DISTRIB_ID="Fedora" | |
elif [ -r /etc/vector-version ]; then | |
_distro_var_DISTRIB_ID="VectorLinux" | |
elif [ -r /etc/slackware-version ]; then | |
_distro_var_DISTRIB_ID="$(cat /etc/slackware-version)" | |
elif [ -f /etc/release ]; then | |
_distro_var_DISTRIB_ID="Solaris" | |
elif [ -r /etc/SuSE-release ]; then | |
_distro_var_DISTRIB_ID="$(grep -i suse /etc/SuSE-release)" | |
elif [ -f /etc/yellowdog-release ]; then | |
_distro_var_DISTRIB_ID="YellowDog Linux" | |
elif [ -f /etc/zenwalk-version ]; then | |
_distro_var_DISTRIB_ID="Zenwalk" | |
fi | |
printf "%s\\n" "$_distro_var_DISTRIB_ID" | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | |
else | |
printf "%s\\n" "$DISTRIB_ID" | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment