1#! /bin/sh
2#
3#	@(#)install.sh	4.5	(Berkeley)	10/12/83
4#
5cmd=/bin/mv
6strip=""
7chmod="/bin/chmod 755"
8chown=""
9chgrp=""
10while true ; do
11	case $1 in
12		-s )	strip="/bin/strip"
13			shift
14			;;
15		-c )	cmd="/bin/cp -p"
16			shift
17			;;
18		-m )	chmod="/bin/chmod $2"
19			shift
20			shift
21			;;
22		-o )	chown="/etc/chown -f $2"
23			shift
24			shift
25			;;
26		-g )	chgrp="/bin/chgrp -f $2"
27			shift
28			shift
29			;;
30		-d )	cmd="/bin/mkdir"
31			shift
32			;;
33		* )	break
34			;;
35	esac
36done
37
38if test ! ${2-""}; then
39	echo "install: no destination specified"
40	exit 1
41fi
42if test ${3-""}; then
43	echo "install: too many files specified -> $*"
44	exit 1
45fi
46if test $1 = $2 -o $2 = .; then
47	echo "install: can't move $1 onto itself"
48	exit 1
49fi
50case $cmd in
51/bin/mkdir )
52	file=$2/$1
53	;;
54* )
55	if test '!' -f $1; then
56		echo "install: can't open $1"
57		exit 1
58	fi
59	if test -d $2; then
60		file=$2/$1
61	else
62		file=$2
63	fi
64	/bin/rm -f $file
65	;;
66esac
67
68case $cmd in
69/bin/mkdir )
70	if test ! -d "$file"; then
71		$cmd $file
72	fi
73	;;
74* )
75	$cmd $1 $file
76	if test -n "$strip"; then
77		$strip $file
78	fi
79	;;
80esac
81
82if test -n "$chown"; then
83	$chown $file
84fi
85if test -n "$chgrp"; then
86	$chgrp $file
87fi
88$chmod $file
89
90exit 0
91