
# Install script that matches the function of 4.2 BSD install

cmd="mv"
strip="strip"
chmod="chmod 755"
chown="chown root"
chgrp="chgrp bin"
while true ; do
	case $1 in
		-s )	strip="strip"
			shift
			;;
		-ns )	strip=""
			shift
			;;
		-c )	cmd="cp"
			shift
			;;
		-m )	chmod="chmod $2"
			shift
			shift
			;;
		-o )	chown="chown $2"
			shift
			shift
			;;
		-g )	chgrp="chgrp $2"
			shift
			shift
			;;
		* )	break
			;;
	esac
done

if [ ! ${2-""} ]
then	echo "install: no destination specified"
	exit 1
fi
if [ ${3-""} ]
then	echo "install: too many files specified -> $*"
	exit 1
fi
if [ $1 = $2 -o $2 = . ]
then	echo "install: can't move $1 onto itself"
	exit 1
fi
if [ -d $2 ]
then	file=$2/$1
else	file=$2
fi
rm -f $file
$cmd $1 $file
if [ $strip ]
then	$strip $file
fi
$chown $file
$chgrp $file
$chmod $file
