#!/bin/sh
#
# Copyright (c) 1992-1993 Michael A. Cooper.
# This software may be freely distributed provided it is not sold for 
# profit and the author is credited appropriately.
#
# $Header: /src/common/usc/bin/sysinfo/3.0/RCS/ostype,v 1.7 1994/11/16 00:58:00 mcooper Exp $
#
# Determine type of OS
#

#
# Find uname program.
#
if [ -f /usr/bin/uname ]; then
	unameprog=/usr/bin/uname
elif [ -f /bin/uname ]; then
	unameprog=/bin/uname
fi

#
# Determine our OS name if we can.
#
if [ "${unameprog}" ]; then
	osname="`${unameprog} -s`"
fi

#
# Check for Convex SPP special handling
#
if [ "${osname}" = "HP-UX" ]; then
	if [ -x /bin/sysinfo ]; then
		altname="`/bin/sysinfo -sv | awk '{print $1}' | sed -e 's;_.*;;' 2>/dev/null`"
		if [ ! -z "${altname}" ]; then
			osname="${altname}"
		fi
	fi
fi

#
# Try stupid file checks
#
if [ -z "${osname}" ]; then
	if [ -d /NextApps ]; then
		if [ -f /usr/bin/hostinfo ]; then
			mver="`/usr/bin/hostinfo | grep -i 'next mach' | awk '{print $3}' | sed -e 's/\..*//'`"
			osname="nextstep${mver}"
		else
			osname="nextstep2"
		fi
	elif [ -d /usr/alliant ]; then
		osname="concentrix"
	else
		echo "Unable to determine your OS type.";
		exit 1;
	fi
fi

osname="`echo ${osname} | tr '[A-Z]' '[a-z]'`"

#
# Get OS Version
#
case "${osname}" in
sunos|ultrix|hp-ux)
	if [ -z "${unameprog}" ]; then
		echo "No uname program found."
		exit 1
	fi
	osver="`${unameprog} -r`"
	;;
aix)
	osver="`${unameprog} -v`"
	;;
spp-ux)
	osver="`/bin/sysinfo -sv | awk '{print $2}'`"
	;;
concentrix)
	# We don't care what the os version is
	osver=""
	;;
esac

echo "${osname}${osver}"
