112891Swpaul#
212891Swpaul# Makefile for the NIS databases
312891Swpaul#
450479Speter# $FreeBSD$
512891Swpaul#
612891Swpaul# This Makefile should only be run on the NIS master server of a domain.
712891Swpaul# All updated maps will be pushed to all NIS slave servers listed in the
812891Swpaul# /var/yp/ypservers file. Please make sure that the hostnames of all
912891Swpaul# NIS servers in your domain are listed in /var/yp/ypservers.
1012891Swpaul#
1112891Swpaul# This Makefile can be modified to support more NIS maps if desired.
1212891Swpaul#
1312891Swpaul
14194968Sbrian# If this machine is an NIS master, reset this variable (NOPUSH=)
15194968Sbrian# in Makefile.local so that changes to the NIS maps can be propagated to
16194968Sbrian# the slave servers.  (By default we assume that we are only serving a
17194968Sbrian# small domain with only one server.)
1812891Swpaul#
1912891SwpaulNOPUSH = "True"
2012891Swpaul
21194968Sbrian# If this machine does not wish to generate a linux-style shadow map
22194968Sbrian# from the master.passwd file, reset this variable (SHADOW=) in
23194968Sbrian# Makefile.local.
24194968SbrianSHADOW = "True"
25194968Sbrian
2612891Swpaul# If you want to use a FreeBSD NIS server to serve non-FreeBSD clients
2712891Swpaul# (i.e. clients who expect the password field in the passwd maps to be
28194968Sbrian# valid) then set this variable (UNSECURE="True") in Makefile.local.
29194968Sbrian# This will cause $YPDIR/passwd to be generated with valid password
30194968Sbrian# fields.  This is insecure: FreeBSD normally only serves the
31194968Sbrian# master.passwd and shadow maps (which have real encrypted passwords
32194968Sbrian# in them) to the superuser on other FreeBSD machines, but non-FreeBSD
33194968Sbrian# clients (e.g. SunOS, Solaris (without NIS+), IRIX, HP-UX, etc...)
34194968Sbrian# will only work properly in 'unsecure' mode.
3512891Swpaul# 
3612891Swpaul#UNSECURE = "True"
3712891Swpaul
3819161Swpaul# The following line encodes the YP_INTERDOMAIN key into the hosts.byname
3919161Swpaul# and hosts.byaddr maps so that ypserv(8) will do DNS lookups to resolve
40194968Sbrian# hosts not in the current domain.  Resetting this variable in
41194968Sbrian# Makefile.local (B=) will disable the DNS lookups.
4219161SwpaulB=-b
4319161Swpaul
44194968Sbrian# Normally, the master.passwd.* and shadow.* maps are guarded against access
45194968Sbrian# from non-privileged users.  By resetting S in Makefile.local (S=), the
46194968Sbrian# YP_SECURE key will be removed from these maps, allowing anyone to access
47194968Sbrian# them.
4819161SwpaulS=-s
4919161Swpaul
5012891Swpaul# These are commands which this Makefile needs to properly rebuild the
5112891Swpaul# NIS databases. Don't change these unless you have a good reason. Also
5212891Swpaul# be sure not to place an @ in front of /usr/bin/awk: it isn't necessary
5312891Swpaul# and it'll break everything in sight.
5412891Swpaul#
5512891SwpaulAWK = /usr/bin/awk
5612891SwpaulRM  = @/bin/rm -f
5715426SwpaulMV  = @/bin/mv -f
5833100SwpaulRMV  = /bin/mv -f
5912891Swpaul
6017220SadamMKDB = /usr/sbin/yp_mkdb
6117220SadamDBLOAD = $(MKDB) -m `hostname`
6212891SwpaulMKNETID = /usr/libexec/mknetid
6315426SwpaulNEWALIASES = /usr/bin/newaliases
6413398SwpaulYPPUSH = /usr/sbin/yppush
6513896Swpaul.if !defined(UPDATE_DOMAIN)
6612891SwpaulDOMAIN = `/bin/domainname`
6713896Swpaul.else
6813896SwpaulDOMAIN = $(UPDATE_DOMAIN)
6913896Swpaul.endif
7012891SwpaulREVNETGROUP = /usr/libexec/revnetgroup
7133100SwpaulTMP = `echo $@.$$$$`
7212891Swpaul
7317220Sadam# It is advisable to create a separate directory to contain the
7417220Sadam# source files used to generate your NIS maps. If you intend to
7515426Swpaul# support multiple domains, something like /src/dir/$DOMAIN
7615426Swpaul# would work well.
7712891SwpaulYPSRCDIR = /etc
7831110Swpaul.if !defined(YP_DIR)
7912891SwpaulYPDIR = /var/yp
8031110Swpaul.else
8131110SwpaulYPDIR = $(YP_DIR)
8231110Swpaul.endif
8312891SwpaulYPMAPDIR = $(YPDIR)/$(DOMAIN)
8412891Swpaul
8512891Swpaul# These are the files from which the NIS databases are built. You may edit
8612891Swpaul# these to taste in the event that you wish to keep your NIS source files
8772091Sasmodai# separate from your NIS server's actual configuration files. Note that the
8812891Swpaul# NIS passwd and master.passwd files are stored in /var/yp: the server's
8912891Swpaul# real password database is not used by default. However, you may use
9012891Swpaul# the real /etc/passwd and /etc/master.passwd files by:
9112891Swpaul#
9212891Swpaul#
9337819Sphk# - invoking yppasswdd with `-t /etc/master.passwd' (yppasswdd will do a
9437819Sphk#   'pwd_mkdb' as needed if /etc/master.passwd is thus specified).
9512891Swpaul# - Specifying the location of the master.passwd file using the
9612891Swpaul#   MASTER_PASSWD variable, i.e.:
9712891Swpaul#
9812891Swpaul#   # make MASTER_PASSWD=/path/to/some/other/master.passwd
9912891Swpaul#
10012891Swpaul# - (optionally): editing this Makefile to change the default location.
10112891Swpaul#
10212891Swpaul# To add a user, edit $(YPDIR)/master.passwd and type 'make'. The raw
10312891Swpaul# passwd file will be generated from the master.passwd file automagically.
10412891Swpaul#
10512891SwpaulETHERS    = $(YPSRCDIR)/ethers	   # ethernet addresses (for rarpd)
10612891SwpaulBOOTPARAMS= $(YPSRCDIR)/bootparams # for booting Sun boxes (bootparamd)
10712891SwpaulHOSTS     = $(YPSRCDIR)/hosts
108145801SumeIPNODES   = $(YPDIR)/ipnodes
10912891SwpaulNETWORKS  = $(YPSRCDIR)/networks
11012891SwpaulPROTOCOLS = $(YPSRCDIR)/protocols
11112891SwpaulRPC 	  = $(YPSRCDIR)/rpc
11212891SwpaulSERVICES  = $(YPSRCDIR)/services
113112458SrobertSHELLS    = $(YPSRCDIR)/shells
11412891SwpaulGROUP     = $(YPSRCDIR)/group
11576621SgshapiroALIASES   = $(YPSRCDIR)/mail/aliases
11615426SwpaulNETGROUP  = $(YPDIR)/netgroup
11712891SwpaulPASSWD    = $(YPDIR)/passwd
11812891Swpaul.if !defined(MASTER_PASSWD)
11912891SwpaulMASTER    = $(YPDIR)/master.passwd
12012891Swpaul.else
12112891SwpaulMASTER	  = $(MASTER_PASSWD)
12212891Swpaul.endif
12312891SwpaulYPSERVERS = $(YPDIR)/ypservers	# List of all NIS servers for a domain
12412891SwpaulPUBLICKEY = $(YPSRCDIR)/publickey
12516732SwpaulNETID     = $(YPSRCDIR)/netid
12690320SmarkmAMDHOST   = $(YPSRCDIR)/amd.map
12712891Swpaul
128194968Sbriantarget: 
129194968Sbrian	@if [ ! -d $(DOMAIN) ]; then mkdir $(DOMAIN); fi; \
130194968Sbrian	cd $(DOMAIN) ; echo "NIS Map update started on `date` for domain $(DOMAIN)" ; \
131194968Sbrian	make -f ../Makefile all; echo "NIS Map update completed."
132194968Sbrian
133194968Sbrian# Read overrides.  Note, the current directory will be /var/yp/<domain>
134194968Sbrian# when 'all' is built.
135194968Sbrian.if exists(${YPDIR}/Makefile.local)
136194968Sbrian.include "${YPDIR}/Makefile.local"
137194968Sbrian.endif
138194968Sbrian
13931110Swpaul# List of maps that are always built.
14031110Swpaul# If you want to omit some of them, feel free to comment
14131110Swpaul# them out from this list.
142112458SrobertTARGETS= servers hosts networks protocols rpc services shells group
14331110Swpaul#TARGETS+= aliases
14431110Swpaul
14531110Swpaul# Sanity checks: filter out targets we can't build
14631110Swpaul# Note that we don't build the ethers or boorparams maps by default
14731110Swpaul# since /etc/ethers and /etc/bootparams are not likely to be present
14831110Swpaul# on all systems.
14931110Swpaul.if exists($(ETHERS))
15031110SwpaulTARGETS+= ethers
15131110Swpaul.else
15231110SwpaulETHERS= /dev/null
15331110Swpaul.endif
15431110Swpaul
15531110Swpaul.if exists($(BOOTPARAMS))
15631110SwpaulTARGETS+= bootparams
15731110Swpaul.else
15831110SwpaulBOOTPARAMS= /dev/null
15931110Swpaul.endif
16031110Swpaul
16131110Swpaul.if exists($(NETGROUP))
16231110SwpaulTARGETS+= netgrp
16331110Swpaul.else
16431110SwpaulNETGROUP= /dev/null
16531110Swpaul.endif
16631110Swpaul
16731110Swpaul.if exists($(MASTER))
16831110SwpaulTARGETS+= passwd master.passwd netid
169194968Sbrian.if ${SHADOW} == "\"True\""
170194968SbrianTARGETS+= shadow
171194968Sbrian.endif
17231110Swpaul.else
17331110SwpaulMASTER= /dev/null
17431110SwpaulTARGETS+= nopass
17531110Swpaul.endif
17631110Swpaul
17731110Swpaul.if exists($(PUBLICKEY))
17831110SwpaulTARGETS+= publickey
17931110Swpaul.else
18031110SwpaulPUBLICKEY= /dev/null
18131110Swpaul.endif
18231110Swpaul
18331110Swpaul.if exists($(AMDHOST))
18490320SmarkmTARGETS+= amd.map
18531110Swpaul.else
18631110SwpaulAMDHOST= /dev/null
18731110Swpaul.endif
18831110Swpaul
189145801Sume.if exists($(IPNODES))
190145801SumeTARGETS+= ipnodes
191145801Sume.else
192145801SumeIPNODES= /dev/null
193145801Sume.endif
194145801Sume
19531110Swpaulall: $(TARGETS)
19612891Swpaul
19712891Swpaulethers:	   ethers.byname ethers.byaddr
19812891Swpaulbootparam: bootparams
19912891Swpaulhosts:	   hosts.byname hosts.byaddr
200145801Sumeipnodes:   ipnodes.byname ipnodes.byaddr
20112891Swpaulnetworks:  networks.byaddr networks.byname
20212891Swpaulprotocols: protocols.bynumber protocols.byname
20312891Swpaulrpc:	   rpc.byname rpc.bynumber
20412891Swpaulservices:  services.byname
20512891Swpaulpasswd:    passwd.byname passwd.byuid
206194968Sbrianshadow:    shadow.byname shadow.byuid
20712891Swpaulgroup:     group.byname group.bygid
20812891Swpaulnetgrp:    netgroup
20912891Swpaulnetid:	   netid.byname
21012891Swpaulservers:   ypservers
21112891Swpaulpublickey: publickey.byname
21215426Swpaulaliases:   mail.aliases
21312891Swpaul
21412891Swpaulmaster.passwd:	master.passwd.byname master.passwd.byuid
21512891Swpaul
21616118Swpaul#
21716118Swpaul# This is a special target used only when doing in-place updates with
21816118Swpaul# rpc.yppasswdd. In this case, the maps will be updated by the rpc.yppasswdd
21916118Swpaul# server and won't need to be remade. They will have to be pushed to the
22016118Swpaul# slaves however. Calling this target implicitly insures that this will
22116118Swpaul# happen.
22216118Swpaul#
22316118Swpaulpushpw:
22416118Swpaul	@$(DBLOAD) -c
22516118Swpaul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) master.passwd.byname ; fi
22616118Swpaul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) master.passwd.byuid ; fi
227194968Sbrian.if ${SHADOW} == "\"True\""
228194968Sbrian	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) shadow.byname ; fi
229194968Sbrian	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) shadow.byuid ; fi
230194968Sbrian.endif
23116118Swpaul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) passwd.byname ; fi
23216118Swpaul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) passwd.byuid ; fi
23316118Swpaul
23431110Swpaulpushmap:
23531110Swpaul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $(PUSHMAP) ; fi
23631110Swpaul
23731110Swpaulnopass:
23831110Swpaul	@echo ""
23931110Swpaul	@echo "                ********WARNING********"
24031110Swpaul	@echo "  Couldn't find the master.passwd source file. This file"
24131110Swpaul	@echo "  is needed to generate the master.passwd and passwd maps."
24231110Swpaul	@echo "  The default location is /var/yp/master.passwd. You should"
24331110Swpaul	@echo "  edit /var/yp/Makefile and set the MASTER variable to point"
24431110Swpaul	@echo "  to the source file you wish to use for building the passwd"
24531110Swpaul	@echo "  maps, or else invoke make(1) in the following manner:"
24648199Sn_hibma	@echo ""
24731110Swpaul	@echo "        make MASTER_PASSWD=/path/to/master.passwd"
24831110Swpaul	@echo ""
24931110Swpaul
25015426Swpaulmail.aliases: $(ALIASES)
25115426Swpaul	@echo "Updating $@..."
25217220Sadam	@$(NEWALIASES) -oA$(ALIASES)
25317481Sadam	@$(MKDB) -u $(ALIASES).db \
25433100Swpaul		| $(DBLOAD) -i $(ALIASES) -o $(YPMAPDIR)/$@ - $(TMP); \
25533100Swpaul		$(RMV) $(TMP) $@
25615426Swpaul	@$(DBLOAD) -c
25716044Swpaul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
25816044Swpaul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
25912891Swpaul
26015426Swpaul
26112891Swpaulypservers: $(YPSERVERS)
26212891Swpaul	@echo "Updating $@..."
263116301Sru	@$(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*") print $$0"\t"$$0 }' \
264116301Sru		$(YPSERVERS) \
26533100Swpaul		| $(DBLOAD) -i $(YPSERVERS) -o $(YPMAPDIR)/$@ - $(TMP); \
26633100Swpaul		$(RMV) $(TMP) $@
26715426Swpaul	@$(DBLOAD) -c
26812891Swpaul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
26912891Swpaul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
27012891Swpaul
27112891Swpaulethers.byname: $(ETHERS)
27212891Swpaul	@echo "Updating $@..."
27331110Swpaul.if ${ETHERS} == "/dev/null"
27431110Swpaul	@echo "Ethers source file not found -- skipping"
27531110Swpaul.else
276116301Sru	@$(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
277116301Sru		print $$2"\t"$$0 }' $(ETHERS) | $(DBLOAD) -i $(ETHERS) \
27833100Swpaul		-o $(YPMAPDIR)/$@ - $(TMP); $(RMV) $(TMP) $@
27915426Swpaul	@$(DBLOAD) -c
28017268Speter	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
28112891Swpaul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
28231110Swpaul.endif
28312891Swpaul
28412891Swpaulethers.byaddr: $(ETHERS)
28512891Swpaul	@echo "Updating $@..."
28631110Swpaul.if ${ETHERS} == "/dev/null"
28731110Swpaul	@echo "Ethers source file not found -- skipping"
28831110Swpaul.else
289116301Sru	@$(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
290116301Sru		print $$1"\t"$$0 }' $(ETHERS) | $(DBLOAD) -i $(ETHERS) \
29133100Swpaul		-o $(YPMAPDIR)/$@ - $(TMP); $(RMV) $(TMP) $@
29215426Swpaul	@$(DBLOAD) -c
29312891Swpaul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
29412891Swpaul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
29531110Swpaul.endif
29612891Swpaul
29712891Swpaul
29812891Swpaulbootparams: $(BOOTPARAMS)
29912891Swpaul	@echo "Updating $@..."
30031110Swpaul.if ${BOOTPARAMS} == "/dev/null"
30131110Swpaul	@echo "Bootparams source file not found -- skipping"
30231110Swpaul.else
303116301Sru	@$(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
304116301Sru		print $$0 }' $(BOOTPARAMS) | $(DBLOAD) -i $(BOOTPARAMS) \
30533100Swpaul		-o $(YPMAPDIR)/$@ - $(TMP); $(RMV) $(TMP) $@
30615426Swpaul	@$(DBLOAD) -c
30712891Swpaul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
30812891Swpaul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
30931110Swpaul.endif
31012891Swpaul
31112891Swpaul
31212891Swpaulnetgroup: $(NETGROUP) netgroup.byhost netgroup.byuser
31312891Swpaul	@echo "Updating $@..."
31431110Swpaul.if ${NETGROUP} == "/dev/null"
31531110Swpaul	@echo "Netgroup source file not found -- skipping"
31631110Swpaul.else
317116301Sru	@$(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
318116301Sru		print $$0 }' $(NETGROUP) | $(DBLOAD) -i $(NETGROUP) \
31933100Swpaul		-o $(YPMAPDIR)/$@ - $(TMP); $(RMV) $(TMP) $@
32015426Swpaul	@$(DBLOAD) -c
32112891Swpaul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
32212891Swpaul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
32331110Swpaul.endif
32412891Swpaul
32512891Swpaul
32612891Swpaulnetgroup.byhost: $(NETGROUP)
32712891Swpaul	@echo "Updating $@..."
32831110Swpaul.if ${NETGROUP} == "/dev/null"
32931110Swpaul	@echo "Netgroup source file not found -- skipping"
33031110Swpaul.else
331116301Sru	@$(REVNETGROUP) -h -f $(NETGROUP) | \
33232775Ssteve	$(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
333116301Sru		print $$0 }' | $(DBLOAD) -i $(NETGROUP) \
33433100Swpaul		-o $(YPMAPDIR)/$@ - $(TMP); $(RMV) $(TMP) $@
33515426Swpaul	@$(DBLOAD) -c
33612891Swpaul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
33712891Swpaul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
33831110Swpaul.endif
33912891Swpaul
34012891Swpaul
34112891Swpaulnetgroup.byuser: $(NETGROUP)
34212891Swpaul	@echo "Updating $@..."
34331110Swpaul.if ${NETGROUP} == "/dev/null"
34431110Swpaul	@echo "Netgroup source file not found -- skipping"
34531110Swpaul.else
346116301Sru	@$(REVNETGROUP) -u -f $(NETGROUP) | \
34732775Ssteve	$(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
348116301Sru		print $$0 }' | $(DBLOAD) -i $(NETGROUP) \
34933100Swpaul		-o $(YPMAPDIR)/$@ - $(TMP); $(RMV) $(TMP) $@
35015426Swpaul	@$(DBLOAD) -c
35112891Swpaul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
35212891Swpaul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
35331110Swpaul.endif
35412891Swpaul
35512891Swpaul
35612891Swpaulhosts.byname: $(HOSTS)
35712891Swpaul	@echo "Updating $@..."
358116301Sru	@$(AWK) '/^[0-9]/ { for (n=2; n<=NF && $$n !~ "^#.*"; n++) \
359116301Sru		print $$n"\t"$$0 }' $(HOSTS) | $(DBLOAD) ${B} -i $(HOSTS)  \
36033100Swpaul		-o $(YPMAPDIR)/$@ - $(TMP); $(RMV) $(TMP) $@
36115426Swpaul	@$(DBLOAD) -c
36212891Swpaul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
36312891Swpaul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
36412891Swpaul
36515426Swpaul
36612891Swpaulhosts.byaddr: $(HOSTS)
36712891Swpaul	@echo "Updating $@..."
368116301Sru	@$(AWK) '$$1 !~ "^#.*" { print $$1"\t"$$0 }' $(HOSTS) \
36933100Swpaul		| $(DBLOAD) ${B} -i $(HOSTS) -o $(YPMAPDIR)/$@ - $(TMP); \
37033100Swpaul		$(RMV) $(TMP) $@
37115426Swpaul	@$(DBLOAD) -c
37212891Swpaul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
37312891Swpaul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
37412891Swpaul
37512891Swpaul
376145801Sumeipnodes.byname: $(IPNODES)
377145801Sume	@echo "Updating $@..."
378145801Sume.if ${IPNODES} == "/dev/null"
379145801Sume	@echo "Ipnodes source file not found -- skipping"
380145801Sume.else
381145801Sume	@$(AWK) '/^[0-9a-fA-F:]/ { for (n=2; n<=NF && $$n !~ "^#.*"; n++) \
382145801Sume		print $$n"\t"$$0 }' $(IPNODES) | $(DBLOAD) ${B} -i $(IPNODES)  \
383145801Sume		-o $(YPMAPDIR)/$@ - $(TMP); $(RMV) $(TMP) $@
384145801Sume	@$(DBLOAD) -c
385145801Sume	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
386145801Sume	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
387145801Sume.endif
388145801Sume
389145801Sume
390145801Sumeipnodes.byaddr: $(IPNODES)
391145801Sume	@echo "Updating $@..."
392145801Sume.if ${IPNODES} == "/dev/null"
393145801Sume	@echo "Ipnodes source file not found -- skipping"
394145801Sume.else
395145801Sume	@$(AWK) '$$1 !~ "^#.*" { print $$1"\t"$$0 }' $(IPNODES) \
396145801Sume		| $(DBLOAD) ${B} -i $(IPNODES) -o $(YPMAPDIR)/$@ - $(TMP); \
397145801Sume		$(RMV) $(TMP) $@
398145801Sume	@$(DBLOAD) -c
399145801Sume	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
400145801Sume	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
401145801Sume.endif
402145801Sume
403145801Sume
40412891Swpaulnetworks.byname: $(NETWORKS)
40512891Swpaul	@echo "Updating $@..."
406116301Sru	@$(AWK) \
40732775Ssteve	   '$$1 !~ "^#.*"  { print $$1"\t"$$0; \
40832775Ssteve			  for (n=3; n<=NF && $$n !~ "^#.*"; n++) \
40912891Swpaul			      print $$n"\t"$$0 \
410116301Sru		}' $(NETWORKS) \
411116301Sru		| $(DBLOAD) -i $(NETWORKS) -o $(YPMAPDIR)/$@ - $(TMP); \
41233100Swpaul		$(RMV) $(TMP) $@
41315426Swpaul	@$(DBLOAD) -c
41412891Swpaul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
41512891Swpaul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
41612891Swpaul
41712891Swpaul
41812891Swpaulnetworks.byaddr: $(NETWORKS)
41912891Swpaul	@echo "Updating $@..."
420116301Sru	@$(AWK) '$$1 !~ "^#.*" { print $$2"\t"$$0 }' $(NETWORKS) \
42133100Swpaul		| $(DBLOAD) -i $(NETWORKS) -o $(YPMAPDIR)/$@ - $(TMP); \
42233100Swpaul		$(RMV) $(TMP) $@
42315426Swpaul	@$(DBLOAD) -c
42412891Swpaul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
42512891Swpaul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
42612891Swpaul
42712891Swpaul
42812891Swpaulprotocols.byname: $(PROTOCOLS)
42912891Swpaul	@echo "Updating $@..."
430116301Sru	@$(AWK) \
43132775Ssteve	   '$$1 !~ "^#.*"	{ print $$1"\t"$$0; \
43232775Ssteve			  for (n=3; n<=NF && $$n !~ "^#.*"; n++) \
43312891Swpaul			      print $$n"\t"$$0 \
434116301Sru			}' $(PROTOCOLS) | $(DBLOAD) -i $(PROTOCOLS) \
43533100Swpaul		-o $(YPMAPDIR)/$@ - $(TMP); $(RMV) $(TMP) $@
43615426Swpaul	@$(DBLOAD) -c
43712891Swpaul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
43812891Swpaul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
43912891Swpaul
44012891Swpaul
44112891Swpaulprotocols.bynumber: $(PROTOCOLS)
44212891Swpaul	@echo "Updating $@..."
443116301Sru	@$(AWK) '$$1 !~ "^#.*" { print $$2"\t"$$0 }' $(PROTOCOLS) \
44433100Swpaul		| $(DBLOAD) -i $(PROTOCOLS) -o $(YPMAPDIR)/$@ - $(TMP); \
44533100Swpaul		$(RMV) $(TMP) $@
44615426Swpaul	@$(DBLOAD) -c
44712891Swpaul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
44812891Swpaul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
44912891Swpaul
45012891Swpaul
45112891Swpaulrpc.byname: $(RPC)
45212891Swpaul	@echo "Updating $@..."
453116301Sru	@$(AWK) \
45432775Ssteve	   '$$1 !~ "^#.*"  { print $$1"\t"$$0; \
45532775Ssteve			  for (n=3; n<=NF && $$n !~ "^#.*"; n++) \
45612891Swpaul			      print $$n"\t"$$0 \
457116301Sru		}' $(RPC) | $(DBLOAD) -i $(RPC) -o $(YPMAPDIR)/$@ - $(TMP); \
45833100Swpaul		$(RMV) $(TMP) $@
45915426Swpaul	@$(DBLOAD) -c
46012891Swpaul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
46112891Swpaul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
46212891Swpaul
46312891Swpaul
46412891Swpaulrpc.bynumber: $(RPC)
46512891Swpaul	@echo "Updating $@..."
466116301Sru	@$(AWK) '$$1 !~ "^#.*" { print $$2"\t"$$0 }' $(RPC) \
46733100Swpaul		| $(DBLOAD)  -i $(RPC) -o $(YPMAPDIR)/$@ - $(TMP); \
46833100Swpaul		$(RMV) $(TMP) $@
46915426Swpaul	@$(DBLOAD) -c
47012891Swpaul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
47112891Swpaul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
47212891Swpaul
47312891Swpaul
47412891Swpaulservices.byname: $(SERVICES)
47512891Swpaul	@echo "Updating $@..."
476116301Sru	@$(AWK) \
47732775Ssteve	   '$$1 !~ "^#.*"  { for (n=1; n<=NF && $$n !~ "^#.*"; n++) { \
47833300Swpaul				if (split($$2, t, "/")) { \
47933300Swpaul					printf("%s/%s", $$n, t[2]) }; \
48033536Swpaul					print "\t"$$0;	\
48133300Swpaul					if (n == 1) n = 2; \
48233300Swpaul			   } ; print $$2"\t"$$0 ; \
483116301Sru		}' $(SERVICES) \
484116301Sru		| $(DBLOAD) -i $(SERVICES) -o $(YPMAPDIR)/$@ - $(TMP); \
48533100Swpaul		$(RMV) $(TMP) $@
48615426Swpaul	@$(DBLOAD) -c
48712891Swpaul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
48812891Swpaul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
48912891Swpaul
490159394Smaximshells: $(SHELLS)
491112458Srobert	@echo "Updating $@..."
492116301Sru	@$(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*") print $$0"\t"$$0 }' \
493116301Sru		$(SHELLS) \
494116301Sru		| $(DBLOAD) -i $(SHELLS) -o $(YPMAPDIR)/$@ - $(TMP); \
495112458Srobert	 $(RMV) $(TMP) $@
496112458Srobert	@$(DBLOAD) -c
497112458Srobert	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
498112458Srobert	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
49912891Swpaul
50012891Swpaulpublickey.byname: $(PUBLICKEY)
50112891Swpaul	@echo "Updating $@..."
50231110Swpaul.if ${PUBLICKEY} == "/dev/null"
50331110Swpaul	@echo "Publickey source file not found -- skipping"
50431110Swpaul.else
505116301Sru	@$(AWK) '$$1 !~ "^#.*" { print $$1"\t"$$2 }' $(PUBLICKEY) \
50633100Swpaul		| $(DBLOAD)  -i $(PUBLICKEY) -o $(YPMAPDIR)/$@ - $(TMP); \
50733100Swpaul		$(RMV) $(TMP) $@
50815426Swpaul	@$(DBLOAD) -c
50912891Swpaul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
51012891Swpaul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
51131110Swpaul.endif
51212891Swpaul
51312891Swpaul
51412891Swpaul$(PASSWD): $(MASTER)
51512891Swpaul	@echo "Creating new $@ file from $(MASTER)..."
51612891Swpaul	@if [ ! $(UNSECURE) ]; then \
51762210Sbrian	$(AWK) -F: '{if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
518116301Sru		print $$1":*:"$$3":"$$4":"$$8":"$$9":"$$10}' $(MASTER) \
51912891Swpaul		> $(PASSWD) ; \
520116301Sru	else \
52162210Sbrian	$(AWK) -F: '{if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
522116301Sru		print $$1":"$$2":"$$3":"$$4":"$$8":"$$9":"$$10}' $(MASTER) \
52312891Swpaul		> $(PASSWD) ; fi
52412891Swpaul
52512891Swpaul
52612891Swpaulpasswd.byname: $(PASSWD)
52712891Swpaul	@echo "Updating $@..."
528116301Sru	@$(AWK) -F: '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
529116301Sru		print $$1"\t"$$0 }' $(PASSWD) \
53050159Swpaul		| $(DBLOAD) -f -i $(PASSWD) -o $(YPMAPDIR)/$@ - $(TMP); \
53133100Swpaul		$(RMV) $(TMP) $@
53215426Swpaul	@$(DBLOAD) -c
53312891Swpaul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
53412891Swpaul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
53512891Swpaul
53615426Swpaul
53712891Swpaulpasswd.byuid: $(PASSWD)
53812891Swpaul	@echo "Updating $@..."
539116301Sru	@$(AWK) -F: '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
540116301Sru		print $$3"\t"$$0 }' $(PASSWD) \
54150159Swpaul		| $(DBLOAD) -f -i $(PASSWD) -o $(YPMAPDIR)/$@ - $(TMP); \
54233100Swpaul		$(RMV) $(TMP) $@
54315426Swpaul	@$(DBLOAD) -c
54412891Swpaul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
54512891Swpaul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
54612891Swpaul
54712891Swpaul
54812891Swpaulgroup.byname: $(GROUP)
54912891Swpaul	@echo "Updating $@..."
550116301Sru	@$(AWK) -F: '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
551116301Sru		print $$1"\t"$$0 }' $(GROUP) \
55250159Swpaul		| $(DBLOAD) -f -i $(GROUP) -o $(YPMAPDIR)/$@ - $(TMP); \
55333100Swpaul		$(RMV) $(TMP) $@
55415426Swpaul	@$(DBLOAD) -c
55512891Swpaul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
55612891Swpaul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
55712891Swpaul
55812891Swpaul
55912891Swpaulgroup.bygid: $(GROUP)
56012891Swpaul	@echo "Updating $@..."
561116301Sru	@$(AWK) -F: '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
562116301Sru		print $$3"\t"$$0 }' $(GROUP) \
56350159Swpaul		| $(DBLOAD) -f -i $(GROUP) -o $(YPMAPDIR)/$@ - $(TMP); \
56433100Swpaul		$(RMV) $(TMP) $@
56515426Swpaul	@$(DBLOAD) -c
56612891Swpaul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
56712891Swpaul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
56812891Swpaul
56912891Swpaul
570157722Srunetid.byname: $(GROUP) $(PASSWD) $(HOSTS)
57112891Swpaul	@echo "Updating $@..."
57216732Swpaul	@$(MKNETID) -q -p $(PASSWD) -g $(GROUP) -h $(HOSTS) -n $(NETID) \
57333100Swpaul		-d $(DOMAIN) | $(DBLOAD) -o $(YPMAPDIR)/$@ - $(TMP); \
57433100Swpaul		$(RMV) $(TMP) $@
57515426Swpaul	@$(DBLOAD) -c
57612891Swpaul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
57712891Swpaul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
57812891Swpaul
57912891Swpaul
58012891Swpaulmaster.passwd.byname: $(MASTER)
58112891Swpaul	@echo "Updating $@..."
58231110Swpaul.if ${MASTER} == "/dev/null"
58331110Swpaul	@echo "Master.passwd source file not found -- skipping"
58431110Swpaul.else
585116301Sru	@$(AWK) -F: '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
586116301Sru		print $$1"\t"$$0 }' $(MASTER) \
58750159Swpaul		| $(DBLOAD) ${S} -f -i $(MASTER) -o $(YPMAPDIR)/$@ - $(TMP); \
58833100Swpaul		$(RMV) $(TMP) $@
58915426Swpaul	@$(DBLOAD) -c
59012891Swpaul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
59112891Swpaul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
59231110Swpaul.endif
59312891Swpaul
59412891Swpaul
59512891Swpaulmaster.passwd.byuid: $(MASTER)
59612891Swpaul	@echo "Updating $@..."
59731110Swpaul.if ${MASTER} == "/dev/null"
59831110Swpaul	@echo "Master.passwd source file not found -- skipping"
59931110Swpaul.else
600116301Sru	@$(AWK) -F: '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
601116301Sru		print $$3"\t"$$0 }' $(MASTER) \
60250159Swpaul		| $(DBLOAD) ${S} -f -i $(MASTER) -o $(YPMAPDIR)/$@ - $(TMP); \
60333100Swpaul		$(RMV) $(TMP) $@
60415426Swpaul	@$(DBLOAD) -c
60512891Swpaul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
60612891Swpaul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
60731110Swpaul.endif
60817266Speter
60931110Swpaul
610194968Sbrianshadow.byname: $(MASTER)
611194968Sbrian	@echo "Updating $@..."
612194968Sbrian.if ${MASTER} == "/dev/null"
613194968Sbrian	@echo "Master.passwd source file not found -- skipping"
614194968Sbrian.else
615194968Sbrian	@$(AWK) -F: '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
616194968Sbrian		print $$1"\t"$$1":"$$2":12000:0:99999:7:::" }' $(MASTER) \
617194968Sbrian		| sed 's/\(	[^:]*:\)\*:/\1!:/' \
618194968Sbrian		| $(DBLOAD) ${S} -f -i $(PASSWD) -o $(YPMAPDIR)/$@ - $(TMP); \
619194968Sbrian		$(RMV) $(TMP) $@
620194968Sbrian	@$(DBLOAD) -c
621194968Sbrian	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
622194968Sbrian	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
623194968Sbrian.endif
624194968Sbrian
625194968Sbrianshadow.byuid: $(MASTER)
626194968Sbrian	@echo "Updating $@..."
627194968Sbrian.if ${MASTER} == "/dev/null"
628194968Sbrian	@echo "Master.passwd source file not found -- skipping"
629194968Sbrian.else
630194968Sbrian	@$(AWK) -F: '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
631194968Sbrian		print $$3"\t"$$1":"$$2":12000:0:99999:7:::" }' $(MASTER) \
632194968Sbrian		| sed 's/\(	[^:]*:\)\*:/\1!:/' \
633194968Sbrian		| $(DBLOAD) ${S} -f -i $(PASSWD) -o $(YPMAPDIR)/$@ - $(TMP); \
634194968Sbrian		$(RMV) $(TMP) $@
635194968Sbrian	@$(DBLOAD) -c
636194968Sbrian	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
637194968Sbrian	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
638194968Sbrian.endif
639194968Sbrian
64090320Smarkmamd.map: $(AMDHOST)
64117266Speter	@echo "Updating $@..."
642116301Sru	@$(AWK) '$$1 !~ "^#.*"  { \
64317266Speter	  for (i = 1; i <= NF; i++) \
64417266Speter	  if (i == NF) { \
64517266Speter	    if (substr($$i, length($$i), 1) == "\\") \
64617266Speter	      printf("%s", substr($$i, 1, length($$i) - 1)); \
64717266Speter	    else \
64817266Speter	      printf("%s\n", $$i); \
64917266Speter	  } \
65017266Speter	  else \
65117266Speter	    printf("%s ", $$i); \
652116301Sru	}' $(AMDHOST) | \
65333100Swpaul	$(DBLOAD) -i $(AMDHOST) -o $(YPMAPDIR)/$@ - $(TMP); \
65433100Swpaul		$(RMV) $(TMP) $@
65517266Speter	@$(DBLOAD) -c
65617266Speter	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
65717266Speter	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
658