5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License, Version 1.0 only
7 # (the "License"). You may not use this file except in compliance
10 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11 # or http://www.opensolaris.org/os/licensing.
12 # See the License for the specific language governing permissions
13 # and limitations under the License.
15 # When distributing Covered Code, include this CDDL HEADER in each
16 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17 # If applicable, add the following below this CDDL HEADER, with the
18 # fields enclosed by brackets "[]" replaced with your own identifying
19 # information: Portions Copyright [yyyy] [name of copyright owner]
23 # Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T
27 #ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.12.1.1 */
31 FLIST
=$ROOT/etc
/syslist
32 DEFAULT
="$ROOT/bin $ROOT/usr/bin $ROOT/etc $ROOT/lib $ROOT/usr/lib" FOUND
="" MOVOLD
=""
33 ECHO
=echo PATH
=/usr
/bin FLAG
=off
34 USAGE
="eval echo 'usage: install [options] file [dir1 ...]'; exit 2"
36 if [ $# -lt 2 ] ; then
45 GRP
=`expr "\`id\
`" : ".*gid=[0-9]*(\(..*\)) .*"`
46 GROUP
=`echo $GRP | sed -e 's/) fsid.*//p'`
47 OWN
=`expr "\`id\
`" : ".*uid=[0-9]*(\(..*\)) .*"`
48 OWNER
=`echo $OWN | sed -e 's/) .*//p'`
51 GROUP
=`expr "\`id\
`" : ".*gid=\([0-9]*\).*"`
55 OWNER
=`expr "\`id\
`" : ".*uid=\([0-9]*\).*"`
57 if [ "$OWNER" = root
]
72 -*) echo "install: The -c, -f, -n options each require a directory following!"
79 -c) if [ x
$ARG = x-d
-o x
$ARG = x-f
]
81 echo "install: -c dir: illegal option with $ARG option!"
83 elif [ x
$arg = x-i
-o x
$arg = x-o
-o x
$arg = x-n
]
85 echo "install: -c dir: illegal option with $arg option!"
89 echo "install: -c option must have at least 3 args!"
97 -f) if [ x
$ARG = x-d
-o x
$ARG = x-c
]
99 echo "install: -f dir: illegal option with $ARG option!"
101 elif [ x
$arg = x-i
-o x
$arg = x-n
]
103 echo "install: -f dir: illegal option with $arg option!"
107 echo "install: -f option must have at least 3 args!"
115 -i) if [ x
$ARG = x-d
-o x
$ARG = x-c
-o x
$ARG = x-f
]
117 echo "install: -i: illegal option with $ARG option!"
121 echo "install: -i option requires at least 3 args!"
128 -o) if [ x
$ARG = x-d
-o x
$ARG = x-c
]
130 echo "install: -o: illegal option with $ARG option!"
140 -n) if [ x
$ARG = x-d
-o x
$ARG = x-c
-o x
$ARG = x-f
]
142 echo "install: -n dir: illegal option with $ARG option!"
146 echo "install: -n option requires at least 3 args!"
155 -d) if [ x
$ARG = x-c
-o x
$ARG = x-f
]
157 echo "install: -d: illegal option with $ARG option!"
159 elif [ x
$arg = x-i
-o x
$arg = x-o
-o x
$arg = x-n
]
161 echo "install: -d: illegal option with $arg option!"
174 -u) if [ $ROOTFLAG = off
]
176 echo "install: -u option available only to root -- ignored"
180 $ECHO new owner is
$OWNER
184 -g) if [ $ROOTFLAG = off
]
186 echo "install: -g option available only to root -- ignored"
209 $ECHO "directory $i created"
214 echo "install: mkdir $i failed "
224 FILEP
=$i FILE
=`echo $i | sed -e "s/.*\///"`
225 if [ x
$ARG = x-c
-o x
$ARG = x-f
]
231 if test -f $direct/$FILE -o -f $direct/$FILE/$FILE
234 -c) echo "install: $FILE already exists in $direct"
236 -f) GRP
=`ls -l $direct/$FILE | awk '{print $4}'`
237 OWN
=`ls -l $direct/$FILE | awk '{print $3}'`
238 if [ "$MOVOLD" = yes ]
240 mv -f $direct/$FILE $direct/OLD
$FILE
241 cp $direct/OLD
$FILE $direct/$FILE
244 $ECHO "$FILE moved to $direct/OLD$FILE"
246 echo "install: mv $direct/OLD$FILE $direct/$FILE failed"
250 if cp $FILEP $direct/$FILE
252 chgrp
$GRP $direct/$FILE
253 chown
$OWN $direct/$FILE
257 chgrp
$GROUP $direct/$FILE
261 chmod $MODE $direct/$FILE
265 chown
$OWNER $direct/$FILE
268 $ECHO "$FILEP installed as $direct/$FILE"
270 echo "install: cp $FILEP $direct/$FILE failed "
276 cp $FILEP $direct/$FILE
279 $ECHO "$FILEP installed as $direct/$FILE"
280 chgrp
$GROUP $direct/$FILE
281 chown
$OWNER $direct/$FILE
282 chmod $MODE $direct/$FILE
284 echo "install: cp $FILEP $direct/$FILE failed "
299 PUTHOLD
=`find $i -follow -name $FILE -type f -print`
300 PUTHERE
=`expr "\`echo $PUTHOLD\
`" : '\([^ ]*\)'`
301 if [ "$PUTHERE" != "" ]
305 if [ -r $FLIST -a "$PUTHERE" = "" ]
307 PUTHERE
=`grep "/${FILE}$" $FLIST | sed -n -e '1p'`
308 if [ "$PUTHERE" != "" -a "$ROOT" != "" ]
310 PUTHERE
=${ROOT}${PUTHERE}
313 if [ "$PUTHERE" = "" ]
317 PUTHOLD
=`find $i -follow -name $FILE -type f -print`
318 PUTHERE
=`expr "\`echo $PUTHOLD\
`" : '\([^ ]*\)'`
319 if [ "$PUTHERE" != "" ]
324 if [ "$PUTHERE" != "" ]
326 GRP
=`ls -l $PUTHERE | awk '{print $4}'`
327 OWN
=`ls -l $PUTHERE | awk '{print $3}'`
328 if [ "$MOVOLD" = yes ]
330 old
=`echo $PUTHERE | sed -e "s/\/[^\/]*$//"`
331 mv -f $PUTHERE $old/OLD
$FILE
332 cp $old/OLD
$FILE $PUTHERE
335 $ECHO "old $FILE moved to $old/OLD$FILE"
337 echo "install: cp $direct/OLD$FILE $direct/$FILE failed"
342 if cp $FILEP $PUTHERE
349 chgrp
$GROUP $PUTHERE
357 chown
$OWNER $PUTHERE
360 $ECHO "$FILEP installed as $PUTHERE"
368 "") echo "install: $FILE was not found anywhere!"
371 n
) cp $FILEP $LASTRES/$FILE
374 $ECHO "$FILEP installed as $LASTRES/$FILE by default!"
380 echo "install: cp $FILEP $LASTRES/$FILE failed"