xref: /onnv-gate/usr/src/cmd/bnu/SetUp (revision 0:68f95e015346)
1*0Sstevel@tonic-gate#!/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:SetUp 2.3.1.9 */
24*0Sstevel@tonic-gate
25*0Sstevel@tonic-gate#	a function to do the dirty work
26*0Sstevel@tonic-gate#	SYNTAX:
27*0Sstevel@tonic-gate#		needit OWNER GROUP MODE name oldname
28*0Sstevel@tonic-gate
29*0Sstevel@tonic-gateneedit() {
30*0Sstevel@tonic-gateif [ ! -f $ETC/$4 ]; then
31*0Sstevel@tonic-gate    if [ -f $LIB/$4 ]; then
32*0Sstevel@tonic-gate	cp $LIB/$4 $ETC/$4
33*0Sstevel@tonic-gate    else
34*0Sstevel@tonic-gate	if [ -n "$5" -a -f $LIB/$5 ]; then
35*0Sstevel@tonic-gate    	    cp $LIB/$5 $ETC/$4
36*0Sstevel@tonic-gate	else
37*0Sstevel@tonic-gate    	    cp $4 $ETC/$4
38*0Sstevel@tonic-gate	fi
39*0Sstevel@tonic-gate    fi
40*0Sstevel@tonic-gatefi
41*0Sstevel@tonic-gatechown $1 $ETC/$4
42*0Sstevel@tonic-gatechgrp $2 $ETC/$4
43*0Sstevel@tonic-gatechmod $3 $ETC/$4
44*0Sstevel@tonic-gaterm -rf $LIB/$4
45*0Sstevel@tonic-gate$SYMLINK $ETC/$4 $LIB/$4
46*0Sstevel@tonic-gate}
47*0Sstevel@tonic-gate
48*0Sstevel@tonic-gateexport IFS PATH
49*0Sstevel@tonic-gateIFS="
50*0Sstevel@tonic-gate"
51*0Sstevel@tonic-gatePATH="/usr/bin"
52*0Sstevel@tonic-gate
53*0Sstevel@tonic-gate# This shell tries to set up all needed uucp database files.
54*0Sstevel@tonic-gate# Since the names changed from previous versions, it copies those.
55*0Sstevel@tonic-gate# For the Permissions, it will generate one if none exists
56*0Sstevel@tonic-gate
57*0Sstevel@tonic-gateLIB=$ROOT/usr/lib/uucp
58*0Sstevel@tonic-gateETC=$ROOT/etc/uucp
59*0Sstevel@tonic-gate
60*0Sstevel@tonic-gateOWNER=uucp
61*0Sstevel@tonic-gateGROUP=uucp
62*0Sstevel@tonic-gate
63*0Sstevel@tonic-gateDBFILES="Config Devconfig Devices Dialcodes Dialers Grades Limits Permissions Poll Sysfiles Systems"
64*0Sstevel@tonic-gate
65*0Sstevel@tonic-gateSYMLINK=${1:-":"};
66*0Sstevel@tonic-gate
67*0Sstevel@tonic-gate# For cross environment, just take default files, and exit.
68*0Sstevel@tonic-gate
69*0Sstevel@tonic-gateif [ -n "$CH" ]; then
70*0Sstevel@tonic-gate    PATH="/bin:/usr/bin"
71*0Sstevel@tonic-gate    for i in $DBFILES
72*0Sstevel@tonic-gate    do
73*0Sstevel@tonic-gate	cp $i $ETC
74*0Sstevel@tonic-gate	rm -rf $LIB/$i
75*0Sstevel@tonic-gate	$SYMLINK $ETC/$i $LIB/$i
76*0Sstevel@tonic-gate    done
77*0Sstevel@tonic-gate    exit
78*0Sstevel@tonic-gatefi
79*0Sstevel@tonic-gate
80*0Sstevel@tonic-gate# For real environment, try to preserve user's database files
81*0Sstevel@tonic-gate
82*0Sstevel@tonic-gateneedit $OWNER $GROUP 644 Config
83*0Sstevel@tonic-gateneedit $OWNER $GROUP 644 Devconfig
84*0Sstevel@tonic-gateneedit $OWNER $GROUP 644 Devices L-devices
85*0Sstevel@tonic-gateneedit $OWNER $GROUP 644 Dialcodes L-dialcodes
86*0Sstevel@tonic-gateneedit $OWNER $GROUP 644 Dialers L-dialers
87*0Sstevel@tonic-gateneedit $OWNER $GROUP 644 Grades
88*0Sstevel@tonic-gateneedit $OWNER $GROUP 644 Limits
89*0Sstevel@tonic-gateneedit $OWNER $GROUP 644 Poll
90*0Sstevel@tonic-gateneedit $OWNER $GROUP 644 Sysfiles
91*0Sstevel@tonic-gateneedit $OWNER $GROUP 600 Systems L.sys
92*0Sstevel@tonic-gate
93*0Sstevel@tonic-gate# Permissions is handles differently
94*0Sstevel@tonic-gateif [ ! -f $ETC/Permissions ]; then
95*0Sstevel@tonic-gate    if [ -f $LIB/Permissions ]; then
96*0Sstevel@tonic-gate	cp $LIB/Permissions $ETC/Permissions
97*0Sstevel@tonic-gate    else
98*0Sstevel@tonic-gate	if [ -f $ETC/PERMISSIONS ]; then
99*0Sstevel@tonic-gate    	    cp $ETC/PERMISSIONS $ETC/Permissions
100*0Sstevel@tonic-gate	else
101*0Sstevel@tonic-gate	    # Try to generate a Permissions file
102*0Sstevel@tonic-gate	    # using uucp entries in /etc/passwd
103*0Sstevel@tonic-gate	    > $ETC/Permissions
104*0Sstevel@tonic-gate	    set - `sed -n "/uucico/s/:.*//p" /etc/passwd`
105*0Sstevel@tonic-gate	    for i
106*0Sstevel@tonic-gate	    do
107*0Sstevel@tonic-gate		echo "\tLOGNAME=$i\n"
108*0Sstevel@tonic-gate	    done > $ETC/Permissions
109*0Sstevel@tonic-gate	fi
110*0Sstevel@tonic-gate    fi
111*0Sstevel@tonic-gatefi
112*0Sstevel@tonic-gatechown $OWNER $ETC/Permissions
113*0Sstevel@tonic-gatechgrp $GROUP $ETC/Permissions
114*0Sstevel@tonic-gatechmod 600 $ETC/Permissions
115*0Sstevel@tonic-gaterm -rf $LIB/Permissions
116*0Sstevel@tonic-gate$SYMLINK $ETC/Permissions $LIB/Permissions
117*0Sstevel@tonic-gate
118