xref: /onnv-gate/usr/src/cmd/bnu/Install (revision 0:68f95e015346)
1*0Sstevel@tonic-gate#!/usr/bin/sh
2*0Sstevel@tonic-gate#
3*0Sstevel@tonic-gate# CDDL HEADER START
4*0Sstevel@tonic-gate#
5*0Sstevel@tonic-gate# The contents of this file are subject to the terms of the
6*0Sstevel@tonic-gate# Common Development and Distribution License, Version 1.0 only
7*0Sstevel@tonic-gate# (the "License").  You may not use this file except in compliance
8*0Sstevel@tonic-gate# with the License.
9*0Sstevel@tonic-gate#
10*0Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11*0Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing.
12*0Sstevel@tonic-gate# See the License for the specific language governing permissions
13*0Sstevel@tonic-gate# and limitations under the License.
14*0Sstevel@tonic-gate#
15*0Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each
16*0Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17*0Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the
18*0Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying
19*0Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner]
20*0Sstevel@tonic-gate#
21*0Sstevel@tonic-gate# CDDL HEADER END
22*0Sstevel@tonic-gate#
23*0Sstevel@tonic-gate#ident	"%Z%%M%	%I%	%E% SMI"	/* from SVR4 bnu:Install 2.3 */
24*0Sstevel@tonic-gate
25*0Sstevel@tonic-gate# This shell simulates the action of the install command that
26*0Sstevel@tonic-gate# is available on system V systems.
27*0Sstevel@tonic-gate#  It only does the part required for my makefile!
28*0Sstevel@tonic-gate#
29*0Sstevel@tonic-gateUSAGE="usage: Install -f Directory [-o] [-m mode] [-u owner] [-g group] File"
30*0Sstevel@tonic-gate#
31*0Sstevel@tonic-gate# It will copy file to Directory changes the mode, owner and
32*0Sstevel@tonic-gate# group if specified.  If -o is used, an existing file is moved
33*0Sstevel@tonic-gate# to OLDfile.
34*0Sstevel@tonic-gate
35*0Sstevel@tonic-gateOLD=
36*0Sstevel@tonic-gateMODE=
37*0Sstevel@tonic-gateOWNER=
38*0Sstevel@tonic-gateGROUP=
39*0Sstevel@tonic-gateFILE=
40*0Sstevel@tonic-gate
41*0Sstevel@tonic-gatewhile [ $# -gt 0 ]
42*0Sstevel@tonic-gatedo
43*0Sstevel@tonic-gate	case $1 in
44*0Sstevel@tonic-gate	-o)	OLD="OLD"
45*0Sstevel@tonic-gate		shift
46*0Sstevel@tonic-gate		;;
47*0Sstevel@tonic-gate
48*0Sstevel@tonic-gate	-f)	shift
49*0Sstevel@tonic-gate		DIR=$1
50*0Sstevel@tonic-gate		shift
51*0Sstevel@tonic-gate		;;
52*0Sstevel@tonic-gate
53*0Sstevel@tonic-gate	-f*)	DIR=`echo $1|sed "s/..//"`
54*0Sstevel@tonic-gate		shift
55*0Sstevel@tonic-gate		;;
56*0Sstevel@tonic-gate
57*0Sstevel@tonic-gate	-m)	shift
58*0Sstevel@tonic-gate		MODE=$1
59*0Sstevel@tonic-gate		shift
60*0Sstevel@tonic-gate		;;
61*0Sstevel@tonic-gate
62*0Sstevel@tonic-gate	-m*)	MODE=`echo $1|sed "s/..//"`
63*0Sstevel@tonic-gate		shift
64*0Sstevel@tonic-gate		;;
65*0Sstevel@tonic-gate
66*0Sstevel@tonic-gate	-u)	shift
67*0Sstevel@tonic-gate		OWNER=$1
68*0Sstevel@tonic-gate		shift
69*0Sstevel@tonic-gate		;;
70*0Sstevel@tonic-gate
71*0Sstevel@tonic-gate	-u*)	OWNER=`echo $1|sed "s/..//"`
72*0Sstevel@tonic-gate		shift
73*0Sstevel@tonic-gate		;;
74*0Sstevel@tonic-gate
75*0Sstevel@tonic-gate	-g)	shift
76*0Sstevel@tonic-gate		GROUP=$1
77*0Sstevel@tonic-gate		shift
78*0Sstevel@tonic-gate		;;
79*0Sstevel@tonic-gate
80*0Sstevel@tonic-gate	-g*)	GROUP=`echo $1|sed "s/..//"`
81*0Sstevel@tonic-gate		shift
82*0Sstevel@tonic-gate		;;
83*0Sstevel@tonic-gate
84*0Sstevel@tonic-gate	*)	FILE=$1
85*0Sstevel@tonic-gate		break
86*0Sstevel@tonic-gate		;;
87*0Sstevel@tonic-gate
88*0Sstevel@tonic-gate	esac
89*0Sstevel@tonic-gatedone
90*0Sstevel@tonic-gate
91*0Sstevel@tonic-gate
92*0Sstevel@tonic-gateif [ -z "$FILE" -o -z "$DIR" ]; then
93*0Sstevel@tonic-gate	echo $USAGE
94*0Sstevel@tonic-gate	exit 1
95*0Sstevel@tonic-gatefi
96*0Sstevel@tonic-gate
97*0Sstevel@tonic-gateif [ -n "$OLD" ]; then
98*0Sstevel@tonic-gate	echo mv $DIR/$FILE $DIR/OLD$FILE
99*0Sstevel@tonic-gate	mv $DIR/$FILE $DIR/OLD$FILE
100*0Sstevel@tonic-gatefi
101*0Sstevel@tonic-gate
102*0Sstevel@tonic-gaterm -f $DIR/$FILE
103*0Sstevel@tonic-gateecho cp $FILE $DIR/$FILE
104*0Sstevel@tonic-gatecp $FILE $DIR/$FILE
105*0Sstevel@tonic-gate
106*0Sstevel@tonic-gateif [ -n "$GROUP" ]; then
107*0Sstevel@tonic-gate	echo chgrp $GROUP $DIR/$FILE
108*0Sstevel@tonic-gate	chgrp $GROUP $DIR/$FILE
109*0Sstevel@tonic-gatefi
110*0Sstevel@tonic-gate
111*0Sstevel@tonic-gateif [ -n "$MODE" ]; then
112*0Sstevel@tonic-gate	echo chmod $MODE $DIR/$FILE
113*0Sstevel@tonic-gate	chmod $MODE $DIR/$FILE
114*0Sstevel@tonic-gatefi
115*0Sstevel@tonic-gate
116*0Sstevel@tonic-gate
117*0Sstevel@tonic-gateif [ -n "$OWNER" ]; then
118*0Sstevel@tonic-gate	echo chown $OWNER $DIR/$FILE
119*0Sstevel@tonic-gate	chown $OWNER $DIR/$FILE
120*0Sstevel@tonic-gatefi
121*0Sstevel@tonic-gate
122*0Sstevel@tonic-gatels -l $DIR/$FILE
123