#!/bin/sh
#*****************************************************************************
#FILE:               distribution
#LANGUAGE:           sh
#SYSTEM:             POSIX
#USER-INTERFACE:     NONE
#DESCRIPTION
#
#    Detects the running system/distribution/release.
#
#AUTHORS
#    <PJB> Pascal Bourguignon <pjb@informatimago.com>
#MODIFICATIONS
#    2003-11-25 <PJB> Added this header.
#BUGS
#LEGAL
#    GPL
#
#    Copyright Pascal Bourguignon 2003 - 2003
#
#    This program is free software; you can redistribute it and/or
#    modify it under the terms of the GNU General Public License
#    as published by the Free Software Foundation; either version
#    2 of the License, or (at your option) any later version.
#
#    This program is distributed in the hope that it will be
#    useful, but WITHOUT ANY WARRANTY; without even the implied
#    warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
#    PURPOSE.  See the GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public
#    License along with this program; if not, write to the Free
#    Software Foundation, Inc., 59 Temple Place, Suite 330,
#    Boston, MA 02111-1307 USA
#*****************************************************************************

# Sys-V systems have uname. It may also exist as an add-on on other systems.
systeme=`uname` || systeme="unknown"
distrib="unknown"
release="unknown"


case "$systeme" in

Linux)
    if [ -e /etc/mandrake-release ] ; then
        distrib=mandrake
        release=`awk '{print $4}' < /etc/mandrake-release`
    elif [ -e /etc/redhat-release ] ; then
        distrib=redhat
        release=`awk '{print $4}' < /etc/redhat-release`
    elif [ -e /etc/SuSE-release ] ; then
        distrib=SuSE
        release=`grep VERSION /etc/SuSE-release|sed -e 's/.*= *//'`
    fi
    ;;

NEXTSTEP)
    # A special case, where a uname has been installed on NeXTSTEP.
    distrib=NeXT
    release=`uname -r`
    ;;

unknown)

    # Mach systems:
    h=`hostinfo` || h="unknown"

    case "$h" in
    Mach*)
        # Well, this works on NeXTSTEP Mach:
        distrib=`echo "$h" | awk '{print $4}'`
        release=`echo "$h" | awk '{print $6}'`
        ;;
    *)
        ;;
    esac
    ;;

*)
    ;;
esac

echo $systeme $distrib $release
exit 0
#### distribution                     -- 2003-11-25 05:58:19 -- pascal   ####
ViewGit