# this script installs the 'whence' command in /usr/local/bin and checks 
# for the existence of a Bourne shell or Bash

string="`whoami`"

if [ "$string" != "root" ]
then
	echo error: $0 must be run by user root
	exit
fi

found=""

for i in /bin/sh /bin/bash /usr/local/bin/bash
do
	if [ -x "$i" -a -z "$found" ]
	then
		echo "#!${i}" > whence.local
		found="true"
	fi
done

cat whence >> whence.local

if [ ! -d /usr/local/bin ]
then
	mkdir /usr/local/bin
	chmod 755 /usr/local/bin
fi

cp whence.local /usr/local/bin/whence
chmod 555 /usr/local/bin/whence

rm whence.local
