xref: /illumos-gate/usr/src/cmd/bnu/SetUp (revision 7c478bd9)
1*7c478bd9Sstevel@tonic-gate#!/bin/sh
2*7c478bd9Sstevel@tonic-gate#
3*7c478bd9Sstevel@tonic-gate# CDDL HEADER START
4*7c478bd9Sstevel@tonic-gate#
5*7c478bd9Sstevel@tonic-gate# The contents of this file are subject to the terms of the
6*7c478bd9Sstevel@tonic-gate# Common Development and Distribution License, Version 1.0 only
7*7c478bd9Sstevel@tonic-gate# (the "License").  You may not use this file except in compliance
8*7c478bd9Sstevel@tonic-gate# with the License.
9*7c478bd9Sstevel@tonic-gate#
10*7c478bd9Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11*7c478bd9Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing.
12*7c478bd9Sstevel@tonic-gate# See the License for the specific language governing permissions
13*7c478bd9Sstevel@tonic-gate# and limitations under the License.
14*7c478bd9Sstevel@tonic-gate#
15*7c478bd9Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each
16*7c478bd9Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17*7c478bd9Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the
18*7c478bd9Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying
19*7c478bd9Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner]
20*7c478bd9Sstevel@tonic-gate#
21*7c478bd9Sstevel@tonic-gate# CDDL HEADER END
22*7c478bd9Sstevel@tonic-gate#
23*7c478bd9Sstevel@tonic-gate#ident	"%Z%%M%	%I%	%E% SMI"	/* from SVR4 bnu:SetUp 2.3.1.9 */
24*7c478bd9Sstevel@tonic-gate
25*7c478bd9Sstevel@tonic-gate#	a function to do the dirty work
26*7c478bd9Sstevel@tonic-gate#	SYNTAX:
27*7c478bd9Sstevel@tonic-gate#		needit OWNER GROUP MODE name oldname
28*7c478bd9Sstevel@tonic-gate
29*7c478bd9Sstevel@tonic-gateneedit() {
30*7c478bd9Sstevel@tonic-gateif [ ! -f $ETC/$4 ]; then
31*7c478bd9Sstevel@tonic-gate    if [ -f $LIB/$4 ]; then
32*7c478bd9Sstevel@tonic-gate	cp $LIB/$4 $ETC/$4
33*7c478bd9Sstevel@tonic-gate    else
34*7c478bd9Sstevel@tonic-gate	if [ -n "$5" -a -f $LIB/$5 ]; then
35*7c478bd9Sstevel@tonic-gate    	    cp $LIB/$5 $ETC/$4
36*7c478bd9Sstevel@tonic-gate	else
37*7c478bd9Sstevel@tonic-gate    	    cp $4 $ETC/$4
38*7c478bd9Sstevel@tonic-gate	fi
39*7c478bd9Sstevel@tonic-gate    fi
40*7c478bd9Sstevel@tonic-gatefi
41*7c478bd9Sstevel@tonic-gatechown $1 $ETC/$4
42*7c478bd9Sstevel@tonic-gatechgrp $2 $ETC/$4
43*7c478bd9Sstevel@tonic-gatechmod $3 $ETC/$4
44*7c478bd9Sstevel@tonic-gaterm -rf $LIB/$4
45*7c478bd9Sstevel@tonic-gate$SYMLINK $ETC/$4 $LIB/$4
46*7c478bd9Sstevel@tonic-gate}
47*7c478bd9Sstevel@tonic-gate
48*7c478bd9Sstevel@tonic-gateexport IFS PATH
49*7c478bd9Sstevel@tonic-gateIFS="
50*7c478bd9Sstevel@tonic-gate"
51*7c478bd9Sstevel@tonic-gatePATH="/usr/bin"
52*7c478bd9Sstevel@tonic-gate
53*7c478bd9Sstevel@tonic-gate# This shell tries to set up all needed uucp database files.
54*7c478bd9Sstevel@tonic-gate# Since the names changed from previous versions, it copies those.
55*7c478bd9Sstevel@tonic-gate# For the Permissions, it will generate one if none exists
56*7c478bd9Sstevel@tonic-gate
57*7c478bd9Sstevel@tonic-gateLIB=$ROOT/usr/lib/uucp
58*7c478bd9Sstevel@tonic-gateETC=$ROOT/etc/uucp
59*7c478bd9Sstevel@tonic-gate
60*7c478bd9Sstevel@tonic-gateOWNER=uucp
61*7c478bd9Sstevel@tonic-gateGROUP=uucp
62*7c478bd9Sstevel@tonic-gate
63*7c478bd9Sstevel@tonic-gateDBFILES="Config Devconfig Devices Dialcodes Dialers Grades Limits Permissions Poll Sysfiles Systems"
64*7c478bd9Sstevel@tonic-gate
65*7c478bd9Sstevel@tonic-gateSYMLINK=${1:-":"};
66*7c478bd9Sstevel@tonic-gate
67*7c478bd9Sstevel@tonic-gate# For cross environment, just take default files, and exit.
68*7c478bd9Sstevel@tonic-gate
69*7c478bd9Sstevel@tonic-gateif [ -n "$CH" ]; then
70*7c478bd9Sstevel@tonic-gate    PATH="/bin:/usr/bin"
71*7c478bd9Sstevel@tonic-gate    for i in $DBFILES
72*7c478bd9Sstevel@tonic-gate    do
73*7c478bd9Sstevel@tonic-gate	cp $i $ETC
74*7c478bd9Sstevel@tonic-gate	rm -rf $LIB/$i
75*7c478bd9Sstevel@tonic-gate	$SYMLINK $ETC/$i $LIB/$i
76*7c478bd9Sstevel@tonic-gate    done
77*7c478bd9Sstevel@tonic-gate    exit
78*7c478bd9Sstevel@tonic-gatefi
79*7c478bd9Sstevel@tonic-gate
80*7c478bd9Sstevel@tonic-gate# For real environment, try to preserve user's database files
81*7c478bd9Sstevel@tonic-gate
82*7c478bd9Sstevel@tonic-gateneedit $OWNER $GROUP 644 Config
83*7c478bd9Sstevel@tonic-gateneedit $OWNER $GROUP 644 Devconfig
84*7c478bd9Sstevel@tonic-gateneedit $OWNER $GROUP 644 Devices L-devices
85*7c478bd9Sstevel@tonic-gateneedit $OWNER $GROUP 644 Dialcodes L-dialcodes
86*7c478bd9Sstevel@tonic-gateneedit $OWNER $GROUP 644 Dialers L-dialers
87*7c478bd9Sstevel@tonic-gateneedit $OWNER $GROUP 644 Grades
88*7c478bd9Sstevel@tonic-gateneedit $OWNER $GROUP 644 Limits
89*7c478bd9Sstevel@tonic-gateneedit $OWNER $GROUP 644 Poll
90*7c478bd9Sstevel@tonic-gateneedit $OWNER $GROUP 644 Sysfiles
91*7c478bd9Sstevel@tonic-gateneedit $OWNER $GROUP 600 Systems L.sys
92*7c478bd9Sstevel@tonic-gate
93*7c478bd9Sstevel@tonic-gate# Permissions is handles differently
94*7c478bd9Sstevel@tonic-gateif [ ! -f $ETC/Permissions ]; then
95*7c478bd9Sstevel@tonic-gate    if [ -f $LIB/Permissions ]; then
96*7c478bd9Sstevel@tonic-gate	cp $LIB/Permissions $ETC/Permissions
97*7c478bd9Sstevel@tonic-gate    else
98*7c478bd9Sstevel@tonic-gate	if [ -f $ETC/PERMISSIONS ]; then
99*7c478bd9Sstevel@tonic-gate    	    cp $ETC/PERMISSIONS $ETC/Permissions
100*7c478bd9Sstevel@tonic-gate	else
101*7c478bd9Sstevel@tonic-gate	    # Try to generate a Permissions file
102*7c478bd9Sstevel@tonic-gate	    # using uucp entries in /etc/passwd
103*7c478bd9Sstevel@tonic-gate	    > $ETC/Permissions
104*7c478bd9Sstevel@tonic-gate	    set - `sed -n "/uucico/s/:.*//p" /etc/passwd`
105*7c478bd9Sstevel@tonic-gate	    for i
106*7c478bd9Sstevel@tonic-gate	    do
107*7c478bd9Sstevel@tonic-gate		echo "\tLOGNAME=$i\n"
108*7c478bd9Sstevel@tonic-gate	    done > $ETC/Permissions
109*7c478bd9Sstevel@tonic-gate	fi
110*7c478bd9Sstevel@tonic-gate    fi
111*7c478bd9Sstevel@tonic-gatefi
112*7c478bd9Sstevel@tonic-gatechown $OWNER $ETC/Permissions
113*7c478bd9Sstevel@tonic-gatechgrp $GROUP $ETC/Permissions
114*7c478bd9Sstevel@tonic-gatechmod 600 $ETC/Permissions
115*7c478bd9Sstevel@tonic-gaterm -rf $LIB/Permissions
116*7c478bd9Sstevel@tonic-gate$SYMLINK $ETC/Permissions $LIB/Permissions
117*7c478bd9Sstevel@tonic-gate
118