xref: /titanic_51/usr/src/cmd/ypcmd/yp2lscripts/ypmap2src.sh (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate#! /usr/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#
24*7c478bd9Sstevel@tonic-gate# ident	"%Z%%M%	%I%	%E% SMI"
25*7c478bd9Sstevel@tonic-gate#
26*7c478bd9Sstevel@tonic-gate# Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
27*7c478bd9Sstevel@tonic-gate# Use is subject to license terms.
28*7c478bd9Sstevel@tonic-gate#
29*7c478bd9Sstevel@tonic-gate# ypmap2src -- script to generate source files from YP maps.
30*7c478bd9Sstevel@tonic-gate#
31*7c478bd9Sstevel@tonic-gate
32*7c478bd9Sstevel@tonic-gate
33*7c478bd9Sstevel@tonic-gate# Please save a copy of this script before making any changes.
34*7c478bd9Sstevel@tonic-gate
35*7c478bd9Sstevel@tonic-gate
36*7c478bd9Sstevel@tonic-gateusage()
37*7c478bd9Sstevel@tonic-gate{
38*7c478bd9Sstevel@tonic-gateecho "Usage: $PROG [-t] [[-c custom-map-name] ...] [-d domain] -o output-directory [[source-file] ...]"
39*7c478bd9Sstevel@tonic-gateecho " t - Generate source files from TRADITIONAL NIS MAPS, default is NIS2LDAP maps."
40*7c478bd9Sstevel@tonic-gateecho " c - Name of the custom map for which source file needs to be generated."
41*7c478bd9Sstevel@tonic-gateecho " d - Specify a different domain, default is local system domain name."
42*7c478bd9Sstevel@tonic-gateecho " o - Specify the output directory where source files can be generated."
43*7c478bd9Sstevel@tonic-gateecho "source-file - The name of the source file for which needs to be generated."
44*7c478bd9Sstevel@tonic-gateexit 0
45*7c478bd9Sstevel@tonic-gate}
46*7c478bd9Sstevel@tonic-gate
47*7c478bd9Sstevel@tonic-gateparse_argument()
48*7c478bd9Sstevel@tonic-gate{
49*7c478bd9Sstevel@tonic-gatewhile getopts "tc:d:o:" ARG
50*7c478bd9Sstevel@tonic-gatedo
51*7c478bd9Sstevel@tonic-gate  case $ARG in
52*7c478bd9Sstevel@tonic-gate
53*7c478bd9Sstevel@tonic-gate    t) N2LPREFIX=""
54*7c478bd9Sstevel@tonic-gate       MAP_LIST="$NIS_ONLY_MAP_LIST"
55*7c478bd9Sstevel@tonic-gate       ;;
56*7c478bd9Sstevel@tonic-gate    c) CUST_LIST="$CUST_LIST $OPTARG"
57*7c478bd9Sstevel@tonic-gate       ;;
58*7c478bd9Sstevel@tonic-gate    d) DOMAIN=$OPTARG
59*7c478bd9Sstevel@tonic-gate       MAPDIR=/var/yp/"$DOMAIN"
60*7c478bd9Sstevel@tonic-gate       ;;
61*7c478bd9Sstevel@tonic-gate    o) OUTDIR=$OPTARG
62*7c478bd9Sstevel@tonic-gate       ;;
63*7c478bd9Sstevel@tonic-gate    *) echo "ERROR : Invalid argument"
64*7c478bd9Sstevel@tonic-gate       usage
65*7c478bd9Sstevel@tonic-gate       exit 1
66*7c478bd9Sstevel@tonic-gate       ;;
67*7c478bd9Sstevel@tonic-gate  esac
68*7c478bd9Sstevel@tonic-gatedone
69*7c478bd9Sstevel@tonic-gate
70*7c478bd9Sstevel@tonic-gate# This is to handle if "-t" is supplied after "-c"
71*7c478bd9Sstevel@tonic-gatefor MAP in $CUST_LIST
72*7c478bd9Sstevel@tonic-gatedo
73*7c478bd9Sstevel@tonic-gate  CUST_MAP_LIST="$CUST_MAP_LIST ${N2LPREFIX}$MAP"
74*7c478bd9Sstevel@tonic-gatedone
75*7c478bd9Sstevel@tonic-gate
76*7c478bd9Sstevel@tonic-gateif [ -z "$OUTDIR" ]; then
77*7c478bd9Sstevel@tonic-gate  echo "ERROR : output directory has to be specified."
78*7c478bd9Sstevel@tonic-gate  usage
79*7c478bd9Sstevel@tonic-gate  exit 1
80*7c478bd9Sstevel@tonic-gatefi
81*7c478bd9Sstevel@tonic-gate
82*7c478bd9Sstevel@tonic-gate# Set source list if supplied
83*7c478bd9Sstevel@tonic-gateshift `expr $OPTIND - 1`
84*7c478bd9Sstevel@tonic-gateCMDLINE_SRC_LIST="$@"
85*7c478bd9Sstevel@tonic-gate
86*7c478bd9Sstevel@tonic-gate[ $DEBUG -eq 1 ] && echo CMDLINE_SRC_LIST = $CMDLINE_SRC_LIST
87*7c478bd9Sstevel@tonic-gate
88*7c478bd9Sstevel@tonic-gate# If source(s) supplied on command line, then generate ONLY those file(s).
89*7c478bd9Sstevel@tonic-gate
90*7c478bd9Sstevel@tonic-gateif [ "$CMDLINE_SRC_LIST" != "" ]; then
91*7c478bd9Sstevel@tonic-gate  MAP_LIST=""
92*7c478bd9Sstevel@tonic-gate  CMDLINE_SRCS=1
93*7c478bd9Sstevel@tonic-gate
94*7c478bd9Sstevel@tonic-gate  for SRC in $CMDLINE_SRC_LIST
95*7c478bd9Sstevel@tonic-gate  do
96*7c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && echo Parsing Command line SRC = $SRC
97*7c478bd9Sstevel@tonic-gate
98*7c478bd9Sstevel@tonic-gate    case $SRC in
99*7c478bd9Sstevel@tonic-gate      passwd )
100*7c478bd9Sstevel@tonic-gate        MAP=${N2LPREFIX}passwd.byuid
101*7c478bd9Sstevel@tonic-gate        MAP_LIST="$MAP_LIST $MAP"
102*7c478bd9Sstevel@tonic-gate         ;;
103*7c478bd9Sstevel@tonic-gate      group )
104*7c478bd9Sstevel@tonic-gate        MAP=${N2LPREFIX}group.byname
105*7c478bd9Sstevel@tonic-gate        MAP_LIST="$MAP_LIST $MAP"
106*7c478bd9Sstevel@tonic-gate         ;;
107*7c478bd9Sstevel@tonic-gate      hosts )
108*7c478bd9Sstevel@tonic-gate        MAP=${N2LPREFIX}hosts.byaddr
109*7c478bd9Sstevel@tonic-gate        MAP_LIST="$MAP_LIST $MAP"
110*7c478bd9Sstevel@tonic-gate         ;;
111*7c478bd9Sstevel@tonic-gate      ipnodes )
112*7c478bd9Sstevel@tonic-gate        MAP=${N2LPREFIX}ipnodes.byaddr
113*7c478bd9Sstevel@tonic-gate        MAP_LIST="$MAP_LIST $MAP"
114*7c478bd9Sstevel@tonic-gate         ;;
115*7c478bd9Sstevel@tonic-gate      ethers )
116*7c478bd9Sstevel@tonic-gate        MAP=${N2LPREFIX}ethers.byname
117*7c478bd9Sstevel@tonic-gate        MAP_LIST="$MAP_LIST $MAP"
118*7c478bd9Sstevel@tonic-gate         ;;
119*7c478bd9Sstevel@tonic-gate      networks )
120*7c478bd9Sstevel@tonic-gate        MAP=${N2LPREFIX}networks.byaddr
121*7c478bd9Sstevel@tonic-gate        MAP_LIST="$MAP_LIST $MAP"
122*7c478bd9Sstevel@tonic-gate         ;;
123*7c478bd9Sstevel@tonic-gate      rpc )
124*7c478bd9Sstevel@tonic-gate        MAP=${N2LPREFIX}rpc.bynumber
125*7c478bd9Sstevel@tonic-gate        MAP_LIST="$MAP_LIST $MAP"
126*7c478bd9Sstevel@tonic-gate         ;;
127*7c478bd9Sstevel@tonic-gate      services )
128*7c478bd9Sstevel@tonic-gate        MAP=${N2LPREFIX}services.byname
129*7c478bd9Sstevel@tonic-gate        MAP_LIST="$MAP_LIST $MAP"
130*7c478bd9Sstevel@tonic-gate         ;;
131*7c478bd9Sstevel@tonic-gate      protocols )
132*7c478bd9Sstevel@tonic-gate        MAP=${N2LPREFIX}protocols.bynumber
133*7c478bd9Sstevel@tonic-gate        MAP_LIST="$MAP_LIST $MAP"
134*7c478bd9Sstevel@tonic-gate         ;;
135*7c478bd9Sstevel@tonic-gate      netgroup )
136*7c478bd9Sstevel@tonic-gate        MAP=${N2LPREFIX}netgroup
137*7c478bd9Sstevel@tonic-gate        MAP_LIST="$MAP_LIST $MAP"
138*7c478bd9Sstevel@tonic-gate         ;;
139*7c478bd9Sstevel@tonic-gate      bootparams )
140*7c478bd9Sstevel@tonic-gate        MAP=${N2LPREFIX}bootparams
141*7c478bd9Sstevel@tonic-gate        MAP_LIST="$MAP_LIST $MAP"
142*7c478bd9Sstevel@tonic-gate         ;;
143*7c478bd9Sstevel@tonic-gate      aliases )
144*7c478bd9Sstevel@tonic-gate        MAP=${N2LPREFIX}mail.aliases
145*7c478bd9Sstevel@tonic-gate        MAP_LIST="$MAP_LIST $MAP"
146*7c478bd9Sstevel@tonic-gate         ;;
147*7c478bd9Sstevel@tonic-gate      publickey )
148*7c478bd9Sstevel@tonic-gate        MAP=${N2LPREFIX}publickey.byname
149*7c478bd9Sstevel@tonic-gate        MAP_LIST="$MAP_LIST $MAP"
150*7c478bd9Sstevel@tonic-gate         ;;
151*7c478bd9Sstevel@tonic-gate      netid )
152*7c478bd9Sstevel@tonic-gate        MAP=${N2LPREFIX}netid.byname
153*7c478bd9Sstevel@tonic-gate        MAP_LIST="$MAP_LIST $MAP"
154*7c478bd9Sstevel@tonic-gate         ;;
155*7c478bd9Sstevel@tonic-gate      netmasks )
156*7c478bd9Sstevel@tonic-gate        MAP=${N2LPREFIX}netmasks.byaddr
157*7c478bd9Sstevel@tonic-gate        MAP_LIST="$MAP_LIST $MAP"
158*7c478bd9Sstevel@tonic-gate         ;;
159*7c478bd9Sstevel@tonic-gate      passwd.adjunct )
160*7c478bd9Sstevel@tonic-gate        MAP=${N2LPREFIX}passwd.adjunct.byname
161*7c478bd9Sstevel@tonic-gate        MAP_LIST="$MAP_LIST $MAP"
162*7c478bd9Sstevel@tonic-gate         ;;
163*7c478bd9Sstevel@tonic-gate      group.adjunct )
164*7c478bd9Sstevel@tonic-gate        MAP=${N2LPREFIX}group.adjunct.byname
165*7c478bd9Sstevel@tonic-gate        MAP_LIST="$MAP_LIST $MAP"
166*7c478bd9Sstevel@tonic-gate         ;;
167*7c478bd9Sstevel@tonic-gate      timezone )
168*7c478bd9Sstevel@tonic-gate        MAP=${N2LPREFIX}timezone.byname
169*7c478bd9Sstevel@tonic-gate        MAP_LIST="$MAP_LIST $MAP"
170*7c478bd9Sstevel@tonic-gate         ;;
171*7c478bd9Sstevel@tonic-gate      auto.* )
172*7c478bd9Sstevel@tonic-gate        MAP=${N2LPREFIX}${SRC}
173*7c478bd9Sstevel@tonic-gate        MAP_LIST="$MAP_LIST $MAP"
174*7c478bd9Sstevel@tonic-gate         ;;
175*7c478bd9Sstevel@tonic-gate      auth_attr )
176*7c478bd9Sstevel@tonic-gate        MAP=${N2LPREFIX}auth_attr
177*7c478bd9Sstevel@tonic-gate        MAP_LIST="$MAP_LIST $MAP"
178*7c478bd9Sstevel@tonic-gate         ;;
179*7c478bd9Sstevel@tonic-gate      exec_attr )
180*7c478bd9Sstevel@tonic-gate        MAP=${N2LPREFIX}exec_attr
181*7c478bd9Sstevel@tonic-gate        MAP_LIST="$MAP_LIST $MAP"
182*7c478bd9Sstevel@tonic-gate         ;;
183*7c478bd9Sstevel@tonic-gate      prof_attr )
184*7c478bd9Sstevel@tonic-gate        MAP=${N2LPREFIX}prof_attr
185*7c478bd9Sstevel@tonic-gate        MAP_LIST="$MAP_LIST $MAP"
186*7c478bd9Sstevel@tonic-gate         ;;
187*7c478bd9Sstevel@tonic-gate      user_attr )
188*7c478bd9Sstevel@tonic-gate        MAP=${N2LPREFIX}user_attr
189*7c478bd9Sstevel@tonic-gate        MAP_LIST="$MAP_LIST $MAP"
190*7c478bd9Sstevel@tonic-gate         ;;
191*7c478bd9Sstevel@tonic-gate      audit_user )
192*7c478bd9Sstevel@tonic-gate        MAP=${N2LPREFIX}audit_user
193*7c478bd9Sstevel@tonic-gate        MAP_LIST="$MAP_LIST $MAP"
194*7c478bd9Sstevel@tonic-gate         ;;
195*7c478bd9Sstevel@tonic-gate     *) # Not a default source, could be a custom source.
196*7c478bd9Sstevel@tonic-gate        # Then generate source files from all the available
197*7c478bd9Sstevel@tonic-gate        # DBM files for this custom source.
198*7c478bd9Sstevel@tonic-gate
199*7c478bd9Sstevel@tonic-gate        MAPFOUND=0
200*7c478bd9Sstevel@tonic-gate
201*7c478bd9Sstevel@tonic-gate        for dbmfile in $MAPDIR/${N2LPREFIX}${SRC}.dir \
202*7c478bd9Sstevel@tonic-gate            $MAPDIR/${N2LPREFIX}${SRC}.*.dir
203*7c478bd9Sstevel@tonic-gate        do
204*7c478bd9Sstevel@tonic-gate          MAP=`basename $dbmfile .dir`
205*7c478bd9Sstevel@tonic-gate          if [ -f $MAPDIR/${MAP}.pag ]; then
206*7c478bd9Sstevel@tonic-gate            MAPFOUND=1
207*7c478bd9Sstevel@tonic-gate            CUST_MAP_LIST="$CUST_MAP_LIST $MAP"
208*7c478bd9Sstevel@tonic-gate          fi
209*7c478bd9Sstevel@tonic-gate        done
210*7c478bd9Sstevel@tonic-gate
211*7c478bd9Sstevel@tonic-gate        [ $MAPFOUND -eq 0 ] && \
212*7c478bd9Sstevel@tonic-gate           echo ERROR : No maps found for $SRC. Skipping..
213*7c478bd9Sstevel@tonic-gate        ;;
214*7c478bd9Sstevel@tonic-gate   esac
215*7c478bd9Sstevel@tonic-gate  done
216*7c478bd9Sstevel@tonic-gate
217*7c478bd9Sstevel@tonic-gatefi
218*7c478bd9Sstevel@tonic-gate
219*7c478bd9Sstevel@tonic-gate}
220*7c478bd9Sstevel@tonic-gate
221*7c478bd9Sstevel@tonic-gate
222*7c478bd9Sstevel@tonic-gateis_root_user()
223*7c478bd9Sstevel@tonic-gate{
224*7c478bd9Sstevel@tonic-gate  case `id` in
225*7c478bd9Sstevel@tonic-gate    uid=0\(root\)*) return 0
226*7c478bd9Sstevel@tonic-gate                    ;;
227*7c478bd9Sstevel@tonic-gate    * )             return 1
228*7c478bd9Sstevel@tonic-gate                    ;;
229*7c478bd9Sstevel@tonic-gate  esac
230*7c478bd9Sstevel@tonic-gate}
231*7c478bd9Sstevel@tonic-gate
232*7c478bd9Sstevel@tonic-gate
233*7c478bd9Sstevel@tonic-gatecreate_passwd()
234*7c478bd9Sstevel@tonic-gate{
235*7c478bd9Sstevel@tonic-gateSRCFILE=passwd
236*7c478bd9Sstevel@tonic-gateSHADOW=shadow
237*7c478bd9Sstevel@tonic-gate
238*7c478bd9Sstevel@tonic-gatemakedbm -u $MAPDIR/$MAP > $TMPDIR/$MAP
239*7c478bd9Sstevel@tonic-gate
240*7c478bd9Sstevel@tonic-gate# Remove the YP operational lines
241*7c478bd9Sstevel@tonic-gategrep -v YP_LAST_MODIFIED $TMPDIR/$MAP |
242*7c478bd9Sstevel@tonic-gate  grep -v "YP_DOMAIN_NAME $DOMAIN" |
243*7c478bd9Sstevel@tonic-gate  grep -v YP_MASTER_NAME > $TMPDIR/${MAP}.grep
244*7c478bd9Sstevel@tonic-gate
245*7c478bd9Sstevel@tonic-gate# Remove the key
246*7c478bd9Sstevel@tonic-gatecut -f 2- -d " " $TMPDIR/${MAP}.grep > $TMPDIR/${MAP}.cut
247*7c478bd9Sstevel@tonic-gate
248*7c478bd9Sstevel@tonic-gate# Sort the entries in ascending order of uid
249*7c478bd9Sstevel@tonic-gatesort -n -t: -k3,3 $TMPDIR/${MAP}.cut > $TMPDIR/${MAP}.sort
250*7c478bd9Sstevel@tonic-gate
251*7c478bd9Sstevel@tonic-gate# If passwd.adjunct is used, the actual password is stored in
252*7c478bd9Sstevel@tonic-gate# this map, and the passwd map contains "##<uid>" as the passwd.
253*7c478bd9Sstevel@tonic-gate# In that case, do not generate the shadow file.
254*7c478bd9Sstevel@tonic-gate
255*7c478bd9Sstevel@tonic-gateUID=`head -1 $TMPDIR/${MAP}.sort | cut -f1 -d:`
256*7c478bd9Sstevel@tonic-gatePSWD=`head -1 $TMPDIR/${MAP}.sort | cut -f2 -d:`
257*7c478bd9Sstevel@tonic-gateif [ "$PSWD" != "##${UID}" ]; then
258*7c478bd9Sstevel@tonic-gate
259*7c478bd9Sstevel@tonic-gate  #Create the shadow file with blank passwd aging information
260*7c478bd9Sstevel@tonic-gate  cut -f 1,2 -d: $TMPDIR/${MAP}.sort |
261*7c478bd9Sstevel@tonic-gate      sed 's/$/:::::::/' > $OUTDIR/$SHADOW
262*7c478bd9Sstevel@tonic-gate
263*7c478bd9Sstevel@tonic-gate  #Make the shadow file readable to root only
264*7c478bd9Sstevel@tonic-gate  chmod 400 $OUTDIR/$SHADOW
265*7c478bd9Sstevel@tonic-gate
266*7c478bd9Sstevel@tonic-gate  #Create the passwd file with "x" as the passwd
267*7c478bd9Sstevel@tonic-gate  awk ' BEGIN { FS = ":"; OFS = ":"}
268*7c478bd9Sstevel@tonic-gate        {$2 = "x"; print}' $TMPDIR/${MAP}.sort > $OUTDIR/$SRCFILE
269*7c478bd9Sstevel@tonic-gateelse
270*7c478bd9Sstevel@tonic-gate  cp $TMPDIR/${MAP}.sort $OUTDIR/$SRCFILE
271*7c478bd9Sstevel@tonic-gatefi
272*7c478bd9Sstevel@tonic-gate
273*7c478bd9Sstevel@tonic-gate}
274*7c478bd9Sstevel@tonic-gate
275*7c478bd9Sstevel@tonic-gate
276*7c478bd9Sstevel@tonic-gatecreate_group()
277*7c478bd9Sstevel@tonic-gate{
278*7c478bd9Sstevel@tonic-gateSRCFILE=group
279*7c478bd9Sstevel@tonic-gate
280*7c478bd9Sstevel@tonic-gatemakedbm -u $MAPDIR/$MAP > $TMPDIR/$MAP
281*7c478bd9Sstevel@tonic-gate
282*7c478bd9Sstevel@tonic-gate# Remove the YP operational lines
283*7c478bd9Sstevel@tonic-gategrep -v YP_LAST_MODIFIED $TMPDIR/$MAP |
284*7c478bd9Sstevel@tonic-gate  grep -v "YP_DOMAIN_NAME $DOMAIN" |
285*7c478bd9Sstevel@tonic-gate  grep -v YP_MASTER_NAME > $TMPDIR/${MAP}.grep
286*7c478bd9Sstevel@tonic-gate
287*7c478bd9Sstevel@tonic-gate# Remove the key
288*7c478bd9Sstevel@tonic-gatecut -f 2- -d " " $TMPDIR/${MAP}.grep > $TMPDIR/${MAP}.cut
289*7c478bd9Sstevel@tonic-gate
290*7c478bd9Sstevel@tonic-gate# Sort the entries in ascending order of gid
291*7c478bd9Sstevel@tonic-gatesort -n -t: -k3,3 $TMPDIR/${MAP}.cut > $OUTDIR/$SRCFILE
292*7c478bd9Sstevel@tonic-gate}
293*7c478bd9Sstevel@tonic-gate
294*7c478bd9Sstevel@tonic-gate
295*7c478bd9Sstevel@tonic-gatecreate_hosts()
296*7c478bd9Sstevel@tonic-gate{
297*7c478bd9Sstevel@tonic-gateSRCFILE=hosts
298*7c478bd9Sstevel@tonic-gate
299*7c478bd9Sstevel@tonic-gatemakedbm -u $MAPDIR/$MAP > $TMPDIR/$MAP
300*7c478bd9Sstevel@tonic-gate
301*7c478bd9Sstevel@tonic-gate# Remove the YP operational lines
302*7c478bd9Sstevel@tonic-gategrep -v YP_LAST_MODIFIED $TMPDIR/$MAP |
303*7c478bd9Sstevel@tonic-gate  grep -v "YP_DOMAIN_NAME $DOMAIN" |
304*7c478bd9Sstevel@tonic-gate  grep -v YP_MASTER_NAME > $TMPDIR/${MAP}.grep
305*7c478bd9Sstevel@tonic-gate
306*7c478bd9Sstevel@tonic-gate# Remove the key
307*7c478bd9Sstevel@tonic-gatecut -f 2- -d " " $TMPDIR/${MAP}.grep > $TMPDIR/${MAP}.cut
308*7c478bd9Sstevel@tonic-gate
309*7c478bd9Sstevel@tonic-gate# Sort the hosts ip addresses in ascending order
310*7c478bd9Sstevel@tonic-gatesort -n -t. -k1,1 -k2,2 -k3,3 -k4,4 $TMPDIR/${MAP}.cut > $OUTDIR/$SRCFILE
311*7c478bd9Sstevel@tonic-gate}
312*7c478bd9Sstevel@tonic-gate
313*7c478bd9Sstevel@tonic-gate
314*7c478bd9Sstevel@tonic-gatecreate_ipnodes()
315*7c478bd9Sstevel@tonic-gate{
316*7c478bd9Sstevel@tonic-gateSRCFILE=ipnodes
317*7c478bd9Sstevel@tonic-gate
318*7c478bd9Sstevel@tonic-gatemakedbm -u $MAPDIR/$MAP > $TMPDIR/$MAP
319*7c478bd9Sstevel@tonic-gate
320*7c478bd9Sstevel@tonic-gate# Remove the YP operational lines
321*7c478bd9Sstevel@tonic-gategrep -v YP_LAST_MODIFIED $TMPDIR/$MAP |
322*7c478bd9Sstevel@tonic-gate  grep -v "YP_DOMAIN_NAME $DOMAIN" |
323*7c478bd9Sstevel@tonic-gate  grep -v YP_MASTER_NAME > $TMPDIR/${MAP}.grep
324*7c478bd9Sstevel@tonic-gate
325*7c478bd9Sstevel@tonic-gate# Remove the key
326*7c478bd9Sstevel@tonic-gatecut -f 2- -d " " $TMPDIR/${MAP}.grep > $TMPDIR/${MAP}.cut
327*7c478bd9Sstevel@tonic-gate
328*7c478bd9Sstevel@tonic-gategrep -v "::" $TMPDIR/${MAP}.cut >$TMPDIR/${MAP}.V4
329*7c478bd9Sstevel@tonic-gategrep "::" $TMPDIR/${MAP}.cut >$TMPDIR/${MAP}.V6
330*7c478bd9Sstevel@tonic-gate
331*7c478bd9Sstevel@tonic-gate# Sort the ip addresses in ascending order
332*7c478bd9Sstevel@tonic-gatesort -n -t. -k1,1 -k2,2 -k3,3 -k4,4 $TMPDIR/${MAP}.V4 > $OUTDIR/$SRCFILE
333*7c478bd9Sstevel@tonic-gate
334*7c478bd9Sstevel@tonic-gate# V6 addresses due to hex chars, can't be sorted this way.
335*7c478bd9Sstevel@tonic-gate# So just do the default string sort.
336*7c478bd9Sstevel@tonic-gatesort $TMPDIR/${MAP}.V6 >> $OUTDIR/$SRCFILE
337*7c478bd9Sstevel@tonic-gate}
338*7c478bd9Sstevel@tonic-gate
339*7c478bd9Sstevel@tonic-gate
340*7c478bd9Sstevel@tonic-gatecreate_ethers()
341*7c478bd9Sstevel@tonic-gate{
342*7c478bd9Sstevel@tonic-gateSRCFILE=ethers
343*7c478bd9Sstevel@tonic-gate
344*7c478bd9Sstevel@tonic-gatemakedbm -u $MAPDIR/$MAP > $TMPDIR/$MAP
345*7c478bd9Sstevel@tonic-gate
346*7c478bd9Sstevel@tonic-gate# Remove the YP operational lines
347*7c478bd9Sstevel@tonic-gategrep -v YP_LAST_MODIFIED $TMPDIR/$MAP |
348*7c478bd9Sstevel@tonic-gate  grep -v "YP_DOMAIN_NAME $DOMAIN" |
349*7c478bd9Sstevel@tonic-gate  grep -v YP_MASTER_NAME > $TMPDIR/${MAP}.grep
350*7c478bd9Sstevel@tonic-gate
351*7c478bd9Sstevel@tonic-gate# Remove the key
352*7c478bd9Sstevel@tonic-gatecut -f 2- -d " " $TMPDIR/${MAP}.grep > $TMPDIR/${MAP}.cut
353*7c478bd9Sstevel@tonic-gate
354*7c478bd9Sstevel@tonic-gate# Sort ethernet addresses based on host names
355*7c478bd9Sstevel@tonic-gatesort -b -k2 $TMPDIR/${MAP}.cut > $OUTDIR/$SRCFILE
356*7c478bd9Sstevel@tonic-gate}
357*7c478bd9Sstevel@tonic-gate
358*7c478bd9Sstevel@tonic-gate
359*7c478bd9Sstevel@tonic-gatecreate_networks()
360*7c478bd9Sstevel@tonic-gate{
361*7c478bd9Sstevel@tonic-gateSRCFILE=networks
362*7c478bd9Sstevel@tonic-gate
363*7c478bd9Sstevel@tonic-gatemakedbm -u $MAPDIR/$MAP > $TMPDIR/$MAP
364*7c478bd9Sstevel@tonic-gate
365*7c478bd9Sstevel@tonic-gate# Remove the YP operational lines
366*7c478bd9Sstevel@tonic-gategrep -v YP_LAST_MODIFIED $TMPDIR/$MAP |
367*7c478bd9Sstevel@tonic-gate  grep -v "YP_DOMAIN_NAME $DOMAIN" |
368*7c478bd9Sstevel@tonic-gate  grep -v YP_MASTER_NAME > $TMPDIR/${MAP}.grep
369*7c478bd9Sstevel@tonic-gate
370*7c478bd9Sstevel@tonic-gate# Remove the key
371*7c478bd9Sstevel@tonic-gatecut -f 2- -d " " $TMPDIR/${MAP}.grep > $TMPDIR/${MAP}.cut
372*7c478bd9Sstevel@tonic-gate
373*7c478bd9Sstevel@tonic-gate# Sort networks based on their names
374*7c478bd9Sstevel@tonic-gatesort $TMPDIR/${MAP}.cut > $OUTDIR/$SRCFILE
375*7c478bd9Sstevel@tonic-gate}
376*7c478bd9Sstevel@tonic-gate
377*7c478bd9Sstevel@tonic-gate
378*7c478bd9Sstevel@tonic-gatecreate_rpc()
379*7c478bd9Sstevel@tonic-gate{
380*7c478bd9Sstevel@tonic-gateSRCFILE=rpc
381*7c478bd9Sstevel@tonic-gate
382*7c478bd9Sstevel@tonic-gatemakedbm -u $MAPDIR/$MAP > $TMPDIR/$MAP
383*7c478bd9Sstevel@tonic-gate
384*7c478bd9Sstevel@tonic-gate# Remove the YP operational lines
385*7c478bd9Sstevel@tonic-gategrep -v YP_LAST_MODIFIED $TMPDIR/$MAP |
386*7c478bd9Sstevel@tonic-gate  grep -v "YP_DOMAIN_NAME $DOMAIN" |
387*7c478bd9Sstevel@tonic-gate  grep -v YP_MASTER_NAME > $TMPDIR/${MAP}.grep
388*7c478bd9Sstevel@tonic-gate
389*7c478bd9Sstevel@tonic-gate# Remove the key
390*7c478bd9Sstevel@tonic-gatecut -f 2- -d " " $TMPDIR/${MAP}.grep > $TMPDIR/${MAP}.cut
391*7c478bd9Sstevel@tonic-gate
392*7c478bd9Sstevel@tonic-gate# Sort entries in the increasing order of RPC number
393*7c478bd9Sstevel@tonic-gatesort -n -k2 $TMPDIR/${MAP}.cut > $OUTDIR/$SRCFILE
394*7c478bd9Sstevel@tonic-gate}
395*7c478bd9Sstevel@tonic-gate
396*7c478bd9Sstevel@tonic-gate
397*7c478bd9Sstevel@tonic-gatecreate_services()
398*7c478bd9Sstevel@tonic-gate{
399*7c478bd9Sstevel@tonic-gateSRCFILE=services
400*7c478bd9Sstevel@tonic-gate
401*7c478bd9Sstevel@tonic-gatemakedbm -u $MAPDIR/$MAP > $TMPDIR/$MAP
402*7c478bd9Sstevel@tonic-gate
403*7c478bd9Sstevel@tonic-gate# Remove the YP operational lines
404*7c478bd9Sstevel@tonic-gategrep -v YP_LAST_MODIFIED $TMPDIR/$MAP |
405*7c478bd9Sstevel@tonic-gate  grep -v "YP_DOMAIN_NAME $DOMAIN" |
406*7c478bd9Sstevel@tonic-gate  grep -v YP_MASTER_NAME > $TMPDIR/${MAP}.grep
407*7c478bd9Sstevel@tonic-gate
408*7c478bd9Sstevel@tonic-gate# Remove the key
409*7c478bd9Sstevel@tonic-gatecut -f 2- -d " " $TMPDIR/${MAP}.grep > $TMPDIR/${MAP}.cut
410*7c478bd9Sstevel@tonic-gate
411*7c478bd9Sstevel@tonic-gate# Sort entries in the increasing order of RPC number
412*7c478bd9Sstevel@tonic-gatesort -n -k2 $TMPDIR/${MAP}.cut > $OUTDIR/$SRCFILE
413*7c478bd9Sstevel@tonic-gate}
414*7c478bd9Sstevel@tonic-gate
415*7c478bd9Sstevel@tonic-gate
416*7c478bd9Sstevel@tonic-gatecreate_protocols()
417*7c478bd9Sstevel@tonic-gate{
418*7c478bd9Sstevel@tonic-gateSRCFILE=protocols
419*7c478bd9Sstevel@tonic-gate
420*7c478bd9Sstevel@tonic-gatemakedbm -u $MAPDIR/$MAP > $TMPDIR/$MAP
421*7c478bd9Sstevel@tonic-gate
422*7c478bd9Sstevel@tonic-gate# Remove the YP operational lines
423*7c478bd9Sstevel@tonic-gategrep -v YP_LAST_MODIFIED $TMPDIR/$MAP |
424*7c478bd9Sstevel@tonic-gate  grep -v "YP_DOMAIN_NAME $DOMAIN" |
425*7c478bd9Sstevel@tonic-gate  grep -v YP_MASTER_NAME > $TMPDIR/${MAP}.grep
426*7c478bd9Sstevel@tonic-gate
427*7c478bd9Sstevel@tonic-gate# Remove the key
428*7c478bd9Sstevel@tonic-gatecut -f 2- -d " " $TMPDIR/${MAP}.grep > $TMPDIR/${MAP}.cut
429*7c478bd9Sstevel@tonic-gate
430*7c478bd9Sstevel@tonic-gate# Sort entries in the increasing order of RPC number
431*7c478bd9Sstevel@tonic-gatesort -n -k2 $TMPDIR/${MAP}.cut > $OUTDIR/$SRCFILE
432*7c478bd9Sstevel@tonic-gate}
433*7c478bd9Sstevel@tonic-gate
434*7c478bd9Sstevel@tonic-gate
435*7c478bd9Sstevel@tonic-gatecreate_netgroup()
436*7c478bd9Sstevel@tonic-gate{
437*7c478bd9Sstevel@tonic-gateSRCFILE=netgroup
438*7c478bd9Sstevel@tonic-gate
439*7c478bd9Sstevel@tonic-gatemakedbm -u $MAPDIR/$MAP > $TMPDIR/$MAP
440*7c478bd9Sstevel@tonic-gate
441*7c478bd9Sstevel@tonic-gate# Remove the YP operational lines
442*7c478bd9Sstevel@tonic-gategrep -v YP_LAST_MODIFIED $TMPDIR/$MAP |
443*7c478bd9Sstevel@tonic-gate  grep -v "YP_DOMAIN_NAME $DOMAIN" |
444*7c478bd9Sstevel@tonic-gate  grep -v YP_MASTER_NAME > $TMPDIR/${MAP}.grep
445*7c478bd9Sstevel@tonic-gate
446*7c478bd9Sstevel@tonic-gatecp $TMPDIR/${MAP}.grep $OUTDIR/$SRCFILE
447*7c478bd9Sstevel@tonic-gate}
448*7c478bd9Sstevel@tonic-gate
449*7c478bd9Sstevel@tonic-gate
450*7c478bd9Sstevel@tonic-gatecreate_bootparams()
451*7c478bd9Sstevel@tonic-gate{
452*7c478bd9Sstevel@tonic-gateSRCFILE=bootparams
453*7c478bd9Sstevel@tonic-gate
454*7c478bd9Sstevel@tonic-gatemakedbm -u $MAPDIR/$MAP > $TMPDIR/$MAP
455*7c478bd9Sstevel@tonic-gate
456*7c478bd9Sstevel@tonic-gate# Remove the YP operational lines
457*7c478bd9Sstevel@tonic-gategrep -v YP_LAST_MODIFIED $TMPDIR/$MAP |
458*7c478bd9Sstevel@tonic-gate  grep -v "YP_DOMAIN_NAME $DOMAIN" |
459*7c478bd9Sstevel@tonic-gate  grep -v YP_MASTER_NAME > $TMPDIR/${MAP}.grep
460*7c478bd9Sstevel@tonic-gate
461*7c478bd9Sstevel@tonic-gate# Sort the entries
462*7c478bd9Sstevel@tonic-gatesort $TMPDIR/${MAP}.grep > $OUTDIR/$SRCFILE
463*7c478bd9Sstevel@tonic-gate}
464*7c478bd9Sstevel@tonic-gate
465*7c478bd9Sstevel@tonic-gate
466*7c478bd9Sstevel@tonic-gatecreate_aliases()
467*7c478bd9Sstevel@tonic-gate{
468*7c478bd9Sstevel@tonic-gateSRCFILE=aliases
469*7c478bd9Sstevel@tonic-gate
470*7c478bd9Sstevel@tonic-gatemakedbm -u $MAPDIR/$MAP > $TMPDIR/$MAP
471*7c478bd9Sstevel@tonic-gate
472*7c478bd9Sstevel@tonic-gate# Remove the YP operational lines
473*7c478bd9Sstevel@tonic-gategrep -v YP_LAST_MODIFIED $TMPDIR/$MAP |
474*7c478bd9Sstevel@tonic-gate  grep -v "YP_DOMAIN_NAME $DOMAIN" |
475*7c478bd9Sstevel@tonic-gate  grep -v YP_MASTER_NAME > $TMPDIR/${MAP}.grep
476*7c478bd9Sstevel@tonic-gate
477*7c478bd9Sstevel@tonic-gate# Replace first " " with ": " to make it similar to aliases
478*7c478bd9Sstevel@tonic-gatesed 's/ /: /' $TMPDIR/${MAP}.grep > $TMPDIR/${MAP}.sed
479*7c478bd9Sstevel@tonic-gate
480*7c478bd9Sstevel@tonic-gate# Sort aliases entries alphabetically
481*7c478bd9Sstevel@tonic-gatesort $TMPDIR/${MAP}.sed > $OUTDIR/$SRCFILE
482*7c478bd9Sstevel@tonic-gate}
483*7c478bd9Sstevel@tonic-gate
484*7c478bd9Sstevel@tonic-gate
485*7c478bd9Sstevel@tonic-gatecreate_publickey()
486*7c478bd9Sstevel@tonic-gate{
487*7c478bd9Sstevel@tonic-gateSRCFILE=publickey
488*7c478bd9Sstevel@tonic-gate
489*7c478bd9Sstevel@tonic-gatemakedbm -u $MAPDIR/$MAP > $TMPDIR/$MAP
490*7c478bd9Sstevel@tonic-gate
491*7c478bd9Sstevel@tonic-gate# Remove the YP operational lines
492*7c478bd9Sstevel@tonic-gategrep -v YP_LAST_MODIFIED $TMPDIR/$MAP |
493*7c478bd9Sstevel@tonic-gate  grep -v "YP_DOMAIN_NAME $DOMAIN" |
494*7c478bd9Sstevel@tonic-gate  grep -v YP_MASTER_NAME > $TMPDIR/${MAP}.grep
495*7c478bd9Sstevel@tonic-gate
496*7c478bd9Sstevel@tonic-gate# Sort entries alphabetically
497*7c478bd9Sstevel@tonic-gatesort $TMPDIR/${MAP}.grep > $OUTDIR/$SRCFILE
498*7c478bd9Sstevel@tonic-gate}
499*7c478bd9Sstevel@tonic-gate
500*7c478bd9Sstevel@tonic-gate
501*7c478bd9Sstevel@tonic-gatecreate_netid()
502*7c478bd9Sstevel@tonic-gate{
503*7c478bd9Sstevel@tonic-gateSRCFILE=netid
504*7c478bd9Sstevel@tonic-gate
505*7c478bd9Sstevel@tonic-gatemakedbm -u $MAPDIR/$MAP > $TMPDIR/$MAP
506*7c478bd9Sstevel@tonic-gate
507*7c478bd9Sstevel@tonic-gate# Remove the YP operational lines
508*7c478bd9Sstevel@tonic-gategrep -v YP_LAST_MODIFIED $TMPDIR/$MAP |
509*7c478bd9Sstevel@tonic-gate  grep -v "YP_DOMAIN_NAME $DOMAIN" |
510*7c478bd9Sstevel@tonic-gate  grep -v YP_MASTER_NAME > $TMPDIR/${MAP}.grep
511*7c478bd9Sstevel@tonic-gate
512*7c478bd9Sstevel@tonic-gate# netid source files is used to add other domain
513*7c478bd9Sstevel@tonic-gate# entries. So, filter out local domain entries
514*7c478bd9Sstevel@tonic-gategrep -v "@${DOMAIN}" $TMPDIR/${MAP}.grep > $OUTDIR/$SRCFILE
515*7c478bd9Sstevel@tonic-gate}
516*7c478bd9Sstevel@tonic-gate
517*7c478bd9Sstevel@tonic-gate
518*7c478bd9Sstevel@tonic-gatecreate_netmasks()
519*7c478bd9Sstevel@tonic-gate{
520*7c478bd9Sstevel@tonic-gateSRCFILE=netmasks
521*7c478bd9Sstevel@tonic-gate
522*7c478bd9Sstevel@tonic-gatemakedbm -u $MAPDIR/$MAP > $TMPDIR/$MAP
523*7c478bd9Sstevel@tonic-gate
524*7c478bd9Sstevel@tonic-gate# Remove the YP operational lines
525*7c478bd9Sstevel@tonic-gategrep -v YP_LAST_MODIFIED $TMPDIR/$MAP |
526*7c478bd9Sstevel@tonic-gate  grep -v "YP_DOMAIN_NAME $DOMAIN" |
527*7c478bd9Sstevel@tonic-gate  grep -v YP_MASTER_NAME > $TMPDIR/${MAP}.grep
528*7c478bd9Sstevel@tonic-gate
529*7c478bd9Sstevel@tonic-gate# Sort the network numbers in ascending order
530*7c478bd9Sstevel@tonic-gatesort -n -t. -k1,1 -k2,2 -k3,3 -k4,4 $TMPDIR/${MAP}.grep > $OUTDIR/$SRCFILE
531*7c478bd9Sstevel@tonic-gate}
532*7c478bd9Sstevel@tonic-gate
533*7c478bd9Sstevel@tonic-gate
534*7c478bd9Sstevel@tonic-gatecreate_passwd_adjunct()
535*7c478bd9Sstevel@tonic-gate{
536*7c478bd9Sstevel@tonic-gateSRCFILE=passwd.adjunct
537*7c478bd9Sstevel@tonic-gate
538*7c478bd9Sstevel@tonic-gatemakedbm -u $MAPDIR/$MAP > $TMPDIR/$MAP
539*7c478bd9Sstevel@tonic-gate
540*7c478bd9Sstevel@tonic-gate# Remove the YP operational lines. It has three of them.
541*7c478bd9Sstevel@tonic-gategrep -v YP_LAST_MODIFIED $TMPDIR/$MAP |
542*7c478bd9Sstevel@tonic-gate  grep -v "YP_DOMAIN_NAME $DOMAIN" |
543*7c478bd9Sstevel@tonic-gate  grep -v YP_MASTER_NAME | grep -v YP_SECURE > $TMPDIR/${MAP}.grep
544*7c478bd9Sstevel@tonic-gate
545*7c478bd9Sstevel@tonic-gate# Remove the key
546*7c478bd9Sstevel@tonic-gatecut -f 2- -d " " $TMPDIR/${MAP}.grep > $TMPDIR/${MAP}.cut
547*7c478bd9Sstevel@tonic-gate
548*7c478bd9Sstevel@tonic-gate## Check if sorting is ok, or leave it as it is.
549*7c478bd9Sstevel@tonic-gate# Sort the entries in alphabetical order
550*7c478bd9Sstevel@tonic-gatesort $TMPDIR/${MAP}.cut > $OUTDIR/$SRCFILE
551*7c478bd9Sstevel@tonic-gate}
552*7c478bd9Sstevel@tonic-gate
553*7c478bd9Sstevel@tonic-gate
554*7c478bd9Sstevel@tonic-gatecreate_group_adjunct()
555*7c478bd9Sstevel@tonic-gate{
556*7c478bd9Sstevel@tonic-gateSRCFILE=group.adjunct
557*7c478bd9Sstevel@tonic-gate
558*7c478bd9Sstevel@tonic-gatemakedbm -u $MAPDIR/$MAP > $TMPDIR/$MAP
559*7c478bd9Sstevel@tonic-gate
560*7c478bd9Sstevel@tonic-gate# Remove the YP operational lines. It has three of them.
561*7c478bd9Sstevel@tonic-gategrep -v YP_LAST_MODIFIED $TMPDIR/$MAP |
562*7c478bd9Sstevel@tonic-gate  grep -v "YP_DOMAIN_NAME $DOMAIN" |
563*7c478bd9Sstevel@tonic-gate  grep -v YP_MASTER_NAME | grep -v YP_SECURE > $TMPDIR/${MAP}.grep
564*7c478bd9Sstevel@tonic-gate
565*7c478bd9Sstevel@tonic-gate# Remove the key
566*7c478bd9Sstevel@tonic-gatecut -f 2- -d " " $TMPDIR/${MAP}.grep > $TMPDIR/${MAP}.cut
567*7c478bd9Sstevel@tonic-gate
568*7c478bd9Sstevel@tonic-gate# Sort the entries in alphabetical order
569*7c478bd9Sstevel@tonic-gatesort $TMPDIR/${MAP}.cut > $OUTDIR/$SRCFILE
570*7c478bd9Sstevel@tonic-gate}
571*7c478bd9Sstevel@tonic-gate
572*7c478bd9Sstevel@tonic-gate
573*7c478bd9Sstevel@tonic-gatecreate_timezone()
574*7c478bd9Sstevel@tonic-gate{
575*7c478bd9Sstevel@tonic-gateSRCFILE=timezone
576*7c478bd9Sstevel@tonic-gate
577*7c478bd9Sstevel@tonic-gatemakedbm -u $MAPDIR/$MAP > $TMPDIR/$MAP
578*7c478bd9Sstevel@tonic-gate
579*7c478bd9Sstevel@tonic-gate# Remove the YP operational lines
580*7c478bd9Sstevel@tonic-gategrep -v YP_LAST_MODIFIED $TMPDIR/$MAP |
581*7c478bd9Sstevel@tonic-gate  grep -v "YP_DOMAIN_NAME $DOMAIN" |
582*7c478bd9Sstevel@tonic-gate  grep -v YP_MASTER_NAME > $TMPDIR/${MAP}.grep
583*7c478bd9Sstevel@tonic-gate
584*7c478bd9Sstevel@tonic-gate# Remove the key
585*7c478bd9Sstevel@tonic-gatecut -f 2- -d " " $TMPDIR/${MAP}.grep > $TMPDIR/${MAP}.cut
586*7c478bd9Sstevel@tonic-gate
587*7c478bd9Sstevel@tonic-gate# Sort the entries in alphabetical order
588*7c478bd9Sstevel@tonic-gatesort $TMPDIR/${MAP}.cut > $OUTDIR/$SRCFILE
589*7c478bd9Sstevel@tonic-gate}
590*7c478bd9Sstevel@tonic-gate
591*7c478bd9Sstevel@tonic-gate
592*7c478bd9Sstevel@tonic-gatecreate_auto_src()
593*7c478bd9Sstevel@tonic-gate{
594*7c478bd9Sstevel@tonic-gateSRCFILE=$MAP
595*7c478bd9Sstevel@tonic-gate
596*7c478bd9Sstevel@tonic-gatemakedbm -u $MAPDIR/$MAP > $TMPDIR/$MAP
597*7c478bd9Sstevel@tonic-gate
598*7c478bd9Sstevel@tonic-gate# Remove the YP operational lines
599*7c478bd9Sstevel@tonic-gategrep -v YP_LAST_MODIFIED $TMPDIR/$MAP |
600*7c478bd9Sstevel@tonic-gate  grep -v "YP_DOMAIN_NAME $DOMAIN" |
601*7c478bd9Sstevel@tonic-gate  grep -v YP_MASTER_NAME > $TMPDIR/${MAP}.grep
602*7c478bd9Sstevel@tonic-gate
603*7c478bd9Sstevel@tonic-gate# Sort entries alphabetically
604*7c478bd9Sstevel@tonic-gatesort $TMPDIR/${MAP}.grep > $OUTDIR/$SRCFILE
605*7c478bd9Sstevel@tonic-gate}
606*7c478bd9Sstevel@tonic-gate
607*7c478bd9Sstevel@tonic-gate
608*7c478bd9Sstevel@tonic-gatecreate_auth_attr()
609*7c478bd9Sstevel@tonic-gate{
610*7c478bd9Sstevel@tonic-gateSRCFILE=auth_attr
611*7c478bd9Sstevel@tonic-gate
612*7c478bd9Sstevel@tonic-gatemakedbm -u $MAPDIR/$MAP > $TMPDIR/$MAP
613*7c478bd9Sstevel@tonic-gate
614*7c478bd9Sstevel@tonic-gate# Remove the YP operational lines
615*7c478bd9Sstevel@tonic-gategrep -v YP_LAST_MODIFIED $TMPDIR/$MAP |
616*7c478bd9Sstevel@tonic-gate  grep -v "YP_DOMAIN_NAME $DOMAIN" |
617*7c478bd9Sstevel@tonic-gate  grep -v YP_MASTER_NAME > $TMPDIR/${MAP}.grep
618*7c478bd9Sstevel@tonic-gate
619*7c478bd9Sstevel@tonic-gate# Remove the key
620*7c478bd9Sstevel@tonic-gatecut -f 2- -d " " $TMPDIR/${MAP}.grep > $TMPDIR/${MAP}.cut
621*7c478bd9Sstevel@tonic-gate
622*7c478bd9Sstevel@tonic-gate# Sort entries in the alphabetical order
623*7c478bd9Sstevel@tonic-gatesort $TMPDIR/${MAP}.cut > $OUTDIR/$SRCFILE
624*7c478bd9Sstevel@tonic-gate}
625*7c478bd9Sstevel@tonic-gate
626*7c478bd9Sstevel@tonic-gate
627*7c478bd9Sstevel@tonic-gatecreate_exec_attr()
628*7c478bd9Sstevel@tonic-gate{
629*7c478bd9Sstevel@tonic-gateSRCFILE=exec_attr
630*7c478bd9Sstevel@tonic-gate
631*7c478bd9Sstevel@tonic-gatemakedbm -u $MAPDIR/$MAP > $TMPDIR/$MAP
632*7c478bd9Sstevel@tonic-gate
633*7c478bd9Sstevel@tonic-gate# Remove the YP operational lines
634*7c478bd9Sstevel@tonic-gategrep -v YP_LAST_MODIFIED $TMPDIR/$MAP |
635*7c478bd9Sstevel@tonic-gate  grep -v "YP_DOMAIN_NAME $DOMAIN" |
636*7c478bd9Sstevel@tonic-gate  grep -v YP_MASTER_NAME > $TMPDIR/${MAP}.grep
637*7c478bd9Sstevel@tonic-gate
638*7c478bd9Sstevel@tonic-gate# Remove the key which is made of three fields. space is part of key
639*7c478bd9Sstevel@tonic-gatecut -f 3- -d ":" $TMPDIR/${MAP}.grep > $TMPDIR/${MAP}.cut1
640*7c478bd9Sstevel@tonic-gatecut -f 2- -d " " $TMPDIR/${MAP}.cut1 > $TMPDIR/${MAP}.cut2
641*7c478bd9Sstevel@tonic-gate
642*7c478bd9Sstevel@tonic-gate# Sort entries in the alphabetical order
643*7c478bd9Sstevel@tonic-gatesort $TMPDIR/${MAP}.cut2 > $OUTDIR/$SRCFILE
644*7c478bd9Sstevel@tonic-gate}
645*7c478bd9Sstevel@tonic-gate
646*7c478bd9Sstevel@tonic-gate
647*7c478bd9Sstevel@tonic-gatecreate_prof_attr()
648*7c478bd9Sstevel@tonic-gate{
649*7c478bd9Sstevel@tonic-gateSRCFILE=prof_attr
650*7c478bd9Sstevel@tonic-gate
651*7c478bd9Sstevel@tonic-gatemakedbm -u $MAPDIR/$MAP > $TMPDIR/$MAP
652*7c478bd9Sstevel@tonic-gate
653*7c478bd9Sstevel@tonic-gate# Remove the YP operational lines
654*7c478bd9Sstevel@tonic-gategrep -v YP_LAST_MODIFIED $TMPDIR/$MAP |
655*7c478bd9Sstevel@tonic-gate  grep -v "YP_DOMAIN_NAME $DOMAIN" |
656*7c478bd9Sstevel@tonic-gate  grep -v YP_MASTER_NAME > $TMPDIR/${MAP}.grep
657*7c478bd9Sstevel@tonic-gate
658*7c478bd9Sstevel@tonic-gate# Remove the key. It is difficult here as space is part of the key.
659*7c478bd9Sstevel@tonic-gate# From the "key key" part, extract "key", and then paste it with
660*7c478bd9Sstevel@tonic-gate# the rest of the entry.
661*7c478bd9Sstevel@tonic-gatecut -f1 -d: $TMPDIR/${MAP}.grep |
662*7c478bd9Sstevel@tonic-gateawk '{
663*7c478bd9Sstevel@tonic-gate  STR = $1
664*7c478bd9Sstevel@tonic-gate  for (i=2; i <= NF/2; i++) {
665*7c478bd9Sstevel@tonic-gate    STR = STR  " " $i
666*7c478bd9Sstevel@tonic-gate  }
667*7c478bd9Sstevel@tonic-gateprint STR
668*7c478bd9Sstevel@tonic-gate}' > $TMPDIR/${MAP}.cut1
669*7c478bd9Sstevel@tonic-gate
670*7c478bd9Sstevel@tonic-gatecut -f2- -d: $TMPDIR/${MAP}.grep > $TMPDIR/${MAP}.cut2
671*7c478bd9Sstevel@tonic-gatepaste -d ":" $TMPDIR/${MAP}.cut1 $TMPDIR/${MAP}.cut2 > $TMPDIR/${MAP}.cut
672*7c478bd9Sstevel@tonic-gate
673*7c478bd9Sstevel@tonic-gate# Sort entries in the alphabetical order
674*7c478bd9Sstevel@tonic-gatesort $TMPDIR/${MAP}.cut > $OUTDIR/$SRCFILE
675*7c478bd9Sstevel@tonic-gate}
676*7c478bd9Sstevel@tonic-gate
677*7c478bd9Sstevel@tonic-gate
678*7c478bd9Sstevel@tonic-gatecreate_user_attr()
679*7c478bd9Sstevel@tonic-gate{
680*7c478bd9Sstevel@tonic-gateSRCFILE=user_attr
681*7c478bd9Sstevel@tonic-gate
682*7c478bd9Sstevel@tonic-gatemakedbm -u $MAPDIR/$MAP > $TMPDIR/$MAP
683*7c478bd9Sstevel@tonic-gate
684*7c478bd9Sstevel@tonic-gate# Remove the YP operational lines
685*7c478bd9Sstevel@tonic-gategrep -v YP_LAST_MODIFIED $TMPDIR/$MAP |
686*7c478bd9Sstevel@tonic-gate  grep -v "YP_DOMAIN_NAME $DOMAIN" |
687*7c478bd9Sstevel@tonic-gate  grep -v YP_MASTER_NAME > $TMPDIR/${MAP}.grep
688*7c478bd9Sstevel@tonic-gate
689*7c478bd9Sstevel@tonic-gate# Remove the key
690*7c478bd9Sstevel@tonic-gatecut -f 2- -d " " $TMPDIR/${MAP}.grep > $TMPDIR/${MAP}.cut
691*7c478bd9Sstevel@tonic-gate
692*7c478bd9Sstevel@tonic-gate# Sort entries in the alphabetical order
693*7c478bd9Sstevel@tonic-gatesort $TMPDIR/${MAP}.cut > $OUTDIR/$SRCFILE
694*7c478bd9Sstevel@tonic-gate}
695*7c478bd9Sstevel@tonic-gate
696*7c478bd9Sstevel@tonic-gate
697*7c478bd9Sstevel@tonic-gatecreate_audit_user()
698*7c478bd9Sstevel@tonic-gate{
699*7c478bd9Sstevel@tonic-gateSRCFILE=audit_user
700*7c478bd9Sstevel@tonic-gate
701*7c478bd9Sstevel@tonic-gatemakedbm -u $MAPDIR/$MAP > $TMPDIR/$MAP
702*7c478bd9Sstevel@tonic-gate
703*7c478bd9Sstevel@tonic-gate# Remove the YP operational lines. It has 3 of them.
704*7c478bd9Sstevel@tonic-gategrep -v YP_LAST_MODIFIED $TMPDIR/$MAP |
705*7c478bd9Sstevel@tonic-gate  grep -v "YP_DOMAIN_NAME $DOMAIN" |
706*7c478bd9Sstevel@tonic-gate  grep -v YP_MASTER_NAME | grep -v YP_SECURE > $TMPDIR/${MAP}.grep
707*7c478bd9Sstevel@tonic-gate
708*7c478bd9Sstevel@tonic-gate# Remove the key
709*7c478bd9Sstevel@tonic-gatecut -f 2- -d " " $TMPDIR/${MAP}.grep > $TMPDIR/${MAP}.cut
710*7c478bd9Sstevel@tonic-gate
711*7c478bd9Sstevel@tonic-gate# Sort entries in the alphabetical order
712*7c478bd9Sstevel@tonic-gatesort $TMPDIR/${MAP}.cut > $OUTDIR/$SRCFILE
713*7c478bd9Sstevel@tonic-gate}
714*7c478bd9Sstevel@tonic-gate
715*7c478bd9Sstevel@tonic-gate
716*7c478bd9Sstevel@tonic-gate## MAIN ##
717*7c478bd9Sstevel@tonic-gate
718*7c478bd9Sstevel@tonic-gatePROG=`basename $0`
719*7c478bd9Sstevel@tonic-gate
720*7c478bd9Sstevel@tonic-gate# Only root can read the NIS maps, so no point allowing
721*7c478bd9Sstevel@tonic-gate# non-root users to be able to run this script.
722*7c478bd9Sstevel@tonic-gateis_root_user
723*7c478bd9Sstevel@tonic-gateif [ $? -ne 0 ]; then
724*7c478bd9Sstevel@tonic-gate  echo "ERROR : Only root can run $PROG"
725*7c478bd9Sstevel@tonic-gate  exit 1
726*7c478bd9Sstevel@tonic-gatefi
727*7c478bd9Sstevel@tonic-gate
728*7c478bd9Sstevel@tonic-gate# Prevent non-root users from reading/writing
729*7c478bd9Sstevel@tonic-gateumask 077
730*7c478bd9Sstevel@tonic-gate
731*7c478bd9Sstevel@tonic-gate# Initialize default values.
732*7c478bd9Sstevel@tonic-gateDOMAIN=`/usr/bin/domainname`
733*7c478bd9Sstevel@tonic-gateMAPDIR=/var/yp/"$DOMAIN"	# Default to local domain
734*7c478bd9Sstevel@tonic-gateN2LPREFIX=LDAP_
735*7c478bd9Sstevel@tonic-gate
736*7c478bd9Sstevel@tonic-gateNIS_ONLY_MAP_LIST="passwd.byuid
737*7c478bd9Sstevel@tonic-gate                   group.byname
738*7c478bd9Sstevel@tonic-gate                   hosts.byaddr
739*7c478bd9Sstevel@tonic-gate                   ipnodes.byaddr
740*7c478bd9Sstevel@tonic-gate                   ethers.byname
741*7c478bd9Sstevel@tonic-gate                   networks.byaddr
742*7c478bd9Sstevel@tonic-gate                   rpc.bynumber
743*7c478bd9Sstevel@tonic-gate                   services.byname
744*7c478bd9Sstevel@tonic-gate                   protocols.bynumber
745*7c478bd9Sstevel@tonic-gate                   netgroup
746*7c478bd9Sstevel@tonic-gate                   bootparams
747*7c478bd9Sstevel@tonic-gate                   mail.aliases
748*7c478bd9Sstevel@tonic-gate                   publickey.byname
749*7c478bd9Sstevel@tonic-gate                   netid.byname
750*7c478bd9Sstevel@tonic-gate                   netmasks.byaddr
751*7c478bd9Sstevel@tonic-gate                   passwd.adjunct.byname
752*7c478bd9Sstevel@tonic-gate                   group.adjunct.byname
753*7c478bd9Sstevel@tonic-gate                   timezone.byname
754*7c478bd9Sstevel@tonic-gate                   auth_attr
755*7c478bd9Sstevel@tonic-gate                   exec_attr
756*7c478bd9Sstevel@tonic-gate                   prof_attr
757*7c478bd9Sstevel@tonic-gate                   user_attr
758*7c478bd9Sstevel@tonic-gate                   audit_user"
759*7c478bd9Sstevel@tonic-gate
760*7c478bd9Sstevel@tonic-gateNIS2LDAP_MAP_LIST="${N2LPREFIX}passwd.byuid
761*7c478bd9Sstevel@tonic-gate                   ${N2LPREFIX}group.byname
762*7c478bd9Sstevel@tonic-gate                   ${N2LPREFIX}hosts.byaddr
763*7c478bd9Sstevel@tonic-gate                   ${N2LPREFIX}ipnodes.byaddr
764*7c478bd9Sstevel@tonic-gate                   ${N2LPREFIX}ethers.byname
765*7c478bd9Sstevel@tonic-gate                   ${N2LPREFIX}networks.byaddr
766*7c478bd9Sstevel@tonic-gate                   ${N2LPREFIX}rpc.bynumber
767*7c478bd9Sstevel@tonic-gate                   ${N2LPREFIX}services.byname
768*7c478bd9Sstevel@tonic-gate                   ${N2LPREFIX}protocols.bynumber
769*7c478bd9Sstevel@tonic-gate                   ${N2LPREFIX}netgroup
770*7c478bd9Sstevel@tonic-gate                   ${N2LPREFIX}bootparams
771*7c478bd9Sstevel@tonic-gate                   ${N2LPREFIX}mail.aliases
772*7c478bd9Sstevel@tonic-gate                   ${N2LPREFIX}publickey.byname
773*7c478bd9Sstevel@tonic-gate                   ${N2LPREFIX}netid.byname
774*7c478bd9Sstevel@tonic-gate                   ${N2LPREFIX}netmasks.byaddr
775*7c478bd9Sstevel@tonic-gate                   ${N2LPREFIX}passwd.adjunct.byname
776*7c478bd9Sstevel@tonic-gate                   ${N2LPREFIX}group.adjunct.byname
777*7c478bd9Sstevel@tonic-gate                   ${N2LPREFIX}timezone.byname
778*7c478bd9Sstevel@tonic-gate                   ${N2LPREFIX}auth_attr
779*7c478bd9Sstevel@tonic-gate                   ${N2LPREFIX}exec_attr
780*7c478bd9Sstevel@tonic-gate                   ${N2LPREFIX}prof_attr
781*7c478bd9Sstevel@tonic-gate                   ${N2LPREFIX}user_attr
782*7c478bd9Sstevel@tonic-gate                   ${N2LPREFIX}audit_user"
783*7c478bd9Sstevel@tonic-gate
784*7c478bd9Sstevel@tonic-gate
785*7c478bd9Sstevel@tonic-gate# If auto maps exist, add them to the respective lists.
786*7c478bd9Sstevel@tonic-gatefor dbmfile in $MAPDIR/auto.*.dir
787*7c478bd9Sstevel@tonic-gatedo
788*7c478bd9Sstevel@tonic-gate  MAP=`basename $dbmfile .dir`
789*7c478bd9Sstevel@tonic-gate  if [ -f $MAPDIR/${MAP}.pag ]; then
790*7c478bd9Sstevel@tonic-gate    NIS_ONLY_MAP_LIST="$NIS_ONLY_MAP_LIST $MAP"
791*7c478bd9Sstevel@tonic-gate  fi
792*7c478bd9Sstevel@tonic-gatedone
793*7c478bd9Sstevel@tonic-gate
794*7c478bd9Sstevel@tonic-gatefor dbmfile in $MAPDIR/${N2LPREFIX}auto.*.dir
795*7c478bd9Sstevel@tonic-gatedo
796*7c478bd9Sstevel@tonic-gate  MAP=`basename $dbmfile .dir`
797*7c478bd9Sstevel@tonic-gate  if [ -f $MAPDIR/${MAP}.pag ]; then
798*7c478bd9Sstevel@tonic-gate    NIS2LDAP_MAP_LIST="$NIS2LDAP_MAP_LIST $MAP"
799*7c478bd9Sstevel@tonic-gate  fi
800*7c478bd9Sstevel@tonic-gatedone
801*7c478bd9Sstevel@tonic-gate
802*7c478bd9Sstevel@tonic-gate# Default to N2L maps
803*7c478bd9Sstevel@tonic-gateMAP_LIST="$NIS2LDAP_MAP_LIST"
804*7c478bd9Sstevel@tonic-gate
805*7c478bd9Sstevel@tonic-gate# Safe place to avoid anyone from reading sensitive data.
806*7c478bd9Sstevel@tonic-gateTMPDIR="/var/tmp/ypmap2src"
807*7c478bd9Sstevel@tonic-gate
808*7c478bd9Sstevel@tonic-gateDEBUG=0			# Default to debug off
809*7c478bd9Sstevel@tonic-gateDEBUG=1
810*7c478bd9Sstevel@tonic-gateOUTDIR=""
811*7c478bd9Sstevel@tonic-gateCUST_MAP_LIST=""
812*7c478bd9Sstevel@tonic-gateCMDLINE_SRCS=0
813*7c478bd9Sstevel@tonic-gate
814*7c478bd9Sstevel@tonic-gate
815*7c478bd9Sstevel@tonic-gateparse_argument $*
816*7c478bd9Sstevel@tonic-gate
817*7c478bd9Sstevel@tonic-gate[ $DEBUG -eq 1 ] && echo DOMAIN = $DOMAIN
818*7c478bd9Sstevel@tonic-gate[ $DEBUG -eq 1 ] && echo OUTDIR = $OUTDIR
819*7c478bd9Sstevel@tonic-gate[ $DEBUG -eq 1 ] && echo TMPDIR = $TMPDIR
820*7c478bd9Sstevel@tonic-gate[ $DEBUG -eq 1 ] && echo CUST_MAP_LIST = $CUST_MAP_LIST
821*7c478bd9Sstevel@tonic-gate[ $DEBUG -eq 1 ] && echo MAP_LIST = $MAP_LIST
822*7c478bd9Sstevel@tonic-gate
823*7c478bd9Sstevel@tonic-gate[ $DEBUG -eq 1 ] && echo MAPDIR = $MAPDIR
824*7c478bd9Sstevel@tonic-gateif [ ! -d "$MAPDIR" ]; then
825*7c478bd9Sstevel@tonic-gate  echo ERROR : NIS Map directory $MAPDIR does not exist.
826*7c478bd9Sstevel@tonic-gate  exit 1
827*7c478bd9Sstevel@tonic-gatefi
828*7c478bd9Sstevel@tonic-gate
829*7c478bd9Sstevel@tonic-gateif [ ! -d "$OUTDIR" ]; then
830*7c478bd9Sstevel@tonic-gate  echo output directory $OUTDIR does not exist. Creating it.
831*7c478bd9Sstevel@tonic-gate  mkdir -p $OUTDIR
832*7c478bd9Sstevel@tonic-gate  if [ $? -ne 0 ]; then
833*7c478bd9Sstevel@tonic-gate    echo ERROR : Failed to create output directory $OUTDIR
834*7c478bd9Sstevel@tonic-gate    exit 1
835*7c478bd9Sstevel@tonic-gate  fi
836*7c478bd9Sstevel@tonic-gatefi
837*7c478bd9Sstevel@tonic-gate
838*7c478bd9Sstevel@tonic-gate# Cleanup if the temp directory has been leftover
839*7c478bd9Sstevel@tonic-gate[ -d "$TMPDIR" ] && rm -rf $TMPDIR
840*7c478bd9Sstevel@tonic-gatemkdir $TMPDIR
841*7c478bd9Sstevel@tonic-gateif [ $? -ne 0 ]; then
842*7c478bd9Sstevel@tonic-gate  echo ERROR : Failed to create temp directory $TMPDIR
843*7c478bd9Sstevel@tonic-gate  exit 1
844*7c478bd9Sstevel@tonic-gatefi
845*7c478bd9Sstevel@tonic-gate
846*7c478bd9Sstevel@tonic-gate
847*7c478bd9Sstevel@tonic-gatefor MAP in $MAP_LIST
848*7c478bd9Sstevel@tonic-gatedo
849*7c478bd9Sstevel@tonic-gate  [ $DEBUG -eq 1 ] && echo Processing MAP = $MAP
850*7c478bd9Sstevel@tonic-gate
851*7c478bd9Sstevel@tonic-gate  if [ ! -f $MAPDIR/${MAP}.dir ] || [ ! -f $MAPDIR/${MAP}.pag ]; then
852*7c478bd9Sstevel@tonic-gate
853*7c478bd9Sstevel@tonic-gate    [ $CMDLINE_SRCS -ne 0 ] && \
854*7c478bd9Sstevel@tonic-gate        echo ERROR : Missing DBM file for $MAP in $MAPDIR . Skipping..
855*7c478bd9Sstevel@tonic-gate
856*7c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && [ $CMDLINE_SRCS -eq 0 ] && \
857*7c478bd9Sstevel@tonic-gate        echo No DBM file for $MAP in $MAPDIR . Skipping..
858*7c478bd9Sstevel@tonic-gate    continue
859*7c478bd9Sstevel@tonic-gate  fi
860*7c478bd9Sstevel@tonic-gate
861*7c478bd9Sstevel@tonic-gate  case $MAP in
862*7c478bd9Sstevel@tonic-gate    ${N2LPREFIX}passwd.byuid )
863*7c478bd9Sstevel@tonic-gate      create_passwd
864*7c478bd9Sstevel@tonic-gate       ;;
865*7c478bd9Sstevel@tonic-gate    ${N2LPREFIX}group.byname )
866*7c478bd9Sstevel@tonic-gate      create_group
867*7c478bd9Sstevel@tonic-gate       ;;
868*7c478bd9Sstevel@tonic-gate    ${N2LPREFIX}hosts.byaddr )
869*7c478bd9Sstevel@tonic-gate      create_hosts
870*7c478bd9Sstevel@tonic-gate       ;;
871*7c478bd9Sstevel@tonic-gate    ${N2LPREFIX}ipnodes.byaddr )
872*7c478bd9Sstevel@tonic-gate      create_ipnodes
873*7c478bd9Sstevel@tonic-gate       ;;
874*7c478bd9Sstevel@tonic-gate    ${N2LPREFIX}ethers.byname )
875*7c478bd9Sstevel@tonic-gate      create_ethers
876*7c478bd9Sstevel@tonic-gate       ;;
877*7c478bd9Sstevel@tonic-gate    ${N2LPREFIX}networks.byaddr )
878*7c478bd9Sstevel@tonic-gate      create_networks
879*7c478bd9Sstevel@tonic-gate       ;;
880*7c478bd9Sstevel@tonic-gate    ${N2LPREFIX}rpc.bynumber )
881*7c478bd9Sstevel@tonic-gate      create_rpc
882*7c478bd9Sstevel@tonic-gate       ;;
883*7c478bd9Sstevel@tonic-gate    ${N2LPREFIX}services.byname )
884*7c478bd9Sstevel@tonic-gate      create_services
885*7c478bd9Sstevel@tonic-gate       ;;
886*7c478bd9Sstevel@tonic-gate    ${N2LPREFIX}protocols.bynumber )
887*7c478bd9Sstevel@tonic-gate      create_protocols
888*7c478bd9Sstevel@tonic-gate       ;;
889*7c478bd9Sstevel@tonic-gate    ${N2LPREFIX}netgroup )
890*7c478bd9Sstevel@tonic-gate      create_netgroup
891*7c478bd9Sstevel@tonic-gate       ;;
892*7c478bd9Sstevel@tonic-gate    ${N2LPREFIX}bootparams )
893*7c478bd9Sstevel@tonic-gate      create_bootparams
894*7c478bd9Sstevel@tonic-gate       ;;
895*7c478bd9Sstevel@tonic-gate    ${N2LPREFIX}mail.aliases )
896*7c478bd9Sstevel@tonic-gate      create_aliases
897*7c478bd9Sstevel@tonic-gate       ;;
898*7c478bd9Sstevel@tonic-gate    ${N2LPREFIX}publickey.byname )
899*7c478bd9Sstevel@tonic-gate      create_publickey
900*7c478bd9Sstevel@tonic-gate       ;;
901*7c478bd9Sstevel@tonic-gate    ${N2LPREFIX}netid.byname )
902*7c478bd9Sstevel@tonic-gate      create_netid
903*7c478bd9Sstevel@tonic-gate       ;;
904*7c478bd9Sstevel@tonic-gate    ${N2LPREFIX}netmasks.byaddr )
905*7c478bd9Sstevel@tonic-gate      create_netmasks
906*7c478bd9Sstevel@tonic-gate       ;;
907*7c478bd9Sstevel@tonic-gate    ${N2LPREFIX}passwd.adjunct.byname )
908*7c478bd9Sstevel@tonic-gate      create_passwd_adjunct
909*7c478bd9Sstevel@tonic-gate       ;;
910*7c478bd9Sstevel@tonic-gate    ${N2LPREFIX}group.adjunct.byname )
911*7c478bd9Sstevel@tonic-gate      create_group_adjunct
912*7c478bd9Sstevel@tonic-gate       ;;
913*7c478bd9Sstevel@tonic-gate    ${N2LPREFIX}timezone.byname )
914*7c478bd9Sstevel@tonic-gate      create_timezone
915*7c478bd9Sstevel@tonic-gate       ;;
916*7c478bd9Sstevel@tonic-gate    ${N2LPREFIX}auto.* )
917*7c478bd9Sstevel@tonic-gate      create_auto_src
918*7c478bd9Sstevel@tonic-gate       ;;
919*7c478bd9Sstevel@tonic-gate    ${N2LPREFIX}auth_attr )
920*7c478bd9Sstevel@tonic-gate      create_auth_attr
921*7c478bd9Sstevel@tonic-gate       ;;
922*7c478bd9Sstevel@tonic-gate    ${N2LPREFIX}exec_attr )
923*7c478bd9Sstevel@tonic-gate      create_exec_attr
924*7c478bd9Sstevel@tonic-gate       ;;
925*7c478bd9Sstevel@tonic-gate    ${N2LPREFIX}prof_attr )
926*7c478bd9Sstevel@tonic-gate      create_prof_attr
927*7c478bd9Sstevel@tonic-gate       ;;
928*7c478bd9Sstevel@tonic-gate    ${N2LPREFIX}user_attr )
929*7c478bd9Sstevel@tonic-gate      create_user_attr
930*7c478bd9Sstevel@tonic-gate       ;;
931*7c478bd9Sstevel@tonic-gate    ${N2LPREFIX}audit_user )
932*7c478bd9Sstevel@tonic-gate      create_audit_user
933*7c478bd9Sstevel@tonic-gate       ;;
934*7c478bd9Sstevel@tonic-gate   *) # Not a default map, could be a custom map.
935*7c478bd9Sstevel@tonic-gate      CUST_MAP_LIST="$CUST_MAP_LIST $MAP"
936*7c478bd9Sstevel@tonic-gate      ;;
937*7c478bd9Sstevel@tonic-gate esac
938*7c478bd9Sstevel@tonic-gatedone
939*7c478bd9Sstevel@tonic-gate
940*7c478bd9Sstevel@tonic-gate
941*7c478bd9Sstevel@tonic-gatefor MAP in $CUST_MAP_LIST
942*7c478bd9Sstevel@tonic-gatedo
943*7c478bd9Sstevel@tonic-gate  [ $DEBUG -eq 1 ] && echo Processing Custom MAP = $MAP
944*7c478bd9Sstevel@tonic-gate
945*7c478bd9Sstevel@tonic-gate  if [ ! -f $MAPDIR/${MAP}.dir ] || [ ! -f $MAPDIR/${MAP}.pag ]; then
946*7c478bd9Sstevel@tonic-gate    echo ERROR : Missing DBM file for $MAP in $MAPDIR . Skipping..
947*7c478bd9Sstevel@tonic-gate    continue
948*7c478bd9Sstevel@tonic-gate  fi
949*7c478bd9Sstevel@tonic-gate
950*7c478bd9Sstevel@tonic-gate  makedbm -u $MAPDIR/$MAP > $TMPDIR/$MAP
951*7c478bd9Sstevel@tonic-gate
952*7c478bd9Sstevel@tonic-gate# Remove the YP operational lines. Assuming each custom map
953*7c478bd9Sstevel@tonic-gate# has only these entries (three in n2l mode as shown below, and
954*7c478bd9Sstevel@tonic-gate# two in vanilla NIS mode as it does not have "YP_DOMAIN_NAME".
955*7c478bd9Sstevel@tonic-gate# But that does not require any changes in the code). Modify it
956*7c478bd9Sstevel@tonic-gate# appropriately in other cases.
957*7c478bd9Sstevel@tonic-gate
958*7c478bd9Sstevel@tonic-gate  grep -v YP_LAST_MODIFIED $TMPDIR/$MAP |
959*7c478bd9Sstevel@tonic-gate    grep -v "YP_DOMAIN_NAME $DOMAIN" |
960*7c478bd9Sstevel@tonic-gate    grep -v YP_MASTER_NAME > $TMPDIR/${MAP}.grep
961*7c478bd9Sstevel@tonic-gate
962*7c478bd9Sstevel@tonic-gate# If further processing (e.g., removing key, sorting etc.)
963*7c478bd9Sstevel@tonic-gate# is required, then update the script appropriately.
964*7c478bd9Sstevel@tonic-gate  cp $TMPDIR/${MAP}.grep $OUTDIR/$MAP
965*7c478bd9Sstevel@tonic-gate
966*7c478bd9Sstevel@tonic-gatedone
967*7c478bd9Sstevel@tonic-gate
968*7c478bd9Sstevel@tonic-gate# Leave the temp directory if debug is set
969*7c478bd9Sstevel@tonic-gate[ $DEBUG -eq 0 ] && rm -rf $TMPDIR
970*7c478bd9Sstevel@tonic-gate
971*7c478bd9Sstevel@tonic-gateexit 0
972