Open MPI logo

MTT Devel Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all MTT Users mailing list

Subject: Re: [MTT users] Patch for whatami (new sles10 lsb-release file format)
From: Jeff Squyres (jsquyres_at_[hidden])
Date: 2008-10-31 13:01:02


Re-sending to the MTT list, because I think our listserver will
automatically block Brian (I'll add him to the whitelist for future
posts!).

On Oct 31, 2008, at 12:56 PM, Brian Elliott Finley wrote:

> I've taken a look at Ethan's patch. I like the patch, and I like the
> concept. I made a small modification to it, breaking it out into a
> subroutine, which I think makes the logic a bit easier to follow.
>
> Take a look and try this out. If it works for you, I'll commit it.
>
> Cheers, -Brian
>
>
>
>
> Jeff Squyres wrote:
>> Let's commit Ethan's patch, then, and see what Brian wants to do
>> upstream.
>>
>> On Oct 31, 2008, at 11:57 AM, Tim Mattox wrote:
>>
>>> Sorry about that, I missed that Ethan had supplied a workaround
>>> patch. Oops.
>>> Ethan's patch works for me on sles9.
>>>
>>> On Fri, Oct 31, 2008 at 11:42 AM, Jeff Squyres <jsquyres_at_[hidden]>
>>> wrote:
>>>> Ok. Does Ethan's patch work for you, or should we just revert to
>>>> our
>>>> prior
>>>> version until upstream is fixed?
>>>>
>>>> On Oct 31, 2008, at 11:39 AM, Tim Mattox wrote:
>>>>
>>>>> The new version of whatami is what broke sles9. That new version
>>>>> assumes
>>>>> that if an /etc/lsb-release file exists that it has info about
>>>>> what
>>>>> distribution it is.
>>>>> SLES seems to only put in what LSB it conforms to (the LSB_VERSION
>>>>> environment variable).
>>>>> Whatami should check if it got all the info it needs from the
>>>>> lsb-release
>>>>> file,
>>>>> and if not, fall back to something else that worked before.
>>>>>
>>>>> I just reverted the whatami I am using on BigRed to MTT's r1236
>>>>> and it
>>>>> works
>>>>> again. No rush to fix this for me, but it is bad that whatami
>>>>> seems to
>>>>> now
>>>>> be broken for two major SLES releases (9 & 10).
>>>>>
>>>>> On Fri, Oct 31, 2008 at 11:29 AM, Jeff Squyres
>>>>> <jsquyres_at_[hidden]>
>>>>> wrote:
>>>>>>
>>>>>> Which patch broke BigRed -- Ethan's patch, or Brian's original
>>>>>> new
>>>>>> version
>>>>>> of whatami?
>>>>>>
>>>>>>
>>>>>> On Oct 31, 2008, at 11:20 AM, Tim Mattox wrote:
>>>>>>
>>>>>>> This change also broke whatami for sles9 (which happens to be
>>>>>>> what
>>>>>>> our
>>>>>>> BigRed
>>>>>>> PPC cluster is running).
>>>>>>>
>>>>>>> 2008/10/30 Ethan Mallove <ethan.mallove_at_[hidden]>:
>>>>>>>>
>>>>>>>> Hi Brian,
>>>>>>>>
>>>>>>>> I'm using your "whatami" in the MPI Testing Tool (MTT), but
>>>>>>>> I think a recent change to it broke for our sles10 system.
>>>>>>>> We have an lsb-release file that is different from what
>>>>>>>> "whatami" expects:
>>>>>>>>
>>>>>>>> $ cat /etc/lsb-release
>>>>>>>>
>>>>>>>>
>>>>>>>> LSB_VERSION="core-2.0-noarch:core-3.0-noarch:core-2.0-
>>>>>>>> x86_64:core-3.0-x86_64"
>>>>>>>>
>>>>>>>> $ uname -a
>>>>>>>> Linux burl-ct-v20z-6 2.6.16.46-0.12-smp #1 SMP Thu May 17
>>>>>>>> 14:00:09 UTC
>>>>>>>> 2007 x86_64 x86_64 x86_64 GNU/Linux
>>>>>>>>
>>>>>>>> I attached a patch.
>>>>>>>>
>>>>>>>> Regards,
>>>>>>>> Ethan
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> mtt-users mailing list
>>>>>>>> mtt-users_at_[hidden]
>>>>>>>> http://www.open-mpi.org/mailman/listinfo.cgi/mtt-users
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> Tim Mattox, Ph.D. - http://homepage.mac.com/tmattox/
>>>>>>> tmattox_at_[hidden] || timattox_at_[hidden]
>>>>>>> I'm a bright... http://www.the-brights.net/
>>>>>>> _______________________________________________
>>>>>>> mtt-users mailing list
>>>>>>> mtt-users_at_[hidden]
>>>>>>> http://www.open-mpi.org/mailman/listinfo.cgi/mtt-users
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Jeff Squyres
>>>>>> Cisco Systems
>>>>>>
>>>>>> _______________________________________________
>>>>>> mtt-users mailing list
>>>>>> mtt-users_at_[hidden]
>>>>>> http://www.open-mpi.org/mailman/listinfo.cgi/mtt-users
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Tim Mattox, Ph.D. - http://homepage.mac.com/tmattox/
>>>>> tmattox_at_[hidden] || timattox_at_[hidden]
>>>>> I'm a bright... http://www.the-brights.net/
>>>>> _______________________________________________
>>>>> mtt-users mailing list
>>>>> mtt-users_at_[hidden]
>>>>> http://www.open-mpi.org/mailman/listinfo.cgi/mtt-users
>>>>
>>>>
>>>> --
>>>> Jeff Squyres
>>>> Cisco Systems
>>>>
>>>> _______________________________________________
>>>> mtt-users mailing list
>>>> mtt-users_at_[hidden]
>>>> http://www.open-mpi.org/mailman/listinfo.cgi/mtt-users
>>>>
>>>
>>>
>>>
>>> --
>>> Tim Mattox, Ph.D. - http://homepage.mac.com/tmattox/
>>> tmattox_at_[hidden] || timattox_at_[hidden]
>>> I'm a bright... http://www.the-brights.net/
>>> _______________________________________________
>>> mtt-users mailing list
>>> mtt-users_at_[hidden]
>>> http://www.open-mpi.org/mailman/listinfo.cgi/mtt-users
>>
>>
>
> --
> Brian Elliott Finley
> CIS / Argonne National Laboratory
> Office: 630.252.4742
> Mobile: 630.631.6621
> #!/bin/sh
> #
> # whatami
> # Prints a string describing the system type.
> #
> # $Id:
> #
> # "whatami" is part of Msys, the MCS Systems Administration Toolkit.
> # For more information, see http://www.mcs.anl.gov/systems/software/ .
> #
> # Copyright (c) University of Chicago 1999.
> # See the COPYRIGHT file in the distribution for details on the
> copyright.
> #
> #
> =
> =
> =
> =
> =
> ======================================================================
> #
> # Description:
> #
> # Try to figure out what type of machine we're running on.
> #
> # The string returned is one that is useful to distinguish between
> # system architectures, where we think of machines with the same
> architectures
> # as machines that should be using the same set of compiled software.
> #
> # One would think that you could already get such a string from an
> existing
> # UNIX utility. But, no, this appears not to be the case. "uname"
> and
> # "arch" come close, but are inconsistent. Thus this script is
> basically
> # a wrapper around those.
> #
> # Several other programs in the Msys distribution (and innumerable
> scripts
> # around MCS) call this program.
> #
> #
> =
> =
> =
> =
> =
> ======================================================================
> # TODO:
> #
> # Authors:
> #
> # Remy Evard <evard_at_[hidden]>
> # - Version 1.0 and 2.0:
> # 2003.03.12 Brian Elliott Finley <finley_at_[hidden]>
> # - added get_linux_type function to provide a three part type:
> # Ie: linux-debian_unstable-ia32, or linux-sles8-ia64
> # - added -o (option_test)
> # 2003.10.16 Larry A. Diegel <diegella_at_[hidden]>
> # - patch for aix-5
> # 2004.01.17 Brian Elliott Finley <finley_at_[hidden]>
> # - modified --help output
> # - accept --long-options as well as -s (short options)
> # 2004.02.04 Brian Elliott Finley <finley_at_[hidden]>
> # - identify macosx on ppc and ppc64
> # - identify linux on Opteron (x86_64)
> # 2004.02.26 Brian Elliott Finley <finley_at_[hidden]>
> # - add redhat AS
> # - add mandrake 9.1
> # - add redhat 9
> # - add redhat 8
> # 2005.01.19 Susan Coghlan <smc_at_[hidden]>
> # - add sles8 PPC64
> # 2005.02.01 Susan Coghlan <smc_at_[hidden]>
> # - add sles9
> # 2005.03.07 Brian Elliott Finley
> # - add rhel, and deal w/different versions, sub-distros (AS|
> EL|WS)
> # 2005.04.21 Peter Couvares <pfc_at_[hidden]>
> # - add tao linux 1.0, cygwin
> # 2005.04.22 Ti Leggett <leggett_at_[hidden]>
> # - add Gentoo
> # 2006.03.14 JP Navarro <navarro_at_[hidden]>
> # - more precise AIX type, aix-{version}.{release}
> # - add Cray Rocks 1.3
> # - add CentOS 4.0
> # - add SGI ProPack 3 -> rhel3
> # - add SGI ProPack 4 -> sles9
> # - add SuSE 9.1
> # 2006.03.21 JP Navarro <navarro_at_[hidden]>
> # - add Fedora Core <n>
> # - drop RHEL sub-distros
> # - ClassAd output support
> # - XML output support
> # 2006.03.30 Ti Leggett <leggett_at_[hidden]>
> # - Fixed CentOS to recognize 4.x instead of only 4.0
> # 2006.10.17 JP Navarro <navarro_at_[hidden]>
> # - Add SuSE 10.1
> # 2007.01.02 JP Navarro <navarro_at_[hidden]>
> # - Add SuSE 10.2
> # 2007.02.06 Ti Leggett <leggett_at_[hidden]>
> # - Add MacOS on Intel support
> # 2008.10.14 Brian Finley <finley_at_[hidden]>
> # - Add generic lsb_release support
> # - includes CentOS 5.x
> # 2008.10.30 Ethan Mallove <ethan.mallove_at_[hidden]>
> # - Support two different SuSE 10 lsb-release file formats
> # 2008.10.30 Brian Finley <finley_at_[hidden]>
> # - Turn Ethan's code and concept into a subroutine.
> #
> # Authors -- Be sure to increment the version number appropriately!
> #
> #
> =
> =
> =
> =
> =
> ======================================================================
> #
> # Exit codes:
> #
> # 0 on success
> # 1 on failure to grok arguments or figure out architecture details
> #
> #
> =
> =
> =
> =
> =
> ======================================================================
> #
> # Machine type strings:
> #
> # sun4
> # irix-5
> # irix-6
> # solaris
> # freebsd
> # aix-{version}.{release}
> # aux
> # hpux
> # mips
> # osf
> # digital
> # next
> # linux-{distro_and_version}-{architecture}
> # solaris86
> # solarishp
> # nt
> # ntalpha
> #
> #
> =
> =
> =
> =
> =
> ======================================================================
>
> program=`echo $0 | sed 's:.*/::'`
> version="2008.10.31"
>
> ################################################################################
> #
> # Subroutines
> #
>
> get_lsb_info_if_available()
> {
> if [ -f /etc/lsb-release ]; then
> #
> # 1) Example contents of /etc/lsb-release from Ubuntu
> Hardy:
> # DISTRIB_ID=Ubuntu
> # DISTRIB_RELEASE=8.04
> # DISTRIB_CODENAME=hardy
> # DISTRIB_DESCRIPTION="Ubuntu hardy (development branch)"
> # 2) Example contents of /etc/lsb-release from SLES 9:
> # LSB_VERSION="core-2.0-noarch:core-3.0-noarch:core-2.0-
> x86_64:core-3.0-x86_64"
> . /etc/lsb-release
>
> elif [ -x /usr/bin/lsb_release ]; then
> DISTRIB_ID=$(/usr/bin/lsb_release -i | sed -e 's/
> ^Distributor ID:[[:space:]]//')
> DISTRIB_RELEASE=$(/usr/bin/lsb_release -r | sed -e 's/
> ^Release:[[:space:]]//')
> fi
> }
>
> get_linux_type()
> {
>
> ############################################################################
> #
> # Step 1) Determine $hardware string (in Linux terms, based
> on architecture
> # names used by the Linux kernel. See /usr/src/
> linux/hardware/ for
> # details).
> #
> case $uhardware in
> alpha)
> hardware=alpha
> ;;
> i386|i486|i586|i686)
> hardware=ia32
> ;;
> ppc64)
> hardware=ppc64
> ;;
> ia64)
> hardware=ia64
> ;;
> x86_64)
> hardware=x86_64
> ;;
> *)
>
> hardware=unknown_hardware_please_send_us_a_patch
> ;;
> esac
> #
>
> ############################################################################
>
>
> ############################################################################
> #
> # Step 2) Determine $distro (distribution) string
> #
> # NOTES: Put newer tests higher up, as they'll most
> # likely get hit first. -BEF-
> # NOTES: But, make sure that newer programatic tests
> don't override
> # older tests with different results. -BEF-
> #
>
> #
> # If lsb-release contains the DISTRIB* variables we need - use
> # them, otherwise, defer to tests later down the line.
> #
> get_lsb_info_if_available
> if [ "${DISTRIB_ID}" != "" -a "${DISTRIB_RELEASE}" != "" ];
> then
> distro=${DISTRIB_ID}_${DISTRIB_RELEASE}
>
> elif [ -f /etc/issue ]; then
>
> if [ -e /etc/debian_version ]; then
> distro_brand=debian
> distro_version=`cat /etc/debian_version | sed
> 's#testing/##'`
> distro=${distro_brand}_${distro_version}
>
> elif [ -e /etc/gentoo-release ]; then
> distro_brand=gentoo
> # If you think there should be a version,
> # uncomment out the following
> #gentoo_profile=`readlink /etc/make.profile`
> #distro_version=`basename ${gentoo_profile}`
> #distro=${distro_brand}_${distro_version}
> distro=${distro_brand}
>
> elif [ -n "`egrep 'Scientific Linux SL release [0-9\.]
> +' /etc/issue`" ]; then
> distro_ver="`grep 'Scientific Linux' /etc/
> issue | sed -e 's/.*release \([0-9]*\.[0-9]*\).*/\1/'`"
> distro=scientificlinux_$distro_ver
>
> elif [ -n "`egrep 'Red Hat Enterprise Linux ([a-zA-Z]
> +) release [0-9]*' /etc/issue`" ]; then
> distro_brand=rhel
> #sub_distro=` grep 'Red Hat' /etc/issue |
> sed -e 's/Red Hat Enterprise Linux \([A-Z][A-Z]\) release \([0-9]*
> \).*/\1/' `
> distro_version=`grep 'Red Hat' /etc/issue |
> sed -e 's/Red Hat Enterprise Linux \([a-zA-Z]*\) release \([0-9]*
> \).*/\2/' `
> #distro=${distro_brand}${distro_version}_$
> {sub_distro}
> distro=${distro_brand}${distro_version}
>
> elif [ -n "`egrep 'Cray Rocks Linux release 1.3' /etc/
> issue`" ]; then
> distro=rh73
>
> elif [ -n "`egrep 'SGI ProPack 3' /etc/issue`" ]; then
> distro=rhel3
>
> elif [ -n "`egrep 'CentOS release 4.[0-9]' /etc/
> issue`" ]; then
> distro=rhel4
>
> elif [ -n "`egrep 'SuSE SLES 8' /etc/issue`" ]; then
> distro=sles8
>
> elif [ -n "`egrep 'Red Hat Linux Advanced Server
> release 2.1AS ' /etc/issue`" ]; then
> distro=redhat_2.1AS
>
> elif [ -n "`egrep 'Red Hat Linux release 9 ' /etc/
> issue`" ]; then
> distro=redhat_9
>
> elif [ -n "`egrep 'Red Hat Linux release 8.0 ' /etc/
> issue`" ]; then
> distro=redhat_8.0
>
> elif [ -n "`egrep 'Mandrake Linux release 9.1 ' /etc/
> issue`" ]; then
> distro=mandrake_9.1
>
> elif [ -n "`egrep 'SGI ProPack 4' /etc/issue`" ]; then
> distro=sles9
>
> elif [ -n "`egrep 'SUSE LINUX Enterprise Server 9' /
> etc/issue`" ]; then
> distro=sles9
> elif [ -n "`egrep 'SUSE Linux Enterprise Server 10' /
> etc/issue`" ]; then
> distro=sles10
>
> elif [ -n "`egrep 'SuSE SLES 8' /etc/issue`" ]; then
> distro=sles8
>
> elif [ -n "`egrep 'UnitedLinux 1.0' /etc/issue`" ];
> then
> distro=sles8
>
> # Welcome to SuSE Linux 9.0 (x86-64) - Kernel \r (\l)
> elif [ -n "`egrep 'SuSE Linux 9\.0' /etc/issue`" ];
> then
> distro=suse_9.0
>
> elif [ -n "`egrep 'SuSE Linux 9\.1' /etc/issue`" ];
> then
> distro=suse_9.1
>
> elif [ -n "`egrep 'SuSE Linux 9\.2' /etc/issue`" ];
> then
> distro=suse_9.2
>
> elif [ -n "`egrep 'SuSE Linux 9\.3' /etc/issue`" ];
> then
> distro=suse_9.3
>
> # Welcome to SUSE LINUX 10.1 (i586) - Kernel \r (\l).
> elif [ -n "`egrep 'SUSE LINUX 10\.1' /etc/issue`" ];
> then
> distro=suse_10.1
>
> # Welcome to openSUSE 10.2 (i586) - Kernel \r (\l).
> elif [ -n "`egrep 'SUSE 10\.2' /etc/issue`" ]; then
> distro=suse_10.2
>
> elif [ -n "`egrep 'SUSE 10\.3' /etc/issue`" ]; then
> distro=suse_10.3
>
> elif [ -n "`egrep 'Tao Linux release 1 ' /etc/
> issue`" ]; then
> distro=tao_1.0
>
> elif [ -n "`egrep 'Fedora Core ' /etc/issue`" ]; then
> distro_brand=fc
> distro_version=`grep 'Fedora Core ' /etc/
> issue | sed -e 's/Fedora Core release \([0-9]*\).*/\1/' `
> distro=${distro_brand}${distro_version}
>
> elif [ -n "`egrep 'White Box Enterprise Linux release
> 3.0' /etc/issue`" ]; then
> distro=white_box_enterprise_linux_3.0
>
> else
>
> distro=unknown_linux_type_please_send_us_a_patch
> fi
> fi
> #
>
> ############################################################################
>
>
> ############################################################################
> #
> # Step 3) Put it all together as $type
> #
> type=linux-${distro}-${hardware}
> #
>
> ############################################################################
>
> os=$uos
> release=$urelease
> }
>
> get_darwin_info()
> {
>
> ############################################################################
> #
> # step 1) determine $hardware (architecture) string
> # (Should be one of ppc, ppc64. Why these strings?
> Well, we are
> # taking them from the arches directory names in
> the linux kernel
> # source.) -BEF-
> #
> if [ -n "`system_profiler SPHardwareDataType|egrep '(CPU Type|
> Processor Name): PowerPC G4 '`" ]; then
> hardware=ppc
> elif [ -n "`system_profiler SPHardwareDataType|egrep '(CPU
> Type|Processor Name): PowerPC (970|G5) '`" ]; then
> hardware=ppc64
> elif [ -n "`system_profiler SPHardwareDataType|egrep
> 'Processor Name: Intel Core Duo'`" ]; then
> hardware=ia32
> elif [ -n "`system_profiler SPHardwareDataType|egrep
> 'Processor Name: (Dual-Core Intel Xeon|Intel Core 2 Duo)'`" ]; then
> hardware=x86_64
> else
> hardware=unknown_darwin_hardware_please_send_us_a_patch
> fi
> #
>
> ############################################################################
>
>
> ############################################################################
> #
> # step 2) determine $distro (distribution) string
> #
> # Thanks to JP Navarro for the get distro version
> string command
> # below. -BEF-
> #
>
> distro_brand=macosx
> distro_version=`sw_vers -productVersion|sed -e 's/\
> ([0-9]\{1,2\}\.[0-9]\{1,2\}\).*/\1/'`
> distro=${distro_brand}_${distro_version}
> if [ -z "$distro" ]; then
> distro=unknown_darwin_version_please_send_us_a_patch
> fi
> #
>
> ############################################################################
>
>
> ############################################################################
> #
> # Step 3) Put it all together as $type
> #
> type=darwin-${distro}-${hardware}
> #
>
> ############################################################################
>
> os=$uos
> release=$urelease
> }
> #
> ################################################################################
>
> #
> # Check the number of arguments and set the mode.
> #
> mode=type
> format=default
> if [ $# = 1 ]; then
> case "$1" in
> --c*|-c* )
> format=classad
> ;;
> --x*|-x* )
> format=xml
> ;;
> --t*|-t* )
> mode=type
> ;;
> --n*|-n* )
> mode=os
> ;;
> --r*|-r* )
> mode=release
> ;;
> --m*|-m* )
> mode=hardware
> ;;
> --a*|-a* )
> mode=all
> ;;
> --list-all* )
> mode=list_all
> ;;
> --l*|-l* )
> mode=list
> ;;
> --v*|-v* )
> mode=version
> ;;
> --h*|-h* )
> mode=usage
> ;;
> --o*|-o* )
> mode=option_test
> # Cycles through and tries each of the other options, for
> testing purposes.
> ;;
> esac
> fi
>
> if [ "$mode" = "unknown" -o "$mode" = "usage" ]; then
> echo "$program $version"
> echo
> echo "Usage: $program [OPTION]"
> echo
> cat <<EOF
> whatami determines the "platform" of the system on which it is run.
> This
> can be used, for example, to determine which of a series of nfs
> mounted
> software directories is appropriate for use by the system in question.
>
> No unix utility quite fulfills these requirements, so the "whatami"
> program's
> purpose is to return a single unique string for each platform. This
> string
> can then used in directory names, program switches, and in other
> clever ways.
>
> Options:
> --help, -h
> This help message.
>
> --version, -v
> The version of $program.
>
> --type, -t
> Prints the platform type (the default).
>
> --name, -n
> Prints out the name of the operating system.
>
> --release, -r
> Prints out the name and release of the os, separated by a space.
>
> --machine, -m
> Prints out the architecture type for the machine.
>
> --all, -a
> Prints platform type, hardware, os, and version, seperated by a
> space.
>
> --list, -l
> Lists summary of known description strings.
>
> Please send patches to MCS Systems <systems_at_[hidden]>.
>
> EOF
>
>
> if [ "$mode" = "usage" ]; then
> exit 0
> else
> exit 1
> fi
> fi
>
> #
> =
> =
> =
> =
> =
> ======================================================================
> # Okay, now we know what we should do... if the mode is list or the
> version
> # that's easy to get out of the way.
> #
> # Be sure to add to this list whenever a new architecture is figured
> out.
> #
> =
> =
> =
> =
> =
> ======================================================================
>
> if [ "$mode" = "list" ]; then
> cat <<EOF
> type: cpu os version
> ==================================
> linux: (potential linux platform strings are numerous,
> and may not be known in advance)
> aix-3.x: * AIX 3.x
> aix-4.x: * AIX 4.x
> aix-5.x: * AIX 5.x
> aux: * A/UX *
> freebsd: * FreeBSD *
> hpux: * HP-UX *
> irix-5: * IRIX 5.x
> irix-6: * IRIX 6.x
> osf: * OSF1 *
> solaris: sparc SunOS 5.x
> sun4: sparc SunOS 4.x
> ultrix: * Ultrix *
> EOF
> exit 0
> fi
>
> if [ "$mode" = "version" ]; then
> echo "$program $version"
> exit 0
> fi
>
> if [ "$mode" = "option_test" ]; then
> #
> # Test all options for whatami (except this one, of course)
> #
> for opt in -t -n -r -m -a -v --version -h --help -l
> do
> cmd="$0 $opt"
> echo -n "$cmd: "
> $cmd
> if [ ! $? = 0 ]; then
> echo "Failed on option $opt"
> exit 1
> fi
> done
> exit 0
> fi
>
> #
> =
> =
> =
> =
> =
> ======================================================================
> # Find uname, store its location in $UNAME
> #
> =
> =
> =
> =
> =
> ======================================================================
>
> UNAME=unknown
> for dir in `echo $PATH | sed 's/:/ /g'` ; do
> if [ -f $dir/uname ]; then
> UNAME=$dir/uname
> break
> fi
> done
>
> if [ "$UNAME" = "unknown" ]; then
> echo "Unable to locate uname in the path, which means we're out of
> luck."
> exit 1
> fi
>
>
> #
> =
> =
> =
> =
> =
> ======================================================================
> # Now we try to figure out what we're running on. First we try to get
> # close to the machine type, then we look at the mode and figure out
> what
> # we need to print out.
> #
> =
> =
> =
> =
> =
> ======================================================================
>
> uos=`($UNAME -s) 2>/dev/null` || uos=unknown
> urelease=`($UNAME -r) 2>/dev/null` || urelease=unknown
> uhardware=`($UNAME -m) 2>/dev/null` || uhardware=unknown
>
> type=unknown
> os=unknown
> release=unknown
> hardware=unknown
>
> case "${uos}:${urelease}:${uhardware}" in
> AIX:*:*)
> release=`$UNAME -v 2>/dev/null` || release=unknown
> # case $release in
> # 3)
> # type=aix-3
> # ;;
> # 4)
> # type=aix-4
> # ;;
> # 5)
> # type=aix-5
> # ;;
> # esac
> type=aix-$release.$urelease
> os=$uos
> hardware=$uhardware
> ;;
>
> A/UX:*:*)
> type=aux
> os=$uos
> release=$urelease
> hardware=$uhardware
> ;;
>
> CYGWIN_NT-5.1:*:*)
> type=cygwin-5.1
> os=$uos
> release=$urelease
> hardware=$uhardware
> ;;
>
> Darwin:*:*)
> get_darwin_info
> ;;
>
> FreeBSD:*:*)
> type=freebsd
> os=$uos
> release=$urelease
> hardware=$uhardware
> ;;
>
> HP-UX:*:*)
> type=hpux
> os=$uos
> release=$urelease
> hardware=$uhardware
> ;;
>
> IRIX:5*:*)
> type=irix-5
> os=$uos
> release=$urelease
> hardware=`$UNAME -p 2>/dev/null` || hardware=unknown
> ;;
>
> # On alaska, uname->IRIX64, but IRIX everywhere else.
> IRIX*:6*:*)
> type=irix-6
> os=$uos
> release=$urelease
> hardware=`$UNAME -p 2>/dev/null` || hardware=unknown
> ;;
>
> Linux:*:*)
> os=$uos
> release=$urelease
> hardware=$uhardware
> case $uhardware in
> alpha)
> # legacy definition
> type=linux-alpha
> ;;
> *)
> # legacy definitions
> if [ -f /etc/issue ]; then
> if [ -n "`cat /etc/issue | grep "Mandrake release 7.2"`" ]; then
> type=linux-2
> elif [ -n "`cat /etc/issue | grep "Red Hat Linux release 7.1"`" ];
> then
> type=linux-rh71
> elif [ -n "`cat /etc/issue | grep "Red Hat Linux release 7.2"`" ];
> then
> type=linux-rh72
> elif [ -n "`cat /etc/issue | grep "Red Hat Linux release 7.3"`" ];
> then
> type=linux-rh73
> else
> get_linux_type
> fi
> else
> type=linux
> fi
> ;;
> esac
> ;;
>
> SunOS:4*:*)
> type=sun4
> os=$uos
> release=$urelease
> hardware=`/bin/arch -k` || hardware=unknown
> ;;
>
> SunOS:5*:*)
> solaris_version=`uname -r | sed 's/^5\.//'`
> type=solaris-${solaris_version}
> os=$uos
> release=$urelease
> hardware=`/bin/arch -k` || hardware=unknown
> ;;
>
> OSF1:*:*)
> type=osf
> os=$uos
> release=$urelease
> hardware=$uhardware
> ;;
>
> ULTRIX:*:*)
> type=ultrix
> os=$uos
> release=$urelease
> hardware=$uhardware
> ;;
>
>
> esac
>
> exit_code=0
>
> grid=""
> #
> =
> =
> =
> =
> =
> ======================================================================
> # Got all the info, now just print the right stuff based on mode.
> #
> =
> =
> =
> =
> =
> ======================================================================
> case $format in
> classad)
> echo ${grid}whatami_type = \"$type\"
> echo ${grid}whatami_os = \"$os\"
> echo ${grid}whatami_release = \"$release\"
> echo ${grid}whatami_hardware = \"$hardware\"
> if [ $os = "Linux" ]; then
> echo ${grid}whatami_distro = \"$distro\"
> fi
> exit
> ;;
> xml)
> echo "<${grid}whatami>"
> echo " <type>$type</type>"
> echo " <os>$os</os>"
> echo " <release>$release</release>"
> echo " <hardware>$hardware</hardware>"
> if [ $os = "Linux" ]; then
> echo " <distro>$distro</distro>"
> fi
> echo "</${grid}whatami>"
> exit
> ;;
> esac
>
> case $mode in
> type)
> if [ $type = "unknown" ]; then
> exit_code=1
> fi
> echo $type
> ;;
>
> os)
> if [ $os = "unknown" ]; then
> exit_code=1
> fi
> echo $os
> ;;
>
> release)
> if [ $os = "unknown" -o $release = "unknown" ]; then
> exit_code=1
> fi
> echo "$os $release"
> ;;
>
> hardware)
> if [ $hardware = "unknown" ]; then
> exit_code=1
> fi
> echo $hardware
> ;;
>
> all)
> if [ $hardware = "unknown" \
> -o $os = "unknown" \
> -o $release = "unknown" ]; then
> exit_code=1
> fi
> echo "$type $hardware $os $release"
> ;;
> esac
>
> exit $exit_code
>

-- 
Jeff Squyres
Cisco Systems