xref: /illumos-gate/usr/src/cmd/bnu/Install (revision 581cede61ac9c14d8d4ea452562a567189eead78)
1#!/usr/bin/sh
2#
3# CDDL HEADER START
4#
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
8# with the License.
9#
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.
14#
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]
20#
21# CDDL HEADER END
22#
23#ident	"%Z%%M%	%I%	%E% SMI"	/* from SVR4 bnu:Install 2.3 */
24
25# This shell simulates the action of the install command that
26# is available on system V systems.
27#  It only does the part required for my makefile!
28#
29USAGE="usage: Install -f Directory [-o] [-m mode] [-u owner] [-g group] File"
30#
31# It will copy file to Directory changes the mode, owner and
32# group if specified.  If -o is used, an existing file is moved
33# to OLDfile.
34
35OLD=
36MODE=
37OWNER=
38GROUP=
39FILE=
40
41while [ $# -gt 0 ]
42do
43	case $1 in
44	-o)	OLD="OLD"
45		shift
46		;;
47
48	-f)	shift
49		DIR=$1
50		shift
51		;;
52
53	-f*)	DIR=`echo $1|sed "s/..//"`
54		shift
55		;;
56
57	-m)	shift
58		MODE=$1
59		shift
60		;;
61
62	-m*)	MODE=`echo $1|sed "s/..//"`
63		shift
64		;;
65
66	-u)	shift
67		OWNER=$1
68		shift
69		;;
70
71	-u*)	OWNER=`echo $1|sed "s/..//"`
72		shift
73		;;
74
75	-g)	shift
76		GROUP=$1
77		shift
78		;;
79
80	-g*)	GROUP=`echo $1|sed "s/..//"`
81		shift
82		;;
83
84	*)	FILE=$1
85		break
86		;;
87
88	esac
89done
90
91
92if [ -z "$FILE" -o -z "$DIR" ]; then
93	echo $USAGE
94	exit 1
95fi
96
97if [ -n "$OLD" ]; then
98	echo mv $DIR/$FILE $DIR/OLD$FILE
99	mv $DIR/$FILE $DIR/OLD$FILE
100fi
101
102rm -f $DIR/$FILE
103echo cp $FILE $DIR/$FILE
104cp $FILE $DIR/$FILE
105
106if [ -n "$GROUP" ]; then
107	echo chgrp $GROUP $DIR/$FILE
108	chgrp $GROUP $DIR/$FILE
109fi
110
111if [ -n "$MODE" ]; then
112	echo chmod $MODE $DIR/$FILE
113	chmod $MODE $DIR/$FILE
114fi
115
116
117if [ -n "$OWNER" ]; then
118	echo chown $OWNER $DIR/$FILE
119	chown $OWNER $DIR/$FILE
120fi
121
122ls -l $DIR/$FILE
123