#!/bin/sh
#
#	$Id: GuessOS,v 1.26 2000/05/30 01:23:06 forys Exp $
#
#	GuessOS - guess the OS type for skill.
#	Contributed by: Ric Anderson <ric@rtd.com>
#
#	the OS name is echoed to standard output, based on /etc/motd,
#	or, failing that, the location of some files.
#

case "`exec 2>/dev/null; head -2 /etc/motd`" in
    *"IBM AIX Version 3"*)
	OS=aix3
	;;
    *"IBM AIX Version 4"*)
	OS=aix3
	;;
    *"DYNIX(R) V3."*)
	OS=dynix3
	;;
    *"Sun UNIX 4.2 Release 3."*)
	OS=sos3
	;;
    *"SunOS Release 4.1"*)
	OS=sos4_1
	;;
    *"SunOS Release 4."*)
	OS=sos4
	;;
    *"ULTRIX V4."*)
	OS=ultrix4
	;;
    *"Ultrix"*"V2"*)
	OS=ultrix2
	;;
    *"NeXT Mach 1"*)
	OS=next1
	;;
    *"NeXT Mach 2"*)
	OS=next2
	;;
    *"Mach 3"*)
	OS=mach3
	;;
    *"Digital UNIX"*)
	OS=mach3
	;;
    *"Tru64 UNIX"*)
	OS=mach3
	;;
    *"OSF/1"*)
	OS=mach3
	;;
    *"4.3 BSD UNIX"*)
	if [ -f /etc/ttylocal ]; then
	    OS=xinu43
	else
	    OS=bsd43
	fi
	;;
    *"4.3 BSD Reno UNIX"*)
	OS=bsd44
	;;
    *"4.4BSD"*)
	OS=bsd44
	;;
    *"NetBSD"*)
	OS=bsd44
	;;
    *"FreeBSD"*)
	OS=bsd44
	;;
    *"BSDI"*)
	OS=bsd44
	;;
    *"UMIPS"*)
	OS=umips
	;;
    *"Umax 4.2"*)
	OS=umax-42
	;;
#
# RATS!!!  Try to sniff out a file or two.
#
    *)
	if [ -f /usr/lib/libNeXT_s.a ]; then
	    OS=next2
	elif [ -f /mach ]; then
	    OS=mach2
	elif [ -f /bin/universe ]; then
	    OS=osx
	elif [ -f /bin/4d ]; then
	    case "`exec 2>/dev/null; uname -r`" in
		"3."*)
		    OS=irix3
		    ;;
		"4."*)
		    OS=irix4
		    ;;
		"5."*)
		    OS=irix5
		    ;;
		"6."*)
		    OS=irix6
		    ;;
		*)
		    OS=irix
		    ;;
	    esac
	elif [ -f /bin/hp9000s800 ]; then
	    case "`exec 2>/dev/null; /bin/uname -r`" in
		*6.*|*7.*)
		    OS=hpux7
		    ;;
		*8.*|*9.*)
		    OS=hpux9
		    ;;
		*)
		    OS=hpux10
		    ;;
	    esac
	elif [ -f /sbin/uname -o -f /bin/uname ]; then
	    case "`exec 2>/dev/null; uname -r`" in
		3.*)
		    OS=svr3
		    ;;
		4.*)
		    case "`exec 2>/dev/null; uname -rs`" in
			"SunOS 4.1"*)
			    OS=sos4_1
			    ;;
			"SunOS 4"*)
			    OS=sos4
			    ;;
			"SunOS 3"*)
			    OS=sos3
			    ;;
			*)
			    OS=svr4
			    ;;
		    esac
		    ;;
		*)
		    case "`exec 2>/dev/null; uname`" in
			Linux)
			    OS=linux
			    ;;
			AIX)
			    OS=aix3
			    ;;
			*)
		    	    OS=svrx
			    ;;
		    esac
		    ;;
	    esac
	elif [ -d /etc/aix -o -d /etc/aixdwm ]; then
	    OS=aix3
	elif [ -f /usr/bin/cat ]; then
	    OS=sos4
	elif [ -f /etc/nd ]; then
	    OS=sos3
	elif [ -f /etc/ttylocal ]; then
	    OS=xinu43
	elif [ -f /Umax.image ]; then
	    OS=umax42
	elif [ -d /usr/ibm ]; then
	    OS=aos43
	else
	    OS=unknown
	fi
	;;
esac
echo "${OS}"
exit 0
