Advertisement
Guest User

observium distro script

a guest
Nov 1st, 2015
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.30 KB | None | 0 0
  1. #!/bin/sh
  2. # Detects which OS and if it is Linux then it will detect which Linux Distribution.
  3.  
  4. OS=`uname -s`
  5. REV=`uname -r`
  6. MACH=`uname -m`
  7.  
  8. if [ "${OS}" = "SunOS" ] ; then
  9.   OS=Solaris
  10.   ARCH=`uname -p`
  11.   OSSTR="${OS} ${REV}(${ARCH} `uname -v`)"
  12. elif [ "${OS}" = "AIX" ] ; then
  13.   OSSTR="${OS} `oslevel` (`oslevel -r`)"
  14. elif [ "${OS}" = "Linux" ] ; then
  15.   KERNEL=`uname -r`
  16.   if [ -f /etc/redhat-release ] ; then
  17.     DIST=$(cat /etc/redhat-release | awk '{print $1}')
  18.     if [ "${DIST}" = "CentOS" ]; then
  19.       DIST="CentOS"
  20.     elif [ "${DIST}" = "Mandriva" ]; then
  21.       DIST="Mandriva"
  22.       PSEUDONAME=`cat /etc/mandriva-release | sed s/.*\(// | sed s/\)//`
  23.       REV=`cat /etc/mandriva-release | sed s/.*release\ // | sed s/\ .*//`
  24.     elif [ "${DIST}" = "Fedora" ]; then
  25.       DIST="Fedora"
  26.     else
  27.       DIST="RedHat"
  28.     fi
  29.  
  30.     PSEUDONAME=`cat /etc/redhat-release | sed s/.*\(// | sed s/\)//`
  31.     REV=`cat /etc/redhat-release | sed s/.*release\ // | sed s/\ .*//`
  32.   elif [ -f /etc/SuSE-release ] ; then
  33.     DIST=`cat /etc/SuSE-release | tr "\n" ' '| sed s/VERSION.*//`
  34.     REV=`cat /etc/SuSE-release | tr "\n" ' ' | sed s/.*=\ //`
  35.   elif [ -f /etc/mandrake-release ] ; then
  36.     DIST='Mandrake'
  37.     PSEUDONAME=`cat /etc/mandrake-release | sed s/.*\(// | sed s/\)//`
  38.     REV=`cat /etc/mandrake-release | sed s/.*release\ // | sed s/\ .*//`
  39.   elif [ -f /etc/debian_version ] ; then
  40.     if [ -f /etc/mailcleaner/etc/mailcleaner/version.def ] ; then
  41.       DIST="MailCleaner"
  42.       REV=`cat /etc/mailcleaner/etc/mailcleaner/version.def`
  43.     else
  44.       DIST="Debian `cat /etc/debian_version`"
  45.       REV=""
  46.     fi
  47.   fi
  48.  
  49.   if [ -f /etc/UnitedLinux-release ] ; then
  50.     DIST="${DIST}[`cat /etc/UnitedLinux-release | tr "\n" ' ' | sed s/VERSION.*//`]"
  51.   fi
  52.  
  53.   if [ -f /etc/lsb-release ] ; then
  54.     LSB_DIST="`cat /etc/lsb-release | grep DISTRIB_ID | cut -d "=" -f2`"
  55.     LSB_REV="`cat /etc/lsb-release | grep DISTRIB_RELEASE | cut -d "=" -f2`"
  56.     if [ "$LSB_DIST" != "" ] ; then
  57.       DIST=$LSB_DIST
  58.       REV=$LSB_REV
  59.     fi
  60.   fi
  61.  
  62. #  OSSTR="${OS} ${DIST} ${REV}(${PSEUDONAME} ${KERNEL} ${MACH})"
  63.   OSSTR="${DIST} ${REV}"
  64. elif [ "${OS}" = "Darwin" ] ; then
  65.   if [ -f /usr/bin/sw_vers ] ; then
  66.     OSSTR=`/usr/bin/sw_vers|grep -v Build|sed 's/^.*:.//'| tr "\n" ' '`
  67.   fi
  68. fi
  69.  
  70. echo ${OSSTR}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement