xref: /freebsd/usr.sbin/ypserv/Makefile.yp (revision ce4946daa5ce852d28008dac492029500ab2ee95)
1#
2# Makefile for the NIS databases
3#
4# $FreeBSD$
5#
6# This Makefile should only be run on the NIS master server of a domain.
7# All updated maps will be pushed to all NIS slave servers listed in the
8# /var/yp/ypservers file. Please make sure that the hostnames of all
9# NIS servers in your domain are listed in /var/yp/ypservers.
10#
11# This Makefile can be modified to support more NIS maps if desired.
12#
13
14# If this machine is an NIS master, comment out this next line so
15# that changes to the NIS maps can be propagated to the slave servers.
16# (By default we assume that we are only serving a small domain with
17# only one server.)
18#
19NOPUSH = "True"
20
21# If you want to use a FreeBSD NIS server to serve non-FreeBSD clients
22# (i.e. clients who expect the password field in the passwd maps to be
23# valid) then uncomment this line. This will cause $YPDIR/passwd to
24# be generated with valid password fields. This is insecure: FreeBSD
25# normally only serves the master.passwd maps (which have real encrypted
26# passwords in them) to the superuser on other FreeBSD machines, but
27# non-FreeBSD clients (e.g. SunOS, Solaris (without NIS+), IRIX, HP-UX,
28# etc...) will only work properly in 'unsecure' mode.
29#
30#UNSECURE = "True"
31
32# The following line encodes the YP_INTERDOMAIN key into the hosts.byname
33# and hosts.byaddr maps so that ypserv(8) will do DNS lookups to resolve
34# hosts not in the current domain. Commenting this line out will disable
35# the DNS lookups.
36B=-b
37
38# Normally, the master.passwd.* maps are guarded against access from
39# non-privileged users. By commenting out the following line, the YP_SECURE
40# key will be removed from these maps, allowing anyone to access them.
41S=-s
42
43# These are commands which this Makefile needs to properly rebuild the
44# NIS databases. Don't change these unless you have a good reason. Also
45# be sure not to place an @ in front of /usr/bin/awk: it isn't necessary
46# and it'll break everything in sight.
47#
48AWK = /usr/bin/awk
49RM  = @/bin/rm -f
50MV  = @/bin/mv -f
51RMV  = /bin/mv -f
52RCAT = /bin/cat
53CAT = @$(RCAT)
54
55MKDB = /usr/sbin/yp_mkdb
56DBLOAD = $(MKDB) -m `hostname`
57MKNETID = /usr/libexec/mknetid
58NEWALIASES = /usr/bin/newaliases
59YPPUSH = /usr/sbin/yppush
60.if !defined(UPDATE_DOMAIN)
61DOMAIN = `/bin/domainname`
62.else
63DOMAIN = $(UPDATE_DOMAIN)
64.endif
65REVNETGROUP = /usr/libexec/revnetgroup
66TMP = `echo $@.$$$$`
67
68# It is advisable to create a separate directory to contain the
69# source files used to generate your NIS maps. If you intend to
70# support multiple domains, something like /src/dir/$DOMAIN
71# would work well.
72YPSRCDIR = /etc
73.if !defined(YP_DIR)
74YPDIR = /var/yp
75.else
76YPDIR = $(YP_DIR)
77.endif
78YPMAPDIR = $(YPDIR)/$(DOMAIN)
79
80# These are the files from which the NIS databases are built. You may edit
81# these to taste in the event that you wish to keep your NIS source files
82# separate from your NIS server's actual configuration files. Note that the
83# NIS passwd and master.passwd files are stored in /var/yp: the server's
84# real password database is not used by default. However, you may use
85# the real /etc/passwd and /etc/master.passwd files by:
86#
87#
88# - invoking yppasswdd with `-t /etc/master.passwd' (yppasswdd will do a
89#   'pwd_mkdb' as needed if /etc/master.passwd is thus specified).
90# - Specifying the location of the master.passwd file using the
91#   MASTER_PASSWD variable, i.e.:
92#
93#   # make MASTER_PASSWD=/path/to/some/other/master.passwd
94#
95# - (optionally): editing this Makefile to change the default location.
96#
97# To add a user, edit $(YPDIR)/master.passwd and type 'make'. The raw
98# passwd file will be generated from the master.passwd file automagically.
99#
100ETHERS    = $(YPSRCDIR)/ethers	   # ethernet addresses (for rarpd)
101BOOTPARAMS= $(YPSRCDIR)/bootparams # for booting Sun boxes (bootparamd)
102HOSTS     = $(YPSRCDIR)/hosts
103NETWORKS  = $(YPSRCDIR)/networks
104PROTOCOLS = $(YPSRCDIR)/protocols
105RPC 	  = $(YPSRCDIR)/rpc
106SERVICES  = $(YPSRCDIR)/services
107GROUP     = $(YPSRCDIR)/group
108ALIASES   = $(YPSRCDIR)/aliases
109NETGROUP  = $(YPDIR)/netgroup
110PASSWD    = $(YPDIR)/passwd
111.if !defined(MASTER_PASSWD)
112MASTER    = $(YPDIR)/master.passwd
113.else
114MASTER	  = $(MASTER_PASSWD)
115.endif
116YPSERVERS = $(YPDIR)/ypservers	# List of all NIS servers for a domain
117PUBLICKEY = $(YPSRCDIR)/publickey
118NETID     = $(YPSRCDIR)/netid
119AMDHOST   = $(YPSRCDIR)/amd.host
120
121# List of maps that are always built.
122# If you want to omit some of them, feel free to comment
123# them out from this list.
124TARGETS= servers hosts networks protocols rpc services group
125#TARGETS+= aliases
126
127# Sanity checks: filter out targets we can't build
128# Note that we don't build the ethers or boorparams maps by default
129# since /etc/ethers and /etc/bootparams are not likely to be present
130# on all systems.
131.if exists($(ETHERS))
132TARGETS+= ethers
133.else
134ETHERS= /dev/null
135.endif
136
137.if exists($(BOOTPARAMS))
138TARGETS+= bootparams
139.else
140BOOTPARAMS= /dev/null
141.endif
142
143.if exists($(NETGROUP))
144TARGETS+= netgrp
145.else
146NETGROUP= /dev/null
147.endif
148
149.if exists($(MASTER))
150TARGETS+= passwd master.passwd netid
151.else
152MASTER= /dev/null
153TARGETS+= nopass
154.endif
155
156.if exists($(PUBLICKEY))
157TARGETS+= publickey
158.else
159PUBLICKEY= /dev/null
160.endif
161
162.if exists($(AMDHOST))
163TARGETS+= amd.host
164.else
165AMDHOST= /dev/null
166.endif
167
168target:
169	@if [ ! -d $(DOMAIN) ]; then mkdir $(DOMAIN); fi; \
170	cd $(DOMAIN) ; echo "NIS Map update started on `date` for domain $(DOMAIN)" ; \
171	make -f ../Makefile all; echo "NIS Map update completed."
172
173all: $(TARGETS)
174
175ethers:	   ethers.byname ethers.byaddr
176bootparam: bootparams
177hosts:	   hosts.byname hosts.byaddr
178networks:  networks.byaddr networks.byname
179protocols: protocols.bynumber protocols.byname
180rpc:	   rpc.byname rpc.bynumber
181services:  services.byname
182passwd:    passwd.byname passwd.byuid
183group:     group.byname group.bygid
184netgrp:    netgroup
185netid:	   netid.byname
186servers:   ypservers
187publickey: publickey.byname
188aliases:   mail.aliases
189
190master.passwd:	master.passwd.byname master.passwd.byuid
191
192#
193# This is a special target used only when doing in-place updates with
194# rpc.yppasswdd. In this case, the maps will be updated by the rpc.yppasswdd
195# server and won't need to be remade. They will have to be pushed to the
196# slaves however. Calling this target implicitly insures that this will
197# happen.
198#
199pushpw:
200	@$(DBLOAD) -c
201	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) master.passwd.byname ; fi
202	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) master.passwd.byuid ; fi
203	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) passwd.byname ; fi
204	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) passwd.byuid ; fi
205
206pushmap:
207	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $(PUSHMAP) ; fi
208
209nopass:
210	@echo ""
211	@echo "                ********WARNING********"
212	@echo "  Couldn't find the master.passwd source file. This file"
213	@echo "  is needed to generate the master.passwd and passwd maps."
214	@echo "  The default location is /var/yp/master.passwd. You should"
215	@echo "  edit /var/yp/Makefile and set the MASTER variable to point"
216	@echo "  to the source file you wish to use for building the passwd"
217	@echo "  maps, or else invoke make(1) in the following manner:"
218	@echo ""
219	@echo "        make MASTER_PASSWD=/path/to/master.passwd"
220	@echo ""
221
222mail.aliases: $(ALIASES)
223	@echo "Updating $@..."
224	@$(NEWALIASES) -oA$(ALIASES)
225	@$(MKDB) -u $(ALIASES).db \
226		| $(DBLOAD) -i $(ALIASES) -o $(YPMAPDIR)/$@ - $(TMP); \
227		$(RMV) $(TMP) $@
228	@$(DBLOAD) -c
229	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
230	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
231
232
233ypservers: $(YPSERVERS)
234	@echo "Updating $@..."
235	$(CAT) $(YPSERVERS) | \
236	$(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*") print $$0"\t"$$0 }' $^ \
237		| $(DBLOAD) -i $(YPSERVERS) -o $(YPMAPDIR)/$@ - $(TMP); \
238		$(RMV) $(TMP) $@
239	@$(DBLOAD) -c
240	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
241	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
242
243
244ethers.byname: $(ETHERS)
245	@echo "Updating $@..."
246.if ${ETHERS} == "/dev/null"
247	@echo "Ethers source file not found -- skipping"
248.else
249	$(CAT) $(ETHERS) | \
250	$(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
251		print $$2"\t"$$0 }' $^ | $(DBLOAD) -i $(ETHERS) \
252		-o $(YPMAPDIR)/$@ - $(TMP); $(RMV) $(TMP) $@
253	@$(DBLOAD) -c
254	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
255	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
256.endif
257
258ethers.byaddr: $(ETHERS)
259	@echo "Updating $@..."
260.if ${ETHERS} == "/dev/null"
261	@echo "Ethers source file not found -- skipping"
262.else
263	$(CAT) $(ETHERS) | \
264	$(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
265		print $$1"\t"$$0 }' $^ | $(DBLOAD) -i $(ETHERS) \
266		-o $(YPMAPDIR)/$@ - $(TMP); $(RMV) $(TMP) $@
267	@$(DBLOAD) -c
268	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
269	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
270.endif
271
272
273bootparams: $(BOOTPARAMS)
274	@echo "Updating $@..."
275.if ${BOOTPARAMS} == "/dev/null"
276	@echo "Bootparams source file not found -- skipping"
277.else
278	$(CAT) $(BOOTPARAMS) | \
279	$(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
280		print $$0 }' $^ | $(DBLOAD) -i $(BOOTPARAMS) \
281		-o $(YPMAPDIR)/$@ - $(TMP); $(RMV) $(TMP) $@
282	@$(DBLOAD) -c
283	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
284	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
285.endif
286
287
288netgroup: $(NETGROUP) netgroup.byhost netgroup.byuser
289	@echo "Updating $@..."
290.if ${NETGROUP} == "/dev/null"
291	@echo "Netgroup source file not found -- skipping"
292.else
293	$(CAT) $(NETGROUP) | \
294	$(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
295		print $$0 }' $^ | $(DBLOAD) -i $(NETGROUP) \
296		-o $(YPMAPDIR)/$@ - $(TMP); $(RMV) $(TMP) $@
297	@$(DBLOAD) -c
298	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
299	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
300	@$(MAKE) -f ../Makefile netid
301.endif
302
303
304netgroup.byhost: $(NETGROUP)
305	@echo "Updating $@..."
306.if ${NETGROUP} == "/dev/null"
307	@echo "Netgroup source file not found -- skipping"
308.else
309	$(CAT) $(NETGROUP) | $(REVNETGROUP) -h -f $(NETGROUP) | \
310	$(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
311		print $$0 }' $^ | $(DBLOAD) -i $(NETGROUP) \
312		-o $(YPMAPDIR)/$@ - $(TMP); $(RMV) $(TMP) $@
313	@$(DBLOAD) -c
314	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
315	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
316.endif
317
318
319netgroup.byuser: $(NETGROUP)
320	@echo "Updating $@..."
321.if ${NETGROUP} == "/dev/null"
322	@echo "Netgroup source file not found -- skipping"
323.else
324	$(CAT) $(NETGROUP) | $(REVNETGROUP) -u -f $(NETGROUP) | \
325	$(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
326		print $$0 }' $^ | $(DBLOAD) -i $(NETGROUP) \
327		-o $(YPMAPDIR)/$@ - $(TMP); $(RMV) $(TMP) $@
328	@$(DBLOAD) -c
329	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
330	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
331.endif
332
333
334hosts.byname: $(HOSTS)
335	@echo "Updating $@..."
336	$(CAT) $(HOSTS) | \
337	$(AWK) '/^[0-9]/ { for (n=2; n<=NF && $$n !~ "^#.*"; n++) \
338		print $$n"\t"$$0 }' $^ | $(DBLOAD) ${B} -i $(HOSTS)  \
339		-o $(YPMAPDIR)/$@ - $(TMP); $(RMV) $(TMP) $@
340	@$(DBLOAD) -c
341	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
342	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
343	@$(MAKE) -f ../Makefile netid
344
345
346hosts.byaddr: $(HOSTS)
347	@echo "Updating $@..."
348	$(CAT) $(HOSTS) | \
349	$(AWK) '$$1 !~ "^#.*" { print $$1"\t"$$0 }' $^ \
350		| $(DBLOAD) ${B} -i $(HOSTS) -o $(YPMAPDIR)/$@ - $(TMP); \
351		$(RMV) $(TMP) $@
352	@$(DBLOAD) -c
353	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
354	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
355	@$(MAKE) -f ../Makefile netid
356
357
358networks.byname: $(NETWORKS)
359	@echo "Updating $@..."
360	$(CAT) $(NETWORKS) | \
361	$(AWK) \
362	   '$$1 !~ "^#.*"  { print $$1"\t"$$0; \
363			  for (n=3; n<=NF && $$n !~ "^#.*"; n++) \
364			      print $$n"\t"$$0 \
365		}' $^ | $(DBLOAD) -i $(NETWORKS) -o $(YPMAPDIR)/$@ - $(TMP); \
366		$(RMV) $(TMP) $@
367	@$(DBLOAD) -c
368	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
369	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
370
371
372networks.byaddr: $(NETWORKS)
373	@echo "Updating $@..."
374	$(CAT) $(NETWORKS) | \
375	$(AWK) '$$1 !~ "^#.*" { print $$2"\t"$$0 }' $^ \
376		| $(DBLOAD) -i $(NETWORKS) -o $(YPMAPDIR)/$@ - $(TMP); \
377		$(RMV) $(TMP) $@
378	@$(DBLOAD) -c
379	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
380	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
381
382
383protocols.byname: $(PROTOCOLS)
384	@echo "Updating $@..."
385	$(CAT) $(PROTOCOLS) | \
386	$(AWK) \
387	   '$$1 !~ "^#.*"	{ print $$1"\t"$$0; \
388			  for (n=3; n<=NF && $$n !~ "^#.*"; n++) \
389			      print $$n"\t"$$0 \
390			}' $^ | $(DBLOAD) -i $(PROTOCOLS) \
391		-o $(YPMAPDIR)/$@ - $(TMP); $(RMV) $(TMP) $@
392	@$(DBLOAD) -c
393	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
394	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
395
396
397protocols.bynumber: $(PROTOCOLS)
398	@echo "Updating $@..."
399	$(CAT) $(PROTOCOLS) | \
400	$(AWK) '$$1 !~ "^#.*" { print $$2"\t"$$0 }' $^ \
401		| $(DBLOAD) -i $(PROTOCOLS) -o $(YPMAPDIR)/$@ - $(TMP); \
402		$(RMV) $(TMP) $@
403	@$(DBLOAD) -c
404	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
405	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
406
407
408rpc.byname: $(RPC)
409	@echo "Updating $@..."
410	$(CAT) $(RPC) | \
411	$(AWK) \
412	   '$$1 !~ "^#.*"  { print $$1"\t"$$0; \
413			  for (n=3; n<=NF && $$n !~ "^#.*"; n++) \
414			      print $$n"\t"$$0 \
415		}' $^ | $(DBLOAD) -i $(RPC) -o $(YPMAPDIR)/$@ - $(TMP); \
416		$(RMV) $(TMP) $@
417	@$(DBLOAD) -c
418	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
419	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
420
421
422rpc.bynumber: $(RPC)
423	@echo "Updating $@..."
424	$(CAT) $(RPC) | \
425	$(AWK) '$$1 !~ "^#.*" { print $$2"\t"$$0 }' $^ \
426		| $(DBLOAD)  -i $(RPC) -o $(YPMAPDIR)/$@ - $(TMP); \
427		$(RMV) $(TMP) $@
428	@$(DBLOAD) -c
429	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
430	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
431
432
433services.byname: $(SERVICES)
434	@echo "Updating $@..."
435	$(CAT) $(SERVICES) | \
436	$(AWK) \
437	   '$$1 !~ "^#.*"  { for (n=1; n<=NF && $$n !~ "^#.*"; n++) { \
438				if (split($$2, t, "/")) { \
439					printf("%s/%s", $$n, t[2]) }; \
440					print "\t"$$0;	\
441					if (n == 1) n = 2; \
442			   } ; print $$2"\t"$$0 ; \
443		}' $^ | $(DBLOAD) -i $(SERVICES) -o $(YPMAPDIR)/$@ - $(TMP); \
444		$(RMV) $(TMP) $@
445	@$(DBLOAD) -c
446	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
447	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
448
449
450publickey.byname: $(PUBLICKEY)
451	@echo "Updating $@..."
452.if ${PUBLICKEY} == "/dev/null"
453	@echo "Publickey source file not found -- skipping"
454.else
455	$(CAT) $(PUBLICKEY) | \
456	$(AWK) '$$1 !~ "^#.*" { print $$1"\t"$$2 }' $^ \
457		| $(DBLOAD)  -i $(PUBLICKEY) -o $(YPMAPDIR)/$@ - $(TMP); \
458		$(RMV) $(TMP) $@
459	@$(DBLOAD) -c
460	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
461	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
462.endif
463
464
465$(PASSWD): $(MASTER)
466	@echo "Creating new $@ file from $(MASTER)..."
467	@if [ ! $(UNSECURE) ]; then \
468	$(RCAT) $(MASTER) | \
469	$(AWK) -F: '{if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
470		print $$1":*:"$$3":"$$4":"$$8":"$$9":"$$10}' $^ \
471		> $(PASSWD) ; \
472	else $(RCAT) $(MASTER) | \
473	$(AWK) -F: '{if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
474		print $$1":"$$2":"$$3":"$$4":"$$8":"$$9":"$$10}' $^ \
475		> $(PASSWD) ; fi
476
477
478passwd.byname: $(PASSWD)
479	@echo "Updating $@..."
480	$(CAT) $(PASSWD) | \
481	$(AWK) -F: '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
482		print $$1"\t"$$0 }' $^ \
483		| $(DBLOAD) -f -i $(PASSWD) -o $(YPMAPDIR)/$@ - $(TMP); \
484		$(RMV) $(TMP) $@
485	@$(DBLOAD) -c
486	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
487	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
488
489
490passwd.byuid: $(PASSWD)
491	@echo "Updating $@..."
492	$(CAT) $(PASSWD) | \
493	$(AWK) -F: '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
494		print $$3"\t"$$0 }' $^ \
495		| $(DBLOAD) -f -i $(PASSWD) -o $(YPMAPDIR)/$@ - $(TMP); \
496		$(RMV) $(TMP) $@
497	@$(DBLOAD) -c
498	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
499	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
500	@$(MAKE) -f ../Makefile netid
501
502
503group.byname: $(GROUP)
504	@echo "Updating $@..."
505	$(CAT) $(GROUP) | \
506	$(AWK) -F: '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
507		print $$1"\t"$$0 }' $^ \
508		| $(DBLOAD) -f -i $(GROUP) -o $(YPMAPDIR)/$@ - $(TMP); \
509		$(RMV) $(TMP) $@
510	@$(DBLOAD) -c
511	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
512	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
513
514
515group.bygid: $(GROUP)
516	@echo "Updating $@..."
517	$(CAT) $(GROUP) | \
518	$(AWK) -F: '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
519		print $$3"\t"$$0 }' $^ \
520		| $(DBLOAD) -f -i $(GROUP) -o $(YPMAPDIR)/$@ - $(TMP); \
521		$(RMV) $(TMP) $@
522	@$(DBLOAD) -c
523	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
524	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
525	@$(MAKE) -f ../Makefile netid
526
527
528netid.byname: $(GROUP) $(PASSWD)
529	@echo "Updating $@..."
530	@$(MKNETID) -q -p $(PASSWD) -g $(GROUP) -h $(HOSTS) -n $(NETID) \
531		-d $(DOMAIN) | $(DBLOAD) -o $(YPMAPDIR)/$@ - $(TMP); \
532		$(RMV) $(TMP) $@
533	@$(DBLOAD) -c
534	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
535	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
536
537
538master.passwd.byname: $(MASTER)
539	@echo "Updating $@..."
540.if ${MASTER} == "/dev/null"
541	@echo "Master.passwd source file not found -- skipping"
542.else
543	$(CAT) $(MASTER) | \
544	$(AWK) -F: '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
545		print $$1"\t"$$0 }' $^ \
546		| $(DBLOAD) ${S} -f -i $(MASTER) -o $(YPMAPDIR)/$@ - $(TMP); \
547		$(RMV) $(TMP) $@
548	@$(DBLOAD) -c
549	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
550	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
551.endif
552
553
554master.passwd.byuid: $(MASTER)
555	@echo "Updating $@..."
556.if ${MASTER} == "/dev/null"
557	@echo "Master.passwd source file not found -- skipping"
558.else
559	$(CAT) $(MASTER) | \
560	$(AWK) -F: '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
561		print $$3"\t"$$0 }' $^ \
562		| $(DBLOAD) ${S} -f -i $(MASTER) -o $(YPMAPDIR)/$@ - $(TMP); \
563		$(RMV) $(TMP) $@
564	@$(DBLOAD) -c
565	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
566	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
567.endif
568
569
570amd.host: $(AMDHOST)
571	@echo "Updating $@..."
572	$(CAT) $(AMDHOST) | \
573	$(AWK) '$$1 !~ "^#.*"  { \
574	  for (i = 1; i <= NF; i++) \
575	  if (i == NF) { \
576	    if (substr($$i, length($$i), 1) == "\\") \
577	      printf("%s", substr($$i, 1, length($$i) - 1)); \
578	    else \
579	      printf("%s\n", $$i); \
580	  } \
581	  else \
582	    printf("%s ", $$i); \
583	}' | \
584	$(DBLOAD) -i $(AMDHOST) -o $(YPMAPDIR)/$@ - $(TMP); \
585		$(RMV) $(TMP) $@
586	@$(DBLOAD) -c
587	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
588	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
589
590