xref: /freebsd/usr.sbin/ypserv/Makefile.yp (revision b3e932340dfea2508fbbc4f8fa226b922970c073)
1778c7b1cSBill Paul#
2778c7b1cSBill Paul# Makefile for the NIS databases
3778c7b1cSBill Paul#
4b3e93234SBill Paul# $Id: Makefile.yp,v 1.5 1996/06/03 16:24:32 wpaul Exp $
5778c7b1cSBill Paul#
6778c7b1cSBill Paul# This Makefile should only be run on the NIS master server of a domain.
7778c7b1cSBill Paul# All updated maps will be pushed to all NIS slave servers listed in the
8778c7b1cSBill Paul# /var/yp/ypservers file. Please make sure that the hostnames of all
9778c7b1cSBill Paul# NIS servers in your domain are listed in /var/yp/ypservers.
10778c7b1cSBill Paul#
11778c7b1cSBill Paul# This Makefile can be modified to support more NIS maps if desired.
12778c7b1cSBill Paul#
13778c7b1cSBill Paul
14778c7b1cSBill Paul# If this machine is an NIS master, comment out this next line so
15778c7b1cSBill Paul# that changes to the NIS maps can be propagated to the slave servers.
16778c7b1cSBill Paul# (By default we assume that we are only serving a small domain with
17778c7b1cSBill Paul# only one server.)
18778c7b1cSBill Paul#
19778c7b1cSBill PaulNOPUSH = "True"
20778c7b1cSBill Paul
21778c7b1cSBill Paul# If you want to use a FreeBSD NIS server to serve non-FreeBSD clients
22778c7b1cSBill Paul# (i.e. clients who expect the password field in the passwd maps to be
23778c7b1cSBill Paul# valid) then uncomment this line. This will cause $YPDIR/passwd to
24778c7b1cSBill Paul# be generated with valid password fields. This is insecure: FreeBSD
25778c7b1cSBill Paul# normally only serves the master.passwd maps (which have real encrypted
26778c7b1cSBill Paul# passwords in them) to the superuser on other FreeBSD machines, but
27778c7b1cSBill Paul# non-FreeBSD clients (e.g. SunOS, Solaris (without NIS+), IRIX, HP-UX,
28778c7b1cSBill Paul# etc...) will only work properly in 'unsecure' mode.
29778c7b1cSBill Paul#
30778c7b1cSBill Paul#UNSECURE = "True"
31778c7b1cSBill Paul
32778c7b1cSBill Paul# These are commands which this Makefile needs to properly rebuild the
33778c7b1cSBill Paul# NIS databases. Don't change these unless you have a good reason. Also
34778c7b1cSBill Paul# be sure not to place an @ in front of /usr/bin/awk: it isn't necessary
35778c7b1cSBill Paul# and it'll break everything in sight.
36778c7b1cSBill Paul#
37778c7b1cSBill PaulAWK = /usr/bin/awk
38778c7b1cSBill PaulRM  = @/bin/rm -f
39b2264be8SBill PaulMV  = @/bin/mv -f
40778c7b1cSBill PaulRCAT = /bin/cat
41778c7b1cSBill PaulCAT = @$(RCAT)
42b2264be8SBill PaulSED = /usr/bin/sed
43778c7b1cSBill Paul
44778c7b1cSBill PaulDBLOAD = /usr/sbin/yp_mkdb -m `hostname`
45778c7b1cSBill PaulMKNETID = /usr/libexec/mknetid
46b2264be8SBill PaulMKALIASES = /usr/libexec/mkaliases
47b2264be8SBill PaulNEWALIASES = /usr/bin/newaliases
481fff226dSBill PaulYPPUSH = /usr/sbin/yppush
49920491cfSBill Paul.if !defined(UPDATE_DOMAIN)
50778c7b1cSBill PaulDOMAIN = `/bin/domainname`
51920491cfSBill Paul.else
52920491cfSBill PaulDOMAIN = $(UPDATE_DOMAIN)
53920491cfSBill Paul.endif
54778c7b1cSBill PaulREVNETGROUP = /usr/libexec/revnetgroup
55b2264be8SBill PaulNFILE = /tmp/ypmake
56b2264be8SBill PaulTMP = `$(RCAT) $(NFILE)`
57778c7b1cSBill Paul
58b2264be8SBill Paul# It is advisable to create a seperate directory to contain the
59b2264be8SBill Paul# source files used to generate your NIS maps. If you intent to
60b2264be8SBill Paul# support multiple domains, something like /src/dir/$DOMAIN
61b2264be8SBill Paul# would work well.
62778c7b1cSBill PaulYPSRCDIR = /etc
63778c7b1cSBill PaulYPDIR = /var/yp
64778c7b1cSBill PaulYPMAPDIR = $(YPDIR)/$(DOMAIN)
65778c7b1cSBill Paul
66778c7b1cSBill Paul# These are the files from which the NIS databases are built. You may edit
67778c7b1cSBill Paul# these to taste in the event that you wish to keep your NIS source files
68778c7b1cSBill Paul# seperate from your NIS server's actual configuration files. Note that the
69778c7b1cSBill Paul# NIS passwd and master.passwd files are stored in /var/yp: the server's
70778c7b1cSBill Paul# real password database is not used by default. However, you may use
71778c7b1cSBill Paul# the real /etc/passwd and /etc/master.passwd files by:
72778c7b1cSBill Paul#
73778c7b1cSBill Paul#
74778c7b1cSBill Paul# - invoking yppasswdd without the -m option (yppasswdd will use
75778c7b1cSBill Paul#   /etc/master.passwd if no alternate master.passwd file is specified
76778c7b1cSBill Paul#   and do a 'pwd_mkdb' as needed).
77778c7b1cSBill Paul# - Specifying the location of the master.passwd file using the
78778c7b1cSBill Paul#   MASTER_PASSWD variable, i.e.:
79778c7b1cSBill Paul#
80778c7b1cSBill Paul#   # make MASTER_PASSWD=/path/to/some/other/master.passwd
81778c7b1cSBill Paul#
82778c7b1cSBill Paul# - (optionally): editing this Makefile to change the default location.
83778c7b1cSBill Paul#
84778c7b1cSBill Paul# To add a user, edit $(YPDIR)/master.passwd and type 'make'. The raw
85778c7b1cSBill Paul# passwd file will be generated from the master.passwd file automagically.
86778c7b1cSBill Paul#
87778c7b1cSBill PaulETHERS    = $(YPSRCDIR)/ethers	   # ethernet addresses (for rarpd)
88778c7b1cSBill PaulBOOTPARAMS= $(YPSRCDIR)/bootparams # for booting Sun boxes (bootparamd)
89778c7b1cSBill PaulHOSTS     = $(YPSRCDIR)/hosts
90778c7b1cSBill PaulNETWORKS  = $(YPSRCDIR)/networks
91778c7b1cSBill PaulPROTOCOLS = $(YPSRCDIR)/protocols
92778c7b1cSBill PaulRPC 	  = $(YPSRCDIR)/rpc
93778c7b1cSBill PaulSERVICES  = $(YPSRCDIR)/services
94778c7b1cSBill PaulGROUP     = $(YPSRCDIR)/group
95b2264be8SBill PaulALIASES   = $(YPSRCDIR)/aliases
96b2264be8SBill PaulNETGROUP  = $(YPDIR)/netgroup
97778c7b1cSBill PaulPASSWD    = $(YPDIR)/passwd
98778c7b1cSBill Paul.if !defined(MASTER_PASSWD)
99778c7b1cSBill PaulMASTER    = $(YPDIR)/master.passwd
100778c7b1cSBill Paul.else
101778c7b1cSBill PaulMASTER	  = $(MASTER_PASSWD)
102778c7b1cSBill Paul.endif
103778c7b1cSBill PaulYPSERVERS = $(YPDIR)/ypservers	# List of all NIS servers for a domain
104778c7b1cSBill PaulPUBLICKEY = $(YPSRCDIR)/publickey
105778c7b1cSBill Paul
106778c7b1cSBill Paultarget:
107b2264be8SBill Paul	@$(RM) $(NFILE)
108778c7b1cSBill Paul	@if [ ! -d $(DOMAIN) ]; then mkdir $(DOMAIN); fi; \
109920491cfSBill Paul	cd $(DOMAIN) ; echo "NIS Map update started on `date` for domain $(DOMAIN)" ; \
110778c7b1cSBill Paul	make -f ../Makefile all; echo "NIS Map update completed."
111778c7b1cSBill Paul
112778c7b1cSBill Paul# If you don't want some of these maps built, feel free to comment
113778c7b1cSBill Paul# them out from this list.
114778c7b1cSBill Paul# Note that we don't build the ethers or boorparams maps by default
115778c7b1cSBill Paul# since /etc/ethers and /etc/bootparams are not likely to be present
116778c7b1cSBill Paul# on all systems.
117778c7b1cSBill Paul#
118778c7b1cSBill Paul
119b2264be8SBill Paulall:  master.passwd passwd hosts group networks protocols rpc \
120b2264be8SBill Paul      services servers netid # aliases publickey netgroup ethers bootparam
121778c7b1cSBill Paul
122778c7b1cSBill Paulethers:	   ethers.byname ethers.byaddr
123778c7b1cSBill Paulbootparam: bootparams
124778c7b1cSBill Paulhosts:	   hosts.byname hosts.byaddr
125778c7b1cSBill Paulnetworks:  networks.byaddr networks.byname
126778c7b1cSBill Paulprotocols: protocols.bynumber protocols.byname
127778c7b1cSBill Paulrpc:	   rpc.byname rpc.bynumber
128778c7b1cSBill Paulservices:  services.byname
129778c7b1cSBill Paulpasswd:    passwd.byname passwd.byuid
130778c7b1cSBill Paulgroup:     group.byname group.bygid
131778c7b1cSBill Paulnetgrp:    netgroup
132778c7b1cSBill Paulnetid:	   netid.byname
133778c7b1cSBill Paulservers:   ypservers
134778c7b1cSBill Paulpublickey: publickey.byname
135b2264be8SBill Paulaliases:   mail.aliases
136778c7b1cSBill Paul
137778c7b1cSBill Paulmaster.passwd:	master.passwd.byname master.passwd.byuid
138778c7b1cSBill Paul
139b3e93234SBill Paul#
140b3e93234SBill Paul# This is a special target used only when doing in-place updates with
141b3e93234SBill Paul# rpc.yppasswdd. In this case, the maps will be updated by the rpc.yppasswdd
142b3e93234SBill Paul# server and won't need to be remade. They will have to be pushed to the
143b3e93234SBill Paul# slaves however. Calling this target implicitly insures that this will
144b3e93234SBill Paul# happen.
145b3e93234SBill Paul#
146b3e93234SBill Paulpushpw:
147b3e93234SBill Paul	@$(DBLOAD) -c
148b3e93234SBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) master.passwd.byname ; fi
149b3e93234SBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) master.passwd.byuid ; fi
150b3e93234SBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) passwd.byname ; fi
151b3e93234SBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) passwd.byuid ; fi
152b3e93234SBill Paul
153b2264be8SBill Paulmail.aliases: $(ALIASES)
154b2264be8SBill Paul	@echo "Updating $@..."
155b2264be8SBill Paul	@echo $@.$$$$ > $(NFILE)
156b2264be8SBill Paul	$(CAT) $(ALIASES) | \
157b2264be8SBill Paul	$(SED) -e "/^#/d" -e s/#.*$$// -e "/^ *$$/d" |\
158b2264be8SBill Paul	$(MKALIASES) \
159b2264be8SBill Paul		| $(DBLOAD) -i $(ALIASES) -o $(YPMAPDIR)/$@ - $(TMP)
160b2264be8SBill Paul	@$(MV) $(TMP) $@
161b2264be8SBill Paul	@$(DBLOAD) -c
162b2264be8SBill Paul	@$(NEWALIASES)
163b2264be8SBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
164b2264be8SBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
165b2264be8SBill Paul
166778c7b1cSBill Paul
167778c7b1cSBill Paulypservers: $(YPSERVERS)
168778c7b1cSBill Paul	@echo "Updating $@..."
169b2264be8SBill Paul	@echo $@.$$$$ > $(NFILE)
170778c7b1cSBill Paul	$(CAT) $(YPSERVERS) | \
171778c7b1cSBill Paul	$(AWK) '{ if ($$1 != "" && $$1 != "#") print $$0"\t"$$0 }' $^ \
172b2264be8SBill Paul		| $(DBLOAD) -i $(YPSERVERS) -o $(YPMAPDIR)/$@ - $(TMP)
173b2264be8SBill Paul	@$(MV) $(TMP) $@
174b2264be8SBill Paul	@$(DBLOAD) -c
175778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
176778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
177778c7b1cSBill Paul
178b2264be8SBill Paul
179778c7b1cSBill Paulethers.byname: $(ETHERS)
180778c7b1cSBill Paul	@echo "Updating $@..."
181b2264be8SBill Paul	@echo $@.$$$$ > $(NFILE)
182778c7b1cSBill Paul	$(CAT) $(ETHERS) | \
183778c7b1cSBill Paul	$(AWK) '{ if ($$1 != "" && $$1 != "#" && $$1 != "+") \
184778c7b1cSBill Paul		print $$2"\t"$$0 }' $^ | $(DBLOAD) -i $(ETHERS) \
185b2264be8SBill Paul						-o $(YPMAPDIR)/$@ - $(TMP)
186b2264be8SBill Paul	@$(MV) $(TMP) $@
187b2264be8SBill Paul	@$(DBLOAD) -c
188778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) -i $(ETHERS) $@; fi
189778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
190778c7b1cSBill Paul
191778c7b1cSBill Paul
192778c7b1cSBill Paulethers.byaddr: $(ETHERS)
193778c7b1cSBill Paul	@echo "Updating $@..."
194b2264be8SBill Paul	@echo $@.$$$$ > $(NFILE)
195778c7b1cSBill Paul	$(CAT) $(ETHERS) | \
196778c7b1cSBill Paul	$(AWK) '{ if ($$1 != "" && $$1 != "#" && $$1 != "+") \
197778c7b1cSBill Paul		print $$1"\t"$$0 }' $^ | $(DBLOAD) -i $(ETHERS) \
198b2264be8SBill Paul						-o $(YPMAPDIR)/$@ - $(TMP)
199b2264be8SBill Paul	@$(MV) $(TMP) $@
200b2264be8SBill Paul	@$(DBLOAD) -c
201778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
202778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
203778c7b1cSBill Paul
204778c7b1cSBill Paul
205778c7b1cSBill Paulbootparams: $(BOOTPARAMS)
206778c7b1cSBill Paul	@echo "Updating $@..."
207b2264be8SBill Paul	@echo $@.$$$$ > $(NFILE)
208778c7b1cSBill Paul	$(CAT) $(BOOTPARAMS) | \
209778c7b1cSBill Paul	$(AWK) '{ if ($$1 != "" && $$1 != "#" && $$1 != "+") \
210778c7b1cSBill Paul		print $$0 }' $^ | $(DBLOAD) -i $(BOOTPARAMS) \
211b2264be8SBill Paul						-o $(YPMAPDIR)/$@ - $(TMP)
212b2264be8SBill Paul	@$(MV) $(TMP) $@
213b2264be8SBill Paul	@$(DBLOAD) -c
214778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
215778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
216778c7b1cSBill Paul
217778c7b1cSBill Paul
218778c7b1cSBill Paulnetgroup: $(NETGROUP) netgroup.byhost netgroup.byuser
219778c7b1cSBill Paul	@echo "Updating $@..."
220b2264be8SBill Paul	@echo $@.$$$$ > $(NFILE)
221778c7b1cSBill Paul	$(CAT) $(NETGROUP) | \
222778c7b1cSBill Paul	$(AWK) '{ if ($$1 != "" && $$1 != "#" && $$1 != "+") \
223778c7b1cSBill Paul		print $$0 }' $^ | $(DBLOAD) -i $(NETGROUP) \
224b2264be8SBill Paul						-o $(YPMAPDIR)/$@ - $(TMP)
225b2264be8SBill Paul	@$(MV) $(TMP) $@
226b2264be8SBill Paul	@$(DBLOAD) -c
227778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
228778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
229778c7b1cSBill Paul	@$(MAKE) -f ../Makefile netid
230778c7b1cSBill Paul
231778c7b1cSBill Paul
232778c7b1cSBill Paulnetgroup.byhost: $(NETGROUP)
233778c7b1cSBill Paul	@echo "Updating $@..."
234b2264be8SBill Paul	@echo $@.$$$$ > $(NFILE)
235778c7b1cSBill Paul	$(CAT) $(NETGROUP) | $(REVNETGROUP) -h -f $(NETGROUP) | \
236778c7b1cSBill Paul	$(AWK) '{ if ($$1 != "" && $$1 != "#" && $$1 != "+") \
237778c7b1cSBill Paul		print $$0 }' $^ | $(DBLOAD) -i $(NETGROUP) \
238b2264be8SBill Paul						-o $(YPMAPDIR)/$@ - $(TMP)
239b2264be8SBill Paul	@$(MV) $(TMP) $@
240b2264be8SBill Paul	@$(DBLOAD) -c
241778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
242778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
243778c7b1cSBill Paul
244778c7b1cSBill Paul
245778c7b1cSBill Paulnetgroup.byuser: $(NETGROUP)
246778c7b1cSBill Paul	@echo "Updating $@..."
247b2264be8SBill Paul	@echo $@.$$$$ > $(NFILE)
248778c7b1cSBill Paul	$(CAT) $(NETGROUP) | $(REVNETGROUP) -u -f $(NETGROUP) | \
249778c7b1cSBill Paul	$(AWK) '{ if ($$1 != "" && $$1 != "#" && $$1 != "+") \
250778c7b1cSBill Paul		print $$0 }' $^ | $(DBLOAD) -i $(NETGROUP) \
251b2264be8SBill Paul						-o $(YPMAPDIR)/$@ - $(TMP)
252b2264be8SBill Paul	@$(MV) $(TMP) $@
253b2264be8SBill Paul	@$(DBLOAD) -c
254778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
255778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
256778c7b1cSBill Paul
257778c7b1cSBill Paul
258778c7b1cSBill Paulhosts.byname: $(HOSTS)
259778c7b1cSBill Paul	@echo "Updating $@..."
260b2264be8SBill Paul	@echo $@.$$$$ > $(NFILE)
261778c7b1cSBill Paul	$(CAT) $(HOSTS) | \
262778c7b1cSBill Paul	$(AWK) '/^[0-9]/ { for (n=2; n<=NF && $$n !~ "#"; n++) \
263778c7b1cSBill Paul		print $$n"\t"$$0 }' $^ | $(DBLOAD) -i $(HOSTS)  \
264b2264be8SBill Paul						-o $(YPMAPDIR)/$@ - $(TMP)
265b2264be8SBill Paul	@$(MV) $(TMP) $@
266b2264be8SBill Paul	@$(DBLOAD) -c
267778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
268778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
269778c7b1cSBill Paul	@$(MAKE) -f ../Makefile netid
270778c7b1cSBill Paul
271b2264be8SBill Paul
272778c7b1cSBill Paulhosts.byaddr: $(HOSTS)
273778c7b1cSBill Paul	@echo "Updating $@..."
274b2264be8SBill Paul	@echo $@.$$$$ > $(NFILE)
275778c7b1cSBill Paul	$(CAT) $(HOSTS) | \
276778c7b1cSBill Paul	$(AWK) '$$1 !~ "#" { print $$1"\t"$$0 }' $^ \
277b2264be8SBill Paul		| $(DBLOAD) -i $(HOSTS) -o $(YPMAPDIR)/$@ - $(TMP)
278b2264be8SBill Paul	@$(MV) $(TMP) $@
279b2264be8SBill Paul	@$(DBLOAD) -c
280778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
281778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
282778c7b1cSBill Paul	@$(MAKE) -f ../Makefile netid
283778c7b1cSBill Paul
284778c7b1cSBill Paul
285778c7b1cSBill Paulnetworks.byname: $(NETWORKS)
286778c7b1cSBill Paul	@echo "Updating $@..."
287b2264be8SBill Paul	@echo $@.$$$$ > $(NFILE)
288778c7b1cSBill Paul	$(CAT) $(NETWORKS) | \
289778c7b1cSBill Paul	$(AWK) \
290778c7b1cSBill Paul	   '$$1 !~ "#"  { print $$1"\t"$$0; \
291778c7b1cSBill Paul			  for (n=3; n<=NF && $$n !~ "#"; n++) \
292778c7b1cSBill Paul			      print $$n"\t"$$0 \
293b2264be8SBill Paul		}' $^ | $(DBLOAD) -i $(NETWORKS) -o $(YPMAPDIR)/$@ - $(TMP)
294b2264be8SBill Paul	@$(MV) $(TMP) $@
295b2264be8SBill Paul	@$(DBLOAD) -c
296778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
297778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
298778c7b1cSBill Paul
299778c7b1cSBill Paul
300778c7b1cSBill Paulnetworks.byaddr: $(NETWORKS)
301778c7b1cSBill Paul	@echo "Updating $@..."
302b2264be8SBill Paul	@echo $@.$$$$ > $(NFILE)
303778c7b1cSBill Paul	$(CAT) $(NETWORKS) | \
304778c7b1cSBill Paul	$(AWK) '$$1 !~ "#" { print $$2"\t"$$0 }' $^ \
305b2264be8SBill Paul		| $(DBLOAD) -i $(NETWORKS) -o $(YPMAPDIR)/$@ - $(TMP)
306b2264be8SBill Paul	@$(MV) $(TMP) $@
307b2264be8SBill Paul	@$(DBLOAD) -c
308778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
309778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
310778c7b1cSBill Paul
311778c7b1cSBill Paul
312778c7b1cSBill Paulprotocols.byname: $(PROTOCOLS)
313778c7b1cSBill Paul	@echo "Updating $@..."
314b2264be8SBill Paul	@echo $@.$$$$ > $(NFILE)
315778c7b1cSBill Paul	$(CAT) $(PROTOCOLS) | \
316778c7b1cSBill Paul	$(AWK) \
317778c7b1cSBill Paul	   '$$1 !~ "#"	{ print $$1"\t"$$0; \
318778c7b1cSBill Paul			  for (n=3; n<=NF && $$n !~ "#"; n++) \
319778c7b1cSBill Paul			      print $$n"\t"$$0 \
320778c7b1cSBill Paul			}' $^ | $(DBLOAD) -i $(PROTOCOLS) \
321b2264be8SBill Paul						-o $(YPMAPDIR)/$@ - $(TMP)
322b2264be8SBill Paul	@$(MV) $(TMP) $@
323b2264be8SBill Paul	@$(DBLOAD) -c
324778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
325778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
326778c7b1cSBill Paul
327778c7b1cSBill Paul
328778c7b1cSBill Paulprotocols.bynumber: $(PROTOCOLS)
329778c7b1cSBill Paul	@echo "Updating $@..."
330b2264be8SBill Paul	@echo $@.$$$$ > $(NFILE)
331778c7b1cSBill Paul	$(CAT) $(PROTOCOLS) | \
332778c7b1cSBill Paul	$(AWK) '$$1 !~ "#" { print $$2"\t"$$0 }' $^ \
333b2264be8SBill Paul		| $(DBLOAD) -i $(PROTOCOLS) -o $(YPMAPDIR)/$@ - $(TMP)
334b2264be8SBill Paul	@$(MV) $(TMP) $@
335b2264be8SBill Paul	@$(DBLOAD) -c
336778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
337778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
338778c7b1cSBill Paul
339778c7b1cSBill Paul
340778c7b1cSBill Paulrpc.byname: $(RPC)
341778c7b1cSBill Paul	@echo "Updating $@..."
342b2264be8SBill Paul	@echo $@.$$$$ > $(NFILE)
343778c7b1cSBill Paul	$(CAT) $(RPC) | \
344778c7b1cSBill Paul	$(AWK) \
345778c7b1cSBill Paul	   '$$1 !~ "#"  { print $$1"\t"$$0; \
346778c7b1cSBill Paul			  for (n=3; n<=NF && $$n !~ "#"; n++) \
347778c7b1cSBill Paul			      print $$n"\t"$$0 \
348b2264be8SBill Paul		}' $^ | $(DBLOAD) -i $(RPC) -o $(YPMAPDIR)/$@ - $(TMP)
349b2264be8SBill Paul	@$(MV) $(TMP) $@
350b2264be8SBill Paul	@$(DBLOAD) -c
351778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
352778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
353778c7b1cSBill Paul
354778c7b1cSBill Paul
355778c7b1cSBill Paulrpc.bynumber: $(RPC)
356778c7b1cSBill Paul	@echo "Updating $@..."
357b2264be8SBill Paul	@echo $@.$$$$ > $(NFILE)
358778c7b1cSBill Paul	$(CAT) $(RPC) | \
359778c7b1cSBill Paul	$(AWK) '$$1 !~ "#" { print $$2"\t"$$0 }' $^ \
360b2264be8SBill Paul		| $(DBLOAD)  -i $(RPC) -o $(YPMAPDIR)/$@ - $(TMP)
361b2264be8SBill Paul	@$(MV) $(TMP) $@
362b2264be8SBill Paul	@$(DBLOAD) -c
363778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
364778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
365778c7b1cSBill Paul
366778c7b1cSBill Paul
367778c7b1cSBill Paulservices.byname: $(SERVICES)
368778c7b1cSBill Paul	@echo "Updating $@..."
369b2264be8SBill Paul	@echo $@.$$$$ > $(NFILE)
370778c7b1cSBill Paul	$(CAT) $(SERVICES) | \
371778c7b1cSBill Paul	$(AWK) \
372778c7b1cSBill Paul	   '$$1 !~ "#"  { if (index($$2,"udp")) { printf("%s/udp",$$1) } \
373b3e93234SBill Paul			  else { printf("%s/tcp",$$1) }; print "\t"$$0 ; \
374b3e93234SBill Paul			  print $$2"\t"$$0 ; \
375b2264be8SBill Paul		}' $^ | $(DBLOAD) -i $(SERVICES) -o $(YPMAPDIR)/$@ - $(TMP)
376b2264be8SBill Paul	@$(MV) $(TMP) $@
377b2264be8SBill Paul	@$(DBLOAD) -c
378778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
379778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
380778c7b1cSBill Paul
381778c7b1cSBill Paul
382778c7b1cSBill Paulpublickey.byname: $(PUBLICKEY)
383778c7b1cSBill Paul	@echo "Updating $@..."
384b2264be8SBill Paul	@echo $@.$$$$ > $(NFILE)
385b2264be8SBill Paul	$(TMP) = `$(RCAT) $(NFILE)`
386778c7b1cSBill Paul	$(AWK) '$$1 !~ "#" { print $$1"\t"$$2 }' $^ \
387b2264be8SBill Paul		| $(DBLOAD)  -i $(PUBLICKEY) -o $(YPMAPDIR)/$@ - $(TMP)
388b2264be8SBill Paul	@$(MV) $(TMP) $@
389b2264be8SBill Paul	@$(DBLOAD) -c
390778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
391778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
392778c7b1cSBill Paul
393778c7b1cSBill Paul
394778c7b1cSBill Paul$(PASSWD): $(MASTER)
395778c7b1cSBill Paul	@echo "Creating new $@ file from $(MASTER)..."
396778c7b1cSBill Paul	@if [ ! $(UNSECURE) ]; then \
397778c7b1cSBill Paul	$(RCAT) $(MASTER) | \
398778c7b1cSBill Paul	$(AWK) -F: '{if ($$1 != "+") \
399778c7b1cSBill Paul		print $$1":*:"$$3":"$$4":"$$8":"$$9":"$$10}' $^ \
400778c7b1cSBill Paul		> $(PASSWD) ; \
401778c7b1cSBill Paul	else $(RCAT) $(MASTER) | \
402778c7b1cSBill Paul	$(AWK) -F: '{if ($$1 != "+") \
403778c7b1cSBill Paul		print $$1":"$$2":"$$3":"$$4":"$$8":"$$9":"$$10}' $^ \
404778c7b1cSBill Paul		> $(PASSWD) ; fi
405778c7b1cSBill Paul
406778c7b1cSBill Paul
407778c7b1cSBill Paulpasswd.byname: $(PASSWD)
408778c7b1cSBill Paul	@echo "Updating $@..."
409b2264be8SBill Paul	@echo $@.$$$$ > $(NFILE)
410778c7b1cSBill Paul	$(CAT) $(PASSWD) | \
411778c7b1cSBill Paul	$(AWK) -F: '{ if ($$1 != "+") print $$1"\t"$$0 }' $^ \
412b2264be8SBill Paul		| $(DBLOAD) -i $(PASSWD) -o $(YPMAPDIR)/$@ - $(TMP)
413b2264be8SBill Paul	@$(MV) $(TMP) $@
414b2264be8SBill Paul	@$(DBLOAD) -c
415778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
416778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
417778c7b1cSBill Paul
418b2264be8SBill Paul
419778c7b1cSBill Paulpasswd.byuid: $(PASSWD)
420778c7b1cSBill Paul	@echo "Updating $@..."
421b2264be8SBill Paul	@echo $@.$$$$ > $(NFILE)
422778c7b1cSBill Paul	$(CAT) $(PASSWD) | \
423778c7b1cSBill Paul	$(AWK) -F: '{ if ($$1 != "+") print $$3"\t"$$0 }' $^ \
424b2264be8SBill Paul		| $(DBLOAD) -i $(PASSWD) -o $(YPMAPDIR)/$@ - $(TMP)
425b2264be8SBill Paul	@$(MV) $(TMP) $@
426b2264be8SBill Paul	@$(DBLOAD) -c
427778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
428778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
429778c7b1cSBill Paul	@$(MAKE) -f ../Makefile netid
430778c7b1cSBill Paul
431778c7b1cSBill Paul
432778c7b1cSBill Paulgroup.byname: $(GROUP)
433778c7b1cSBill Paul	@echo "Updating $@..."
434b2264be8SBill Paul	@echo $@.$$$$ > $(NFILE)
435778c7b1cSBill Paul	$(CAT) $(GROUP) | \
436778c7b1cSBill Paul	$(AWK) -F: '{ if ($$1 != "+") print $$1"\t"$$0 }' $^ \
437b2264be8SBill Paul		| $(DBLOAD) -i $(GROUP) -o $(YPMAPDIR)/$@ - $(TMP)
438b2264be8SBill Paul	@$(MV) $(TMP) $@
439b2264be8SBill Paul	@$(DBLOAD) -c
440778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
441778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
442778c7b1cSBill Paul
443778c7b1cSBill Paul
444778c7b1cSBill Paulgroup.bygid: $(GROUP)
445778c7b1cSBill Paul	@echo "Updating $@..."
446b2264be8SBill Paul	@echo $@.$$$$ > $(NFILE)
447778c7b1cSBill Paul	$(CAT) $(GROUP) | \
448778c7b1cSBill Paul	$(AWK) -F: '{ if ($$1 != "+") print $$3"\t"$$0 }' $^ \
449b2264be8SBill Paul		| $(DBLOAD) -i $(GROUP) -o $(YPMAPDIR)/$@ - $(TMP)
450b2264be8SBill Paul	@$(MV) $(TMP) $@
451b2264be8SBill Paul	@$(DBLOAD) -c
452778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
453778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
454778c7b1cSBill Paul	@$(MAKE) -f ../Makefile netid
455778c7b1cSBill Paul
456778c7b1cSBill Paul
457778c7b1cSBill Paulnetid.byname: $(GROUP) $(PASSWD)
458778c7b1cSBill Paul	@echo "Updating $@..."
459b2264be8SBill Paul	@echo $@.$$$$ > $(NFILE)
460778c7b1cSBill Paul	@$(MKNETID) $(PASSWD) $(GROUP) `basename \`pwd\`` \
461b2264be8SBill Paul		| $(DBLOAD) -o $(YPMAPDIR)/$@ - $(TMP)
462b2264be8SBill Paul	@$(MV) $(TMP) $@
463b2264be8SBill Paul	@$(DBLOAD) -c
464778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
465778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
466778c7b1cSBill Paul
467778c7b1cSBill Paul
468778c7b1cSBill Paulmaster.passwd.byname: $(MASTER)
469778c7b1cSBill Paul	@echo "Updating $@..."
470b2264be8SBill Paul	@echo $@.$$$$ > $(NFILE)
471778c7b1cSBill Paul	$(CAT) $(MASTER) | \
472778c7b1cSBill Paul	$(AWK) -F: '{ if ($$1 != "+") print $$1"\t"$$0 }' $^ \
473b2264be8SBill Paul		| $(DBLOAD) -i $(MASTER) -o $(YPMAPDIR)/$@ - $(TMP)
474b2264be8SBill Paul	@$(MV) $(TMP) $@
475b2264be8SBill Paul	@$(DBLOAD) -c
476778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
477778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
478778c7b1cSBill Paul
479778c7b1cSBill Paul
480778c7b1cSBill Paulmaster.passwd.byuid: $(MASTER)
481778c7b1cSBill Paul	@echo "Updating $@..."
482b2264be8SBill Paul	@echo $@.$$$$ > $(NFILE)
483778c7b1cSBill Paul	$(CAT) $(MASTER) | \
484778c7b1cSBill Paul	$(AWK) -F: '{ if ($$1 != "+") print $$3"\t"$$0 }' $^ \
485b2264be8SBill Paul		| $(DBLOAD) -i $(MASTER) -o $(YPMAPDIR)/$@ - $(TMP)
486b2264be8SBill Paul	@$(MV) $(TMP) $@
487b2264be8SBill Paul	@$(DBLOAD) -c
488778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
489778c7b1cSBill Paul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
490