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