#!/bin/sh
#
# platx
#   Attemps, in vain, to determine the platform -- great if we could get
# hardware and software (OS) base.  First shot at this -- wanted to do this
# for a while, then re-stolen from Todd Merriman's "platform".
#
# *might* work on Xenix/386, CTIX, 386/ix, DG/UX, SunOS, DYNIX, eta10's,
# ibm risc boxes, pyramids, decstations, etc.  Uses the arch, file, and
# uname commands to try to figure things out.  Vaxen and such will
# definitely not work.
#

if test -s "/bin/arch" ; then
    # this gives strange results on some machines...
    # /bin/arch -k
    /bin/arch
    exit 0
    fi

if test -s "/bin/uname" ; then
    type=`uname -m`
        # Convergent S640
    if test "$type" = "miti2" ; then
	echo "CTIX"; exit 0
	fi
        # Sequent Interactive 386/ix and DYNIX
    if test "$type" = "i386" ; then
        if test "`uname -v`" = "DYNIX" ; then 
		echo "DYNIX"
		exit 0
        else 
		echo "386_ix"
		exit 0
		fi
	fi
        # DG/UX 88000
    if test "$type" = "AViiON" ; then 
	echo "DG_UX"; exit 0;
	fi
        # IBM's RISC/AIX
    if test "$type" = "AIX" ; then 
     	echo "aix"; exit 0;
	fi
        # SCO Xenix
    if test "$type" = "3" ; then 
   	echo "Xenix_386"; exit 0;
	fi
#     else    { print "$type???\n"; exit 0;}
    fi

# locations of "file" executable?
dirs="/bin /usr/bin"
typical_executable="/bin/ls"
for dir in $dirs ; do
     if test -r "$dir/file" ; then
         output=`$dir/file $typical_executable`
 	 type=`echo $output | awk '{print $2}'`
         if test "$type" = "mipsel" ; then
 		echo "DECstation"; exit 0
 		fi
         if test "$type" = "90x" ; then 
 		echo "dec"; exit 0
 		fi
         if test "$type" = "SYMMETRY" ; then 
 		echo "Sequent_Symmetry" ; exit 0
 		fi
 	fi
     done

# also stolen from the net...
#
# rt_bsd:	4.3 BSD on RT
# aix_22:	AIX 2.* on RT
# aix_11: AIX 1.1 or AIX 1.2 on PS/2
# aix_31: AIX 3.1 on RISC 6000

if test -f "/unix" ; then
 	if test -d "/vrm" ; then
 		# echo "aix_22"
 		echo "aix"
		exit 1;
 	else
 		if test -d "/etc/security" ; then
 			# echo "aix_31" ; exit 1;
 			echo "aix" ; exit 1;
 		else
 			# echo "aix_11" ; exit 1;
 			echo "aix" ; exit 1;
 			fi
 		fi
	fi

# apollo stuff; thanks to the apollo mailing list!
if test -d /sys/node_data ; then
	echo "apollo" ; exit 1
	fi

exit 1;
