#!/bin/sh
#
#	$Header: GuessOS,v 1.11 1993/04/18 21:00:29 forys Exp $
#
#	GuessOS - guess the OS type for skill.
#	Contributed by: Ric Anderson <ric@cs.arizona.edu>
#
#	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
    *"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
	;;
    *"4.3 BSD UNIX"*)
	if [ -f /etc/ttylocal ]; then
	    OS=xinu43
	else
	    OS=bsd43
	fi
	;;
    *"4.3 BSD Reno UNIX"*)
	OS=bsd44
	;;
    *"4.4BSD"*"UNIX"*)
	OS=bsd44
	;;
    *"UMIPS"*)
	OS=umips
	;;
    *"Umax 4.2"*)
	OS=umax-42
	;;
    *"BSDI"*)
	OS=bsd44
	;;
#
# 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 /sbin/uname ]; then
	    case "`exec 2>/dev/null; /bin/uname -r`" in
		3.*)
		    OS=svr3
		    ;;
		4.*)
		    OS=svr4
		    ;;
		*)
		    OS=svrx
		    ;;
	    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
	elif [ -f /bin/hp9000s800 ]; then
	    case "`exec 2>/dev/null; /bin/uname -r`" in
		A.B7.*|7.*)
		    OS=hpux7
		    ;;
		A.B8.*|8.*|A.08.*|A.B9.*|9.*|A.09.*)
		    OS=hpux9
		    ;;
		*)
		    OS=hpux
		    ;;
	    esac
	else
	    if [ -f /bin/4d ]; then
		if [ /bin/4d ]; then
		    case "`exec 2>/dev/null; uname -r`" in
			"3."*)
			    OS=irix3
			    ;;
			"4."*)
			    OS=irix4
			    ;;
			*)
			    OS=unknown
			    ;;
		    esac
		else
		    OS=unknown
		fi
	    else
		OS=unknown
	    fi
	fi
	;;
esac
echo "${OS}"
exit 0
