#!/bin/sh
# $Id: machtype_netbsd,v 1.6 1995/10/22 01:45:59 yoav Exp $
# $Source: /afs/sipb/project/sipb-athena/machtype/RCS/machtype_netbsd,v $

# need to support the following options:
# NOTE, c, v, d, and M are needed by olc, do not change them a TINY bit!!!
#  -c     : Processor type
#  -d     : display type 
#  -k     : select the kernel
#  -m     : override memory from /dev/kmem
#  -r     : disk drive type
#  -v     : more verbose -- about memory mainly
#  -A     : print Athena Release
#  -E     : print out the version of the Base OS
#  -L     : version of athena from /etc/athena/version
#  -M     : free memory
#  -N     : print out the name of the base OS
#  -P     : print out Athena System packs (from /srvd/.rvdinfo)
#  -S     : Print out the Athena System name  (AFS sysname)

PATH=/bin:/usr/bin
set -- `getopt cdk:m:rvAELMNPS $*`
if test $? != 0
then
	echo 'Usage: machtype [-cdrvAELMNPS] [-k kernel] [-m memsource]'
	exit 2
fi
for i
do
	case "$i"
	in
		-c)
			cpu=1;shift;;
		-d)
			display=1; shift;;
		-k)
				kernel=1; karg=$2; shift 2;;
		-m)
			mem=1; memarg=$2; shift 2;;
		-r)
			rdsk=1; shift;;
		-v)
			verbose=1; shift;;
		-A)
			at_rel=1; shift;;
		-E) 	
			base_os_ver=1; shift;;
		-L)
			ath_vers=1; shift;;
		-M)
			memory=1; shift;;
		-N)
			base_os_name=1; shift;;		
		-P)	
			syspacks=1; shift;;
		-S)
			ath_sys_name=1; shift;;
		--)
			shift; break;;
	esac
done
printed=0

if [ $cpu ] ; then
	if [ $verbose ]; then
		echo "`/usr/sbin/sysctl -n kern.ostype` `/usr/sbin/sysctl -n kern.osrelease` on `/usr/sbin/sysctl -n hw.model`"
	else
		/usr/sbin/sysctl -n hw.model | tr \\040 _
	fi
	printed=1
fi

if [ $display ] ; then
	echo "XFree3.1_`ls -l /etc/X | awk -F_ '/->/{print $NF}'`"
	printed=1
fi

if [ $memory ] ; then
	if [ $verbose ]; then
		/usr/sbin/sysctl -n hw.usermem | awk '{printf "user=%d, ", $1/1000}'
		/usr/sbin/sysctl -n hw.physmem | awk '{printf "phys=%d (%d M)\n", $1/1000, $1/1024000}'
	else
		/usr/sbin/sysctl -n hw.physmem | awk '{printf "%d\n", $1/1000}'
	fi
	printed=1
fi

if [ $at_rel ]; then
	cat /etc/athena/version
	printed=1
fi

if [ $ath_vers ]; then
	cat /etc/athena/version
	printed=1
fi

if [ $base_os_ver ]; then
	/usr/sbin/sysctl -n kern.osrelease
	printed=1
fi

if [ $base_os_name ]; then
	/usr/sbin/sysctl -n kern.osname
	printed=1
fi

if [ $ath_sys_name ]; then
	/bin/athena/fs sysname | awk -F\' '{ print $2 }'
	printed=1
fi

if [ $printed -eq '0' ] ; then
	echo inbsd
fi
exit 0
