xref: /titanic_51/usr/src/cmd/install.d/install.sh (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate#!/sbin/sh
2*7c478bd9Sstevel@tonic-gate#
3*7c478bd9Sstevel@tonic-gate# CDDL HEADER START
4*7c478bd9Sstevel@tonic-gate#
5*7c478bd9Sstevel@tonic-gate# The contents of this file are subject to the terms of the
6*7c478bd9Sstevel@tonic-gate# Common Development and Distribution License, Version 1.0 only
7*7c478bd9Sstevel@tonic-gate# (the "License").  You may not use this file except in compliance
8*7c478bd9Sstevel@tonic-gate# with the License.
9*7c478bd9Sstevel@tonic-gate#
10*7c478bd9Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11*7c478bd9Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing.
12*7c478bd9Sstevel@tonic-gate# See the License for the specific language governing permissions
13*7c478bd9Sstevel@tonic-gate# and limitations under the License.
14*7c478bd9Sstevel@tonic-gate#
15*7c478bd9Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each
16*7c478bd9Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17*7c478bd9Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the
18*7c478bd9Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying
19*7c478bd9Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner]
20*7c478bd9Sstevel@tonic-gate#
21*7c478bd9Sstevel@tonic-gate# CDDL HEADER END
22*7c478bd9Sstevel@tonic-gate#
23*7c478bd9Sstevel@tonic-gate#	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T
24*7c478bd9Sstevel@tonic-gate#	  All Rights Reserved
25*7c478bd9Sstevel@tonic-gate
26*7c478bd9Sstevel@tonic-gate
27*7c478bd9Sstevel@tonic-gate#ident	"%Z%%M%	%I%	%E% SMI"	/* SVr4.0 1.12.1.1	*/
28*7c478bd9Sstevel@tonic-gate
29*7c478bd9Sstevel@tonic-gate#	INSTALL COMMAND
30*7c478bd9Sstevel@tonic-gate
31*7c478bd9Sstevel@tonic-gateFLIST=$ROOT/etc/syslist
32*7c478bd9Sstevel@tonic-gateDEFAULT="$ROOT/bin $ROOT/usr/bin $ROOT/etc $ROOT/lib $ROOT/usr/lib" FOUND="" MOVOLD=""
33*7c478bd9Sstevel@tonic-gateECHO=echo PATH=/usr/bin FLAG=off
34*7c478bd9Sstevel@tonic-gateUSAGE="eval echo 'usage: install [options] file [dir1 ...]'; exit 2"
35*7c478bd9Sstevel@tonic-gate
36*7c478bd9Sstevel@tonic-gateif [ $# -lt 2 ] ; then
37*7c478bd9Sstevel@tonic-gate	$USAGE
38*7c478bd9Sstevel@tonic-gatefi
39*7c478bd9Sstevel@tonic-gate
40*7c478bd9Sstevel@tonic-gateMFLAG=off
41*7c478bd9Sstevel@tonic-gateUFLAG=off
42*7c478bd9Sstevel@tonic-gateGFLAG=off
43*7c478bd9Sstevel@tonic-gate
44*7c478bd9Sstevel@tonic-gateMODE=755
45*7c478bd9Sstevel@tonic-gateGRP=`expr "\`id\`" : ".*gid=[0-9]*(\(..*\)) .*"`
46*7c478bd9Sstevel@tonic-gateGROUP=`echo $GRP | sed -e 's/) fsid.*//p'`
47*7c478bd9Sstevel@tonic-gateOWN=`expr "\`id\`" : ".*uid=[0-9]*(\(..*\)) .*"`
48*7c478bd9Sstevel@tonic-gateOWNER=`echo $OWN | sed -e 's/) .*//p'`
49*7c478bd9Sstevel@tonic-gateif [ -z "$GROUP" ]
50*7c478bd9Sstevel@tonic-gatethen
51*7c478bd9Sstevel@tonic-gate	GROUP=`expr "\`id\`" : ".*gid=\([0-9]*\).*"`
52*7c478bd9Sstevel@tonic-gatefi
53*7c478bd9Sstevel@tonic-gateif [ -z "$OWNER" ]
54*7c478bd9Sstevel@tonic-gatethen
55*7c478bd9Sstevel@tonic-gate	OWNER=`expr "\`id\`" : ".*uid=\([0-9]*\).*"`
56*7c478bd9Sstevel@tonic-gatefi
57*7c478bd9Sstevel@tonic-gateif [ "$OWNER" = root ]
58*7c478bd9Sstevel@tonic-gatethen
59*7c478bd9Sstevel@tonic-gate	ROOTFLAG=on
60*7c478bd9Sstevel@tonic-gate	OWNER=bin
61*7c478bd9Sstevel@tonic-gate	GROUP=bin
62*7c478bd9Sstevel@tonic-gateelse
63*7c478bd9Sstevel@tonic-gate	ROOTFLAG=off
64*7c478bd9Sstevel@tonic-gatefi
65*7c478bd9Sstevel@tonic-gate
66*7c478bd9Sstevel@tonic-gate
67*7c478bd9Sstevel@tonic-gatefor i in $*
68*7c478bd9Sstevel@tonic-gatedo
69*7c478bd9Sstevel@tonic-gate	if [ $FLAG = on ]
70*7c478bd9Sstevel@tonic-gate	then
71*7c478bd9Sstevel@tonic-gate		case $i in
72*7c478bd9Sstevel@tonic-gate		    -*) echo "install: The -c, -f, -n options each require a directory following!"
73*7c478bd9Sstevel@tonic-gate			exit 2;;
74*7c478bd9Sstevel@tonic-gate		     *) FLAG=off
75*7c478bd9Sstevel@tonic-gate			continue;;
76*7c478bd9Sstevel@tonic-gate		esac
77*7c478bd9Sstevel@tonic-gate	fi
78*7c478bd9Sstevel@tonic-gate	case $i in
79*7c478bd9Sstevel@tonic-gate	    -c) if [ x$ARG = x-d -o x$ARG = x-f ]
80*7c478bd9Sstevel@tonic-gate		then
81*7c478bd9Sstevel@tonic-gate			echo "install: -c dir: illegal option with $ARG option!"
82*7c478bd9Sstevel@tonic-gate			exit 2
83*7c478bd9Sstevel@tonic-gate	        elif [ x$arg = x-i -o x$arg = x-o -o x$arg = x-n ]
84*7c478bd9Sstevel@tonic-gate		then
85*7c478bd9Sstevel@tonic-gate			echo "install: -c dir: illegal option with $arg option!"
86*7c478bd9Sstevel@tonic-gate			exit 2
87*7c478bd9Sstevel@tonic-gate		elif test $# -lt 3
88*7c478bd9Sstevel@tonic-gate		then
89*7c478bd9Sstevel@tonic-gate			echo "install: -c option must have at least 3 args!"
90*7c478bd9Sstevel@tonic-gate			exit 2
91*7c478bd9Sstevel@tonic-gate		else
92*7c478bd9Sstevel@tonic-gate			direct=$2
93*7c478bd9Sstevel@tonic-gate			FLAG=on
94*7c478bd9Sstevel@tonic-gate			ARG=-c
95*7c478bd9Sstevel@tonic-gate			shift; shift
96*7c478bd9Sstevel@tonic-gate		fi;;
97*7c478bd9Sstevel@tonic-gate	    -f) if [ x$ARG = x-d -o x$ARG = x-c ]
98*7c478bd9Sstevel@tonic-gate		then
99*7c478bd9Sstevel@tonic-gate			echo "install: -f dir: illegal option with $ARG option!"
100*7c478bd9Sstevel@tonic-gate			exit 2
101*7c478bd9Sstevel@tonic-gate		elif [ x$arg = x-i -o x$arg = x-n ]
102*7c478bd9Sstevel@tonic-gate		then
103*7c478bd9Sstevel@tonic-gate			echo "install: -f dir: illegal option with $arg option!"
104*7c478bd9Sstevel@tonic-gate			exit 2
105*7c478bd9Sstevel@tonic-gate		elif test $# -lt 3
106*7c478bd9Sstevel@tonic-gate		then
107*7c478bd9Sstevel@tonic-gate			echo "install: -f option must have at least 3 args!"
108*7c478bd9Sstevel@tonic-gate			exit 2
109*7c478bd9Sstevel@tonic-gate		else
110*7c478bd9Sstevel@tonic-gate			direct=$2
111*7c478bd9Sstevel@tonic-gate			FLAG=on
112*7c478bd9Sstevel@tonic-gate			ARG=-f
113*7c478bd9Sstevel@tonic-gate			shift; shift
114*7c478bd9Sstevel@tonic-gate		fi;;
115*7c478bd9Sstevel@tonic-gate	  -i) if [ x$ARG = x-d -o x$ARG  = x-c -o x$ARG = x-f ]
116*7c478bd9Sstevel@tonic-gate		then
117*7c478bd9Sstevel@tonic-gate			echo "install: -i: illegal option with $ARG option!"
118*7c478bd9Sstevel@tonic-gate			exit 2
119*7c478bd9Sstevel@tonic-gate		elif test $# -lt 3
120*7c478bd9Sstevel@tonic-gate		then
121*7c478bd9Sstevel@tonic-gate			echo "install: -i option requires at least 3 args!"
122*7c478bd9Sstevel@tonic-gate			exit 2
123*7c478bd9Sstevel@tonic-gate		else
124*7c478bd9Sstevel@tonic-gate			DEFAULT=""
125*7c478bd9Sstevel@tonic-gate			arg=-i
126*7c478bd9Sstevel@tonic-gate			shift
127*7c478bd9Sstevel@tonic-gate		fi;;
128*7c478bd9Sstevel@tonic-gate	    -o) if  [ x$ARG = x-d -o x$ARG = x-c ]
129*7c478bd9Sstevel@tonic-gate		then
130*7c478bd9Sstevel@tonic-gate			echo "install: -o: illegal option with $ARG option!"
131*7c478bd9Sstevel@tonic-gate			exit 2
132*7c478bd9Sstevel@tonic-gate		elif test $# -lt 2
133*7c478bd9Sstevel@tonic-gate		then
134*7c478bd9Sstevel@tonic-gate			$USAGE
135*7c478bd9Sstevel@tonic-gate		else
136*7c478bd9Sstevel@tonic-gate			MOVOLD=yes
137*7c478bd9Sstevel@tonic-gate			arg=-o
138*7c478bd9Sstevel@tonic-gate			shift
139*7c478bd9Sstevel@tonic-gate		fi;;
140*7c478bd9Sstevel@tonic-gate	    -n) if [ x$ARG = x-d -o x$ARG = x-c -o x$ARG = x-f ]
141*7c478bd9Sstevel@tonic-gate		then
142*7c478bd9Sstevel@tonic-gate			echo "install: -n dir: illegal option with $ARG option!"
143*7c478bd9Sstevel@tonic-gate			exit 2
144*7c478bd9Sstevel@tonic-gate		elif test $# -lt 3
145*7c478bd9Sstevel@tonic-gate		then
146*7c478bd9Sstevel@tonic-gate			echo "install: -n option requires at least 3 args!"
147*7c478bd9Sstevel@tonic-gate			exit 2
148*7c478bd9Sstevel@tonic-gate		else
149*7c478bd9Sstevel@tonic-gate			LASTRES=$2
150*7c478bd9Sstevel@tonic-gate			FLAG=on
151*7c478bd9Sstevel@tonic-gate			FOUND=n
152*7c478bd9Sstevel@tonic-gate			arg=-n
153*7c478bd9Sstevel@tonic-gate			shift; shift
154*7c478bd9Sstevel@tonic-gate		fi;;
155*7c478bd9Sstevel@tonic-gate	    -d) if [ x$ARG = x-c -o x$ARG = x-f ]
156*7c478bd9Sstevel@tonic-gate		then
157*7c478bd9Sstevel@tonic-gate			echo "install: -d: illegal option with $ARG option!"
158*7c478bd9Sstevel@tonic-gate			exit 2
159*7c478bd9Sstevel@tonic-gate		elif [ x$arg = x-i -o x$arg = x-o -o x$arg = x-n ]
160*7c478bd9Sstevel@tonic-gate		then
161*7c478bd9Sstevel@tonic-gate			echo "install: -d: illegal option with $arg option!"
162*7c478bd9Sstevel@tonic-gate			exit 2
163*7c478bd9Sstevel@tonic-gate		else
164*7c478bd9Sstevel@tonic-gate			ARG=-d
165*7c478bd9Sstevel@tonic-gate			shift
166*7c478bd9Sstevel@tonic-gate		fi;;
167*7c478bd9Sstevel@tonic-gate	    -s) if test $# -lt 2
168*7c478bd9Sstevel@tonic-gate		then
169*7c478bd9Sstevel@tonic-gate			$USAGE
170*7c478bd9Sstevel@tonic-gate		else
171*7c478bd9Sstevel@tonic-gate			ECHO=:
172*7c478bd9Sstevel@tonic-gate			shift
173*7c478bd9Sstevel@tonic-gate		fi;;
174*7c478bd9Sstevel@tonic-gate	    -u) if [ $ROOTFLAG = off ]
175*7c478bd9Sstevel@tonic-gate		then
176*7c478bd9Sstevel@tonic-gate			echo "install: -u option available only to root -- ignored"
177*7c478bd9Sstevel@tonic-gate		else
178*7c478bd9Sstevel@tonic-gate			OWNER=$2
179*7c478bd9Sstevel@tonic-gate			UFLAG=on
180*7c478bd9Sstevel@tonic-gate			$ECHO new owner is $OWNER
181*7c478bd9Sstevel@tonic-gate		fi
182*7c478bd9Sstevel@tonic-gate		FLAG=on
183*7c478bd9Sstevel@tonic-gate		shift; shift;;
184*7c478bd9Sstevel@tonic-gate	    -g) if [ $ROOTFLAG = off ]
185*7c478bd9Sstevel@tonic-gate		then
186*7c478bd9Sstevel@tonic-gate			echo "install: -g option available only to root -- ignored"
187*7c478bd9Sstevel@tonic-gate		else
188*7c478bd9Sstevel@tonic-gate			GROUP=$2
189*7c478bd9Sstevel@tonic-gate			GFLAG=on
190*7c478bd9Sstevel@tonic-gate		fi
191*7c478bd9Sstevel@tonic-gate		FLAG=on
192*7c478bd9Sstevel@tonic-gate		shift; shift;;
193*7c478bd9Sstevel@tonic-gate	    -m) MODE=$2
194*7c478bd9Sstevel@tonic-gate		MFLAG=on
195*7c478bd9Sstevel@tonic-gate		FLAG=on
196*7c478bd9Sstevel@tonic-gate		shift; shift;;
197*7c478bd9Sstevel@tonic-gate	     *) break;;
198*7c478bd9Sstevel@tonic-gate	esac
199*7c478bd9Sstevel@tonic-gatedone
200*7c478bd9Sstevel@tonic-gate
201*7c478bd9Sstevel@tonic-gate
202*7c478bd9Sstevel@tonic-gateif [ x$ARG = x-d ]
203*7c478bd9Sstevel@tonic-gatethen
204*7c478bd9Sstevel@tonic-gate	if [ ! -d $i ]
205*7c478bd9Sstevel@tonic-gate	then
206*7c478bd9Sstevel@tonic-gate		mkdir -p $i
207*7c478bd9Sstevel@tonic-gate		if [ $? = 0 ]
208*7c478bd9Sstevel@tonic-gate		then
209*7c478bd9Sstevel@tonic-gate			$ECHO "directory $i created"
210*7c478bd9Sstevel@tonic-gate			chgrp $GROUP $i
211*7c478bd9Sstevel@tonic-gate			chown $OWNER $i
212*7c478bd9Sstevel@tonic-gate			chmod $MODE $i
213*7c478bd9Sstevel@tonic-gate		else
214*7c478bd9Sstevel@tonic-gate			echo "install: mkdir $i failed "
215*7c478bd9Sstevel@tonic-gate		fi
216*7c478bd9Sstevel@tonic-gate	else
217*7c478bd9Sstevel@tonic-gate		chgrp $GROUP $i
218*7c478bd9Sstevel@tonic-gate		chown $OWNER $i
219*7c478bd9Sstevel@tonic-gate		chmod $MODE $i
220*7c478bd9Sstevel@tonic-gate	fi
221*7c478bd9Sstevel@tonic-gate	exit
222*7c478bd9Sstevel@tonic-gatefi
223*7c478bd9Sstevel@tonic-gate
224*7c478bd9Sstevel@tonic-gateFILEP=$i FILE=`echo $i | sed -e "s/.*\///"`
225*7c478bd9Sstevel@tonic-gateif [ x$ARG = x-c -o x$ARG = x-f ]
226*7c478bd9Sstevel@tonic-gatethen
227*7c478bd9Sstevel@tonic-gate	case $2 in
228*7c478bd9Sstevel@tonic-gate		-*) $USAGE ;;
229*7c478bd9Sstevel@tonic-gate		"") :	;;
230*7c478bd9Sstevel@tonic-gate	esac
231*7c478bd9Sstevel@tonic-gate	if test -f $direct/$FILE -o -f $direct/$FILE/$FILE
232*7c478bd9Sstevel@tonic-gate	then
233*7c478bd9Sstevel@tonic-gate		case $ARG in
234*7c478bd9Sstevel@tonic-gate			-c) echo "install: $FILE already exists in $direct"
235*7c478bd9Sstevel@tonic-gate			    exit 2;;
236*7c478bd9Sstevel@tonic-gate			-f) GRP=`ls -l $direct/$FILE | awk '{print $4}'`
237*7c478bd9Sstevel@tonic-gate			    OWN=`ls -l $direct/$FILE | awk '{print $3}'`
238*7c478bd9Sstevel@tonic-gate			    if [ "$MOVOLD" = yes ]
239*7c478bd9Sstevel@tonic-gate			    then
240*7c478bd9Sstevel@tonic-gate				mv -f $direct/$FILE $direct/OLD$FILE
241*7c478bd9Sstevel@tonic-gate				cp $direct/OLD$FILE $direct/$FILE
242*7c478bd9Sstevel@tonic-gate				if [ $? = 0 ]
243*7c478bd9Sstevel@tonic-gate				then
244*7c478bd9Sstevel@tonic-gate				   $ECHO "$FILE moved to $direct/OLD$FILE"
245*7c478bd9Sstevel@tonic-gate				else
246*7c478bd9Sstevel@tonic-gate				   echo "install: mv $direct/OLD$FILE $direct/$FILE failed"
247*7c478bd9Sstevel@tonic-gate				   exit 2
248*7c478bd9Sstevel@tonic-gate				fi
249*7c478bd9Sstevel@tonic-gate			    fi
250*7c478bd9Sstevel@tonic-gate			    if cp $FILEP $direct/$FILE
251*7c478bd9Sstevel@tonic-gate			    then
252*7c478bd9Sstevel@tonic-gate				chgrp $GRP $direct/$FILE
253*7c478bd9Sstevel@tonic-gate				chown $OWN $direct/$FILE
254*7c478bd9Sstevel@tonic-gate
255*7c478bd9Sstevel@tonic-gate				if [ "$GFLAG" = on ]
256*7c478bd9Sstevel@tonic-gate				then
257*7c478bd9Sstevel@tonic-gate					chgrp $GROUP $direct/$FILE
258*7c478bd9Sstevel@tonic-gate				fi
259*7c478bd9Sstevel@tonic-gate				if [ "$MFLAG" = on ]
260*7c478bd9Sstevel@tonic-gate				then
261*7c478bd9Sstevel@tonic-gate					chmod $MODE $direct/$FILE
262*7c478bd9Sstevel@tonic-gate				fi
263*7c478bd9Sstevel@tonic-gate				if [ "$UFLAG" = on ]
264*7c478bd9Sstevel@tonic-gate				then
265*7c478bd9Sstevel@tonic-gate					chown $OWNER $direct/$FILE
266*7c478bd9Sstevel@tonic-gate				fi
267*7c478bd9Sstevel@tonic-gate
268*7c478bd9Sstevel@tonic-gate				$ECHO "$FILEP installed as $direct/$FILE"
269*7c478bd9Sstevel@tonic-gate			    else
270*7c478bd9Sstevel@tonic-gate				echo "install: cp $FILEP $direct/$FILE failed "
271*7c478bd9Sstevel@tonic-gate				exit 2
272*7c478bd9Sstevel@tonic-gate			    fi
273*7c478bd9Sstevel@tonic-gate			    exit;;
274*7c478bd9Sstevel@tonic-gate		esac
275*7c478bd9Sstevel@tonic-gate	else
276*7c478bd9Sstevel@tonic-gate		cp $FILEP $direct/$FILE
277*7c478bd9Sstevel@tonic-gate		if [ $? = 0 ]
278*7c478bd9Sstevel@tonic-gate		then
279*7c478bd9Sstevel@tonic-gate			$ECHO "$FILEP installed as $direct/$FILE"
280*7c478bd9Sstevel@tonic-gate			chgrp $GROUP $direct/$FILE
281*7c478bd9Sstevel@tonic-gate			chown $OWNER $direct/$FILE
282*7c478bd9Sstevel@tonic-gate			chmod $MODE $direct/$FILE
283*7c478bd9Sstevel@tonic-gate		else
284*7c478bd9Sstevel@tonic-gate			echo "install: cp $FILEP $direct/$FILE failed "
285*7c478bd9Sstevel@tonic-gate			exit 2
286*7c478bd9Sstevel@tonic-gate		fi
287*7c478bd9Sstevel@tonic-gate	fi
288*7c478bd9Sstevel@tonic-gate	exit
289*7c478bd9Sstevel@tonic-gatefi
290*7c478bd9Sstevel@tonic-gate
291*7c478bd9Sstevel@tonic-gateshift
292*7c478bd9Sstevel@tonic-gate
293*7c478bd9Sstevel@tonic-gatePUTHERE=""
294*7c478bd9Sstevel@tonic-gatefor i in $*
295*7c478bd9Sstevel@tonic-gatedo
296*7c478bd9Sstevel@tonic-gate	case $i in
297*7c478bd9Sstevel@tonic-gate		-*) $USAGE ;;
298*7c478bd9Sstevel@tonic-gate	esac
299*7c478bd9Sstevel@tonic-gate	PUTHOLD=`find $i -follow -name $FILE -type f -print`
300*7c478bd9Sstevel@tonic-gate	PUTHERE=`expr "\`echo $PUTHOLD\`" : '\([^ ]*\)'`
301*7c478bd9Sstevel@tonic-gate	if [ "$PUTHERE" != "" ]
302*7c478bd9Sstevel@tonic-gate	then break
303*7c478bd9Sstevel@tonic-gate	fi
304*7c478bd9Sstevel@tonic-gatedone
305*7c478bd9Sstevel@tonic-gateif [ -r $FLIST -a "$PUTHERE" = "" ]
306*7c478bd9Sstevel@tonic-gatethen
307*7c478bd9Sstevel@tonic-gate	PUTHERE=`grep "/${FILE}$" $FLIST | sed  -n -e '1p'`
308*7c478bd9Sstevel@tonic-gate	if [ "$PUTHERE" != "" -a "$ROOT" != "" ]
309*7c478bd9Sstevel@tonic-gate	then
310*7c478bd9Sstevel@tonic-gate		PUTHERE=${ROOT}${PUTHERE}
311*7c478bd9Sstevel@tonic-gate	fi
312*7c478bd9Sstevel@tonic-gatefi
313*7c478bd9Sstevel@tonic-gateif [ "$PUTHERE" = "" ]
314*7c478bd9Sstevel@tonic-gatethen
315*7c478bd9Sstevel@tonic-gate	for i in $DEFAULT
316*7c478bd9Sstevel@tonic-gate	do
317*7c478bd9Sstevel@tonic-gate		PUTHOLD=`find $i -follow -name $FILE -type f -print`
318*7c478bd9Sstevel@tonic-gate		PUTHERE=`expr "\`echo $PUTHOLD\`" : '\([^ ]*\)'`
319*7c478bd9Sstevel@tonic-gate		if [ "$PUTHERE" != "" ]
320*7c478bd9Sstevel@tonic-gate		then break
321*7c478bd9Sstevel@tonic-gate		fi
322*7c478bd9Sstevel@tonic-gate	done
323*7c478bd9Sstevel@tonic-gatefi
324*7c478bd9Sstevel@tonic-gateif [ "$PUTHERE" != "" ]
325*7c478bd9Sstevel@tonic-gatethen
326*7c478bd9Sstevel@tonic-gate		    GRP=`ls -l $PUTHERE | awk '{print $4}'`
327*7c478bd9Sstevel@tonic-gate		    OWN=`ls -l $PUTHERE | awk '{print $3}'`
328*7c478bd9Sstevel@tonic-gate		    if [ "$MOVOLD" = yes ]
329*7c478bd9Sstevel@tonic-gate		    then
330*7c478bd9Sstevel@tonic-gate			old=`echo $PUTHERE | sed -e "s/\/[^\/]*$//"`
331*7c478bd9Sstevel@tonic-gate			mv -f $PUTHERE $old/OLD$FILE
332*7c478bd9Sstevel@tonic-gate			cp $old/OLD$FILE $PUTHERE
333*7c478bd9Sstevel@tonic-gate			if [ $? = 0 ]
334*7c478bd9Sstevel@tonic-gate			then
335*7c478bd9Sstevel@tonic-gate				    $ECHO "old $FILE moved to $old/OLD$FILE"
336*7c478bd9Sstevel@tonic-gate			else
337*7c478bd9Sstevel@tonic-gate				   echo "install: cp $direct/OLD$FILE $direct/$FILE failed"
338*7c478bd9Sstevel@tonic-gate				    exit 2
339*7c478bd9Sstevel@tonic-gate			fi
340*7c478bd9Sstevel@tonic-gate		    fi
341*7c478bd9Sstevel@tonic-gate		    FOUND=y
342*7c478bd9Sstevel@tonic-gate		    if cp $FILEP $PUTHERE
343*7c478bd9Sstevel@tonic-gate		    then
344*7c478bd9Sstevel@tonic-gate			chgrp $GRP $PUTHERE
345*7c478bd9Sstevel@tonic-gate			chown $OWN $PUTHERE
346*7c478bd9Sstevel@tonic-gate
347*7c478bd9Sstevel@tonic-gate			if [ "$GFLAG" = on ]
348*7c478bd9Sstevel@tonic-gate			then
349*7c478bd9Sstevel@tonic-gate				chgrp $GROUP $PUTHERE
350*7c478bd9Sstevel@tonic-gate			fi
351*7c478bd9Sstevel@tonic-gate			if [ "$MFLAG" = on ]
352*7c478bd9Sstevel@tonic-gate			then
353*7c478bd9Sstevel@tonic-gate				chmod $MODE $PUTHERE
354*7c478bd9Sstevel@tonic-gate			fi
355*7c478bd9Sstevel@tonic-gate			if [ "$UFLAG" = on ]
356*7c478bd9Sstevel@tonic-gate			then
357*7c478bd9Sstevel@tonic-gate				chown $OWNER $PUTHERE
358*7c478bd9Sstevel@tonic-gate			fi
359*7c478bd9Sstevel@tonic-gate
360*7c478bd9Sstevel@tonic-gate			$ECHO "$FILEP installed as $PUTHERE"
361*7c478bd9Sstevel@tonic-gate			break
362*7c478bd9Sstevel@tonic-gate		    else
363*7c478bd9Sstevel@tonic-gate			exit 2
364*7c478bd9Sstevel@tonic-gate		    fi
365*7c478bd9Sstevel@tonic-gatefi
366*7c478bd9Sstevel@tonic-gate
367*7c478bd9Sstevel@tonic-gatecase $FOUND in
368*7c478bd9Sstevel@tonic-gate	"") echo "install: $FILE was not found anywhere!"
369*7c478bd9Sstevel@tonic-gate	    exit 2;;
370*7c478bd9Sstevel@tonic-gate	 y) :	;;
371*7c478bd9Sstevel@tonic-gate	 n) cp $FILEP $LASTRES/$FILE
372*7c478bd9Sstevel@tonic-gate	    if [ $? = 0 ]
373*7c478bd9Sstevel@tonic-gate	    then
374*7c478bd9Sstevel@tonic-gate		$ECHO "$FILEP installed as $LASTRES/$FILE by default!"
375*7c478bd9Sstevel@tonic-gate		cd $LASTRES
376*7c478bd9Sstevel@tonic-gate		chgrp $GROUP $FILE
377*7c478bd9Sstevel@tonic-gate		chown $OWNER $FILE
378*7c478bd9Sstevel@tonic-gate		chmod $MODE $FILE
379*7c478bd9Sstevel@tonic-gate	    else
380*7c478bd9Sstevel@tonic-gate		echo "install: cp $FILEP $LASTRES/$FILE failed"
381*7c478bd9Sstevel@tonic-gate		exit 2
382*7c478bd9Sstevel@tonic-gate	    fi;;
383*7c478bd9Sstevel@tonic-gateesac
384