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