Makefile.yp revision 112458
112891Swpaul#
212891Swpaul# Makefile for the NIS databases
312891Swpaul#
450479Speter# $FreeBSD: head/usr.sbin/ypserv/Makefile.yp 112458 2003-03-21 11:44:03Z robert $
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
1412891Swpaul# If this machine is an NIS master, comment out this next line so
1512891Swpaul# that changes to the NIS maps can be propagated to the slave servers.
1612891Swpaul# (By default we assume that we are only serving a small domain with
1712891Swpaul# only one server.)
1812891Swpaul#
1912891SwpaulNOPUSH = "True"
2012891Swpaul
2112891Swpaul# If you want to use a FreeBSD NIS server to serve non-FreeBSD clients
2212891Swpaul# (i.e. clients who expect the password field in the passwd maps to be
2312891Swpaul# valid) then uncomment this line. This will cause $YPDIR/passwd to
2412891Swpaul# be generated with valid password fields. This is insecure: FreeBSD
2512891Swpaul# normally only serves the master.passwd maps (which have real encrypted
2612891Swpaul# passwords in them) to the superuser on other FreeBSD machines, but
2712891Swpaul# non-FreeBSD clients (e.g. SunOS, Solaris (without NIS+), IRIX, HP-UX,
2812891Swpaul# etc...) will only work properly in 'unsecure' mode.
2912891Swpaul# 
3012891Swpaul#UNSECURE = "True"
3112891Swpaul
3219161Swpaul# The following line encodes the YP_INTERDOMAIN key into the hosts.byname
3319161Swpaul# and hosts.byaddr maps so that ypserv(8) will do DNS lookups to resolve
3419161Swpaul# hosts not in the current domain. Commenting this line out will disable
3519161Swpaul# the DNS lookups.
3619161SwpaulB=-b
3719161Swpaul
3819161Swpaul# Normally, the master.passwd.* maps are guarded against access from
3919161Swpaul# non-privileged users. By commenting out the following line, the YP_SECURE
4019161Swpaul# key will be removed from these maps, allowing anyone to access them.
4119161SwpaulS=-s
4219161Swpaul
4312891Swpaul# These are commands which this Makefile needs to properly rebuild the
4412891Swpaul# NIS databases. Don't change these unless you have a good reason. Also
4512891Swpaul# be sure not to place an @ in front of /usr/bin/awk: it isn't necessary
4612891Swpaul# and it'll break everything in sight.
4712891Swpaul#
4812891SwpaulAWK = /usr/bin/awk
4912891SwpaulRM  = @/bin/rm -f
5015426SwpaulMV  = @/bin/mv -f
5133100SwpaulRMV  = /bin/mv -f
5212891SwpaulRCAT = /bin/cat
5312891SwpaulCAT = @$(RCAT)
5412891Swpaul
5517220SadamMKDB = /usr/sbin/yp_mkdb
5617220SadamDBLOAD = $(MKDB) -m `hostname`
5712891SwpaulMKNETID = /usr/libexec/mknetid
5815426SwpaulNEWALIASES = /usr/bin/newaliases
5913398SwpaulYPPUSH = /usr/sbin/yppush
6013896Swpaul.if !defined(UPDATE_DOMAIN)
6112891SwpaulDOMAIN = `/bin/domainname`
6213896Swpaul.else
6313896SwpaulDOMAIN = $(UPDATE_DOMAIN)
6413896Swpaul.endif
6512891SwpaulREVNETGROUP = /usr/libexec/revnetgroup
6633100SwpaulTMP = `echo $@.$$$$`
6712891Swpaul
6817220Sadam# It is advisable to create a separate directory to contain the
6917220Sadam# source files used to generate your NIS maps. If you intend to
7015426Swpaul# support multiple domains, something like /src/dir/$DOMAIN
7115426Swpaul# would work well.
7212891SwpaulYPSRCDIR = /etc
7331110Swpaul.if !defined(YP_DIR)
7412891SwpaulYPDIR = /var/yp
7531110Swpaul.else
7631110SwpaulYPDIR = $(YP_DIR)
7731110Swpaul.endif
7812891SwpaulYPMAPDIR = $(YPDIR)/$(DOMAIN)
7912891Swpaul
8012891Swpaul# These are the files from which the NIS databases are built. You may edit
8112891Swpaul# these to taste in the event that you wish to keep your NIS source files
8272091Sasmodai# separate from your NIS server's actual configuration files. Note that the
8312891Swpaul# NIS passwd and master.passwd files are stored in /var/yp: the server's
8412891Swpaul# real password database is not used by default. However, you may use
8512891Swpaul# the real /etc/passwd and /etc/master.passwd files by:
8612891Swpaul#
8712891Swpaul#
8837819Sphk# - invoking yppasswdd with `-t /etc/master.passwd' (yppasswdd will do a
8937819Sphk#   'pwd_mkdb' as needed if /etc/master.passwd is thus specified).
9012891Swpaul# - Specifying the location of the master.passwd file using the
9112891Swpaul#   MASTER_PASSWD variable, i.e.:
9212891Swpaul#
9312891Swpaul#   # make MASTER_PASSWD=/path/to/some/other/master.passwd
9412891Swpaul#
9512891Swpaul# - (optionally): editing this Makefile to change the default location.
9612891Swpaul#
9712891Swpaul# To add a user, edit $(YPDIR)/master.passwd and type 'make'. The raw
9812891Swpaul# passwd file will be generated from the master.passwd file automagically.
9912891Swpaul#
10012891SwpaulETHERS    = $(YPSRCDIR)/ethers	   # ethernet addresses (for rarpd)
10112891SwpaulBOOTPARAMS= $(YPSRCDIR)/bootparams # for booting Sun boxes (bootparamd)
10212891SwpaulHOSTS     = $(YPSRCDIR)/hosts
10312891SwpaulNETWORKS  = $(YPSRCDIR)/networks
10412891SwpaulPROTOCOLS = $(YPSRCDIR)/protocols
10512891SwpaulRPC 	  = $(YPSRCDIR)/rpc
10612891SwpaulSERVICES  = $(YPSRCDIR)/services
107112458SrobertSHELLS    = $(YPSRCDIR)/shells
10812891SwpaulGROUP     = $(YPSRCDIR)/group
10976621SgshapiroALIASES   = $(YPSRCDIR)/mail/aliases
11015426SwpaulNETGROUP  = $(YPDIR)/netgroup
11112891SwpaulPASSWD    = $(YPDIR)/passwd
11212891Swpaul.if !defined(MASTER_PASSWD)
11312891SwpaulMASTER    = $(YPDIR)/master.passwd
11412891Swpaul.else
11512891SwpaulMASTER	  = $(MASTER_PASSWD)
11612891Swpaul.endif
11712891SwpaulYPSERVERS = $(YPDIR)/ypservers	# List of all NIS servers for a domain
11812891SwpaulPUBLICKEY = $(YPSRCDIR)/publickey
11916732SwpaulNETID     = $(YPSRCDIR)/netid
12090320SmarkmAMDHOST   = $(YPSRCDIR)/amd.map
12112891Swpaul
12231110Swpaul# List of maps that are always built.
12331110Swpaul# If you want to omit some of them, feel free to comment
12431110Swpaul# them out from this list.
125112458SrobertTARGETS= servers hosts networks protocols rpc services shells group
12631110Swpaul#TARGETS+= aliases
12731110Swpaul
12831110Swpaul# Sanity checks: filter out targets we can't build
12931110Swpaul# Note that we don't build the ethers or boorparams maps by default
13031110Swpaul# since /etc/ethers and /etc/bootparams are not likely to be present
13131110Swpaul# on all systems.
13231110Swpaul.if exists($(ETHERS))
13331110SwpaulTARGETS+= ethers
13431110Swpaul.else
13531110SwpaulETHERS= /dev/null
13631110Swpaul.endif
13731110Swpaul
13831110Swpaul.if exists($(BOOTPARAMS))
13931110SwpaulTARGETS+= bootparams
14031110Swpaul.else
14131110SwpaulBOOTPARAMS= /dev/null
14231110Swpaul.endif
14331110Swpaul
14431110Swpaul.if exists($(NETGROUP))
14531110SwpaulTARGETS+= netgrp
14631110Swpaul.else
14731110SwpaulNETGROUP= /dev/null
14831110Swpaul.endif
14931110Swpaul
15031110Swpaul.if exists($(MASTER))
15131110SwpaulTARGETS+= passwd master.passwd netid
15231110Swpaul.else
15331110SwpaulMASTER= /dev/null
15431110SwpaulTARGETS+= nopass
15531110Swpaul.endif
15631110Swpaul
15731110Swpaul.if exists($(PUBLICKEY))
15831110SwpaulTARGETS+= publickey
15931110Swpaul.else
16031110SwpaulPUBLICKEY= /dev/null
16131110Swpaul.endif
16231110Swpaul
16331110Swpaul.if exists($(AMDHOST))
16490320SmarkmTARGETS+= amd.map
16531110Swpaul.else
16631110SwpaulAMDHOST= /dev/null
16731110Swpaul.endif
16831110Swpaul
16912891Swpaultarget: 
17012891Swpaul	@if [ ! -d $(DOMAIN) ]; then mkdir $(DOMAIN); fi; \
17113896Swpaul	cd $(DOMAIN) ; echo "NIS Map update started on `date` for domain $(DOMAIN)" ; \
17212891Swpaul	make -f ../Makefile all; echo "NIS Map update completed."
17312891Swpaul
17431110Swpaulall: $(TARGETS)
17512891Swpaul
17612891Swpaulethers:	   ethers.byname ethers.byaddr
17712891Swpaulbootparam: bootparams
17812891Swpaulhosts:	   hosts.byname hosts.byaddr
17912891Swpaulnetworks:  networks.byaddr networks.byname
18012891Swpaulprotocols: protocols.bynumber protocols.byname
18112891Swpaulrpc:	   rpc.byname rpc.bynumber
18212891Swpaulservices:  services.byname
183112458Srobertshells:    shells.list
18412891Swpaulpasswd:    passwd.byname passwd.byuid
18512891Swpaulgroup:     group.byname group.bygid
18612891Swpaulnetgrp:    netgroup
18712891Swpaulnetid:	   netid.byname
18812891Swpaulservers:   ypservers
18912891Swpaulpublickey: publickey.byname
19015426Swpaulaliases:   mail.aliases
19112891Swpaul
19212891Swpaulmaster.passwd:	master.passwd.byname master.passwd.byuid
19312891Swpaul
19416118Swpaul#
19516118Swpaul# This is a special target used only when doing in-place updates with
19616118Swpaul# rpc.yppasswdd. In this case, the maps will be updated by the rpc.yppasswdd
19716118Swpaul# server and won't need to be remade. They will have to be pushed to the
19816118Swpaul# slaves however. Calling this target implicitly insures that this will
19916118Swpaul# happen.
20016118Swpaul#
20116118Swpaulpushpw:
20216118Swpaul	@$(DBLOAD) -c
20316118Swpaul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) master.passwd.byname ; fi
20416118Swpaul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) master.passwd.byuid ; fi
20516118Swpaul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) passwd.byname ; fi
20616118Swpaul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) passwd.byuid ; fi
20716118Swpaul
20831110Swpaulpushmap:
20931110Swpaul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $(PUSHMAP) ; fi
21031110Swpaul
21131110Swpaulnopass:
21231110Swpaul	@echo ""
21331110Swpaul	@echo "                ********WARNING********"
21431110Swpaul	@echo "  Couldn't find the master.passwd source file. This file"
21531110Swpaul	@echo "  is needed to generate the master.passwd and passwd maps."
21631110Swpaul	@echo "  The default location is /var/yp/master.passwd. You should"
21731110Swpaul	@echo "  edit /var/yp/Makefile and set the MASTER variable to point"
21831110Swpaul	@echo "  to the source file you wish to use for building the passwd"
21931110Swpaul	@echo "  maps, or else invoke make(1) in the following manner:"
22048199Sn_hibma	@echo ""
22131110Swpaul	@echo "        make MASTER_PASSWD=/path/to/master.passwd"
22231110Swpaul	@echo ""
22331110Swpaul
22415426Swpaulmail.aliases: $(ALIASES)
22515426Swpaul	@echo "Updating $@..."
22617220Sadam	@$(NEWALIASES) -oA$(ALIASES)
22717481Sadam	@$(MKDB) -u $(ALIASES).db \
22833100Swpaul		| $(DBLOAD) -i $(ALIASES) -o $(YPMAPDIR)/$@ - $(TMP); \
22933100Swpaul		$(RMV) $(TMP) $@
23015426Swpaul	@$(DBLOAD) -c
23116044Swpaul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
23216044Swpaul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
23312891Swpaul
23415426Swpaul
23512891Swpaulypservers: $(YPSERVERS)
23612891Swpaul	@echo "Updating $@..."
23712891Swpaul	$(CAT) $(YPSERVERS) | \
23832775Ssteve	$(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*") print $$0"\t"$$0 }' $^ \
23933100Swpaul		| $(DBLOAD) -i $(YPSERVERS) -o $(YPMAPDIR)/$@ - $(TMP); \
24033100Swpaul		$(RMV) $(TMP) $@
24115426Swpaul	@$(DBLOAD) -c
24212891Swpaul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
24312891Swpaul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
24412891Swpaul
24512891Swpaulethers.byname: $(ETHERS)
24612891Swpaul	@echo "Updating $@..."
24731110Swpaul.if ${ETHERS} == "/dev/null"
24831110Swpaul	@echo "Ethers source file not found -- skipping"
24931110Swpaul.else
25012891Swpaul	$(CAT) $(ETHERS) | \
25132775Ssteve	$(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
25212891Swpaul		print $$2"\t"$$0 }' $^ | $(DBLOAD) -i $(ETHERS) \
25333100Swpaul		-o $(YPMAPDIR)/$@ - $(TMP); $(RMV) $(TMP) $@
25415426Swpaul	@$(DBLOAD) -c
25517268Speter	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
25612891Swpaul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
25731110Swpaul.endif
25812891Swpaul
25912891Swpaulethers.byaddr: $(ETHERS)
26012891Swpaul	@echo "Updating $@..."
26131110Swpaul.if ${ETHERS} == "/dev/null"
26231110Swpaul	@echo "Ethers source file not found -- skipping"
26331110Swpaul.else
26412891Swpaul	$(CAT) $(ETHERS) | \
26532775Ssteve	$(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
26612891Swpaul		print $$1"\t"$$0 }' $^ | $(DBLOAD) -i $(ETHERS) \
26733100Swpaul		-o $(YPMAPDIR)/$@ - $(TMP); $(RMV) $(TMP) $@
26815426Swpaul	@$(DBLOAD) -c
26912891Swpaul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
27012891Swpaul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
27131110Swpaul.endif
27212891Swpaul
27312891Swpaul
27412891Swpaulbootparams: $(BOOTPARAMS)
27512891Swpaul	@echo "Updating $@..."
27631110Swpaul.if ${BOOTPARAMS} == "/dev/null"
27731110Swpaul	@echo "Bootparams source file not found -- skipping"
27831110Swpaul.else
27912891Swpaul	$(CAT) $(BOOTPARAMS) | \
28032775Ssteve	$(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
28112891Swpaul		print $$0 }' $^ | $(DBLOAD) -i $(BOOTPARAMS) \
28233100Swpaul		-o $(YPMAPDIR)/$@ - $(TMP); $(RMV) $(TMP) $@
28315426Swpaul	@$(DBLOAD) -c
28412891Swpaul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
28512891Swpaul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
28631110Swpaul.endif
28712891Swpaul
28812891Swpaul
28912891Swpaulnetgroup: $(NETGROUP) netgroup.byhost netgroup.byuser
29012891Swpaul	@echo "Updating $@..."
29131110Swpaul.if ${NETGROUP} == "/dev/null"
29231110Swpaul	@echo "Netgroup source file not found -- skipping"
29331110Swpaul.else
29412891Swpaul	$(CAT) $(NETGROUP) | \
29532775Ssteve	$(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
29612891Swpaul		print $$0 }' $^ | $(DBLOAD) -i $(NETGROUP) \
29733100Swpaul		-o $(YPMAPDIR)/$@ - $(TMP); $(RMV) $(TMP) $@
29815426Swpaul	@$(DBLOAD) -c
29912891Swpaul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
30012891Swpaul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
30112891Swpaul	@$(MAKE) -f ../Makefile netid
30231110Swpaul.endif
30312891Swpaul
30412891Swpaul
30512891Swpaulnetgroup.byhost: $(NETGROUP)
30612891Swpaul	@echo "Updating $@..."
30731110Swpaul.if ${NETGROUP} == "/dev/null"
30831110Swpaul	@echo "Netgroup source file not found -- skipping"
30931110Swpaul.else
31012891Swpaul	$(CAT) $(NETGROUP) | $(REVNETGROUP) -h -f $(NETGROUP) | \
31132775Ssteve	$(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
31212891Swpaul		print $$0 }' $^ | $(DBLOAD) -i $(NETGROUP) \
31333100Swpaul		-o $(YPMAPDIR)/$@ - $(TMP); $(RMV) $(TMP) $@
31415426Swpaul	@$(DBLOAD) -c
31512891Swpaul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
31612891Swpaul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
31731110Swpaul.endif
31812891Swpaul
31912891Swpaul
32012891Swpaulnetgroup.byuser: $(NETGROUP)
32112891Swpaul	@echo "Updating $@..."
32231110Swpaul.if ${NETGROUP} == "/dev/null"
32331110Swpaul	@echo "Netgroup source file not found -- skipping"
32431110Swpaul.else
32512891Swpaul	$(CAT) $(NETGROUP) | $(REVNETGROUP) -u -f $(NETGROUP) | \
32632775Ssteve	$(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
32712891Swpaul		print $$0 }' $^ | $(DBLOAD) -i $(NETGROUP) \
32833100Swpaul		-o $(YPMAPDIR)/$@ - $(TMP); $(RMV) $(TMP) $@
32915426Swpaul	@$(DBLOAD) -c
33012891Swpaul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
33112891Swpaul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
33231110Swpaul.endif
33312891Swpaul
33412891Swpaul
33512891Swpaulhosts.byname: $(HOSTS)
33612891Swpaul	@echo "Updating $@..."
33712891Swpaul	$(CAT) $(HOSTS) | \
33832775Ssteve	$(AWK) '/^[0-9]/ { for (n=2; n<=NF && $$n !~ "^#.*"; n++) \
33919785Swpaul		print $$n"\t"$$0 }' $^ | $(DBLOAD) ${B} -i $(HOSTS)  \
34033100Swpaul		-o $(YPMAPDIR)/$@ - $(TMP); $(RMV) $(TMP) $@
34115426Swpaul	@$(DBLOAD) -c
34212891Swpaul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
34312891Swpaul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
34412891Swpaul	@$(MAKE) -f ../Makefile netid
34512891Swpaul
34615426Swpaul
34712891Swpaulhosts.byaddr: $(HOSTS)
34812891Swpaul	@echo "Updating $@..."
34912891Swpaul	$(CAT) $(HOSTS) | \
35032775Ssteve	$(AWK) '$$1 !~ "^#.*" { print $$1"\t"$$0 }' $^ \
35133100Swpaul		| $(DBLOAD) ${B} -i $(HOSTS) -o $(YPMAPDIR)/$@ - $(TMP); \
35233100Swpaul		$(RMV) $(TMP) $@
35315426Swpaul	@$(DBLOAD) -c
35412891Swpaul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
35512891Swpaul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
35612891Swpaul	@$(MAKE) -f ../Makefile netid
35712891Swpaul
35812891Swpaul
35912891Swpaulnetworks.byname: $(NETWORKS)
36012891Swpaul	@echo "Updating $@..."
36112891Swpaul	$(CAT) $(NETWORKS) | \
36212891Swpaul	$(AWK) \
36332775Ssteve	   '$$1 !~ "^#.*"  { print $$1"\t"$$0; \
36432775Ssteve			  for (n=3; n<=NF && $$n !~ "^#.*"; n++) \
36512891Swpaul			      print $$n"\t"$$0 \
36633100Swpaul		}' $^ | $(DBLOAD) -i $(NETWORKS) -o $(YPMAPDIR)/$@ - $(TMP); \
36733100Swpaul		$(RMV) $(TMP) $@
36815426Swpaul	@$(DBLOAD) -c
36912891Swpaul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
37012891Swpaul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
37112891Swpaul
37212891Swpaul
37312891Swpaulnetworks.byaddr: $(NETWORKS)
37412891Swpaul	@echo "Updating $@..."
37512891Swpaul	$(CAT) $(NETWORKS) | \
37632775Ssteve	$(AWK) '$$1 !~ "^#.*" { print $$2"\t"$$0 }' $^ \
37733100Swpaul		| $(DBLOAD) -i $(NETWORKS) -o $(YPMAPDIR)/$@ - $(TMP); \
37833100Swpaul		$(RMV) $(TMP) $@
37915426Swpaul	@$(DBLOAD) -c
38012891Swpaul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
38112891Swpaul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
38212891Swpaul
38312891Swpaul
38412891Swpaulprotocols.byname: $(PROTOCOLS)
38512891Swpaul	@echo "Updating $@..."
38612891Swpaul	$(CAT) $(PROTOCOLS) | \
38712891Swpaul	$(AWK) \
38832775Ssteve	   '$$1 !~ "^#.*"	{ print $$1"\t"$$0; \
38932775Ssteve			  for (n=3; n<=NF && $$n !~ "^#.*"; n++) \
39012891Swpaul			      print $$n"\t"$$0 \
39112891Swpaul			}' $^ | $(DBLOAD) -i $(PROTOCOLS) \
39233100Swpaul		-o $(YPMAPDIR)/$@ - $(TMP); $(RMV) $(TMP) $@
39315426Swpaul	@$(DBLOAD) -c
39412891Swpaul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
39512891Swpaul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
39612891Swpaul
39712891Swpaul
39812891Swpaulprotocols.bynumber: $(PROTOCOLS)
39912891Swpaul	@echo "Updating $@..."
40012891Swpaul	$(CAT) $(PROTOCOLS) | \
40132775Ssteve	$(AWK) '$$1 !~ "^#.*" { print $$2"\t"$$0 }' $^ \
40233100Swpaul		| $(DBLOAD) -i $(PROTOCOLS) -o $(YPMAPDIR)/$@ - $(TMP); \
40333100Swpaul		$(RMV) $(TMP) $@
40415426Swpaul	@$(DBLOAD) -c
40512891Swpaul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
40612891Swpaul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
40712891Swpaul
40812891Swpaul
40912891Swpaulrpc.byname: $(RPC)
41012891Swpaul	@echo "Updating $@..."
41112891Swpaul	$(CAT) $(RPC) | \
41212891Swpaul	$(AWK) \
41332775Ssteve	   '$$1 !~ "^#.*"  { print $$1"\t"$$0; \
41432775Ssteve			  for (n=3; n<=NF && $$n !~ "^#.*"; n++) \
41512891Swpaul			      print $$n"\t"$$0 \
41633100Swpaul		}' $^ | $(DBLOAD) -i $(RPC) -o $(YPMAPDIR)/$@ - $(TMP); \
41733100Swpaul		$(RMV) $(TMP) $@
41815426Swpaul	@$(DBLOAD) -c
41912891Swpaul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
42012891Swpaul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
42112891Swpaul
42212891Swpaul
42312891Swpaulrpc.bynumber: $(RPC)
42412891Swpaul	@echo "Updating $@..."
42512891Swpaul	$(CAT) $(RPC) | \
42632775Ssteve	$(AWK) '$$1 !~ "^#.*" { print $$2"\t"$$0 }' $^ \
42733100Swpaul		| $(DBLOAD)  -i $(RPC) -o $(YPMAPDIR)/$@ - $(TMP); \
42833100Swpaul		$(RMV) $(TMP) $@
42915426Swpaul	@$(DBLOAD) -c
43012891Swpaul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
43112891Swpaul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
43212891Swpaul
43312891Swpaul
43412891Swpaulservices.byname: $(SERVICES)
43512891Swpaul	@echo "Updating $@..."
43612891Swpaul	$(CAT) $(SERVICES) | \
43712891Swpaul	$(AWK) \
43832775Ssteve	   '$$1 !~ "^#.*"  { for (n=1; n<=NF && $$n !~ "^#.*"; n++) { \
43933300Swpaul				if (split($$2, t, "/")) { \
44033300Swpaul					printf("%s/%s", $$n, t[2]) }; \
44133536Swpaul					print "\t"$$0;	\
44233300Swpaul					if (n == 1) n = 2; \
44333300Swpaul			   } ; print $$2"\t"$$0 ; \
44433100Swpaul		}' $^ | $(DBLOAD) -i $(SERVICES) -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
450112458Srobertshells.list: $(SHELLS)
451112458Srobert	@echo "Updating $@..."
452112458Srobert	$(CAT) $(SHELLS) | \
453112458Srobert	   $(AWK) '{ if ($$1 != "" && $$1 !~ "^#.*") print $$0"\t"$$0 }' $^ | \
454112458Srobert	   $(DBLOAD) -i $(SHELLS) -o $(YPMAPDIR)/$@ - $(TMP); \
455112458Srobert	 $(RMV) $(TMP) $@
456112458Srobert	@$(DBLOAD) -c
457112458Srobert	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
458112458Srobert	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
45912891Swpaul
46012891Swpaulpublickey.byname: $(PUBLICKEY)
46112891Swpaul	@echo "Updating $@..."
46231110Swpaul.if ${PUBLICKEY} == "/dev/null"
46331110Swpaul	@echo "Publickey source file not found -- skipping"
46431110Swpaul.else
46522495Swpaul	$(CAT) $(PUBLICKEY) | \
46632775Ssteve	$(AWK) '$$1 !~ "^#.*" { print $$1"\t"$$2 }' $^ \
46733100Swpaul		| $(DBLOAD)  -i $(PUBLICKEY) -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
47231110Swpaul.endif
47312891Swpaul
47412891Swpaul
47512891Swpaul$(PASSWD): $(MASTER)
47612891Swpaul	@echo "Creating new $@ file from $(MASTER)..."
47712891Swpaul	@if [ ! $(UNSECURE) ]; then \
47812891Swpaul	$(RCAT) $(MASTER) | \
47962210Sbrian	$(AWK) -F: '{if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
48012891Swpaul		print $$1":*:"$$3":"$$4":"$$8":"$$9":"$$10}' $^ \
48112891Swpaul		> $(PASSWD) ; \
48212891Swpaul	else $(RCAT) $(MASTER) | \
48362210Sbrian	$(AWK) -F: '{if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
48412891Swpaul		print $$1":"$$2":"$$3":"$$4":"$$8":"$$9":"$$10}' $^ \
48512891Swpaul		> $(PASSWD) ; fi
48612891Swpaul
48712891Swpaul
48812891Swpaulpasswd.byname: $(PASSWD)
48912891Swpaul	@echo "Updating $@..."
49012891Swpaul	$(CAT) $(PASSWD) | \
49161707Sbrian	$(AWK) -F: '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
49261707Sbrian		print $$1"\t"$$0 }' $^ \
49350159Swpaul		| $(DBLOAD) -f -i $(PASSWD) -o $(YPMAPDIR)/$@ - $(TMP); \
49433100Swpaul		$(RMV) $(TMP) $@
49515426Swpaul	@$(DBLOAD) -c
49612891Swpaul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
49712891Swpaul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
49812891Swpaul
49915426Swpaul
50012891Swpaulpasswd.byuid: $(PASSWD)
50112891Swpaul	@echo "Updating $@..."
50212891Swpaul	$(CAT) $(PASSWD) | \
50361707Sbrian	$(AWK) -F: '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
50461707Sbrian		print $$3"\t"$$0 }' $^ \
50550159Swpaul		| $(DBLOAD) -f -i $(PASSWD) -o $(YPMAPDIR)/$@ - $(TMP); \
50633100Swpaul		$(RMV) $(TMP) $@
50715426Swpaul	@$(DBLOAD) -c
50812891Swpaul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
50912891Swpaul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
51012891Swpaul	@$(MAKE) -f ../Makefile netid
51112891Swpaul
51212891Swpaul
51312891Swpaulgroup.byname: $(GROUP)
51412891Swpaul	@echo "Updating $@..."
51512891Swpaul	$(CAT) $(GROUP) | \
51661707Sbrian	$(AWK) -F: '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
51761707Sbrian		print $$1"\t"$$0 }' $^ \
51850159Swpaul		| $(DBLOAD) -f -i $(GROUP) -o $(YPMAPDIR)/$@ - $(TMP); \
51933100Swpaul		$(RMV) $(TMP) $@
52015426Swpaul	@$(DBLOAD) -c
52112891Swpaul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
52212891Swpaul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
52312891Swpaul
52412891Swpaul
52512891Swpaulgroup.bygid: $(GROUP)
52612891Swpaul	@echo "Updating $@..."
52712891Swpaul	$(CAT) $(GROUP) | \
52861707Sbrian	$(AWK) -F: '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
52961707Sbrian		print $$3"\t"$$0 }' $^ \
53050159Swpaul		| $(DBLOAD) -f -i $(GROUP) -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	@$(MAKE) -f ../Makefile netid
53612891Swpaul
53712891Swpaul
53812891Swpaulnetid.byname: $(GROUP) $(PASSWD)
53912891Swpaul	@echo "Updating $@..."
54016732Swpaul	@$(MKNETID) -q -p $(PASSWD) -g $(GROUP) -h $(HOSTS) -n $(NETID) \
54133100Swpaul		-d $(DOMAIN) | $(DBLOAD) -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
54812891Swpaulmaster.passwd.byname: $(MASTER)
54912891Swpaul	@echo "Updating $@..."
55031110Swpaul.if ${MASTER} == "/dev/null"
55131110Swpaul	@echo "Master.passwd source file not found -- skipping"
55231110Swpaul.else
55312891Swpaul	$(CAT) $(MASTER) | \
55462210Sbrian	$(AWK) -F: '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
55562210Sbrian		print $$1"\t"$$0 }' $^ \
55650159Swpaul		| $(DBLOAD) ${S} -f -i $(MASTER) -o $(YPMAPDIR)/$@ - $(TMP); \
55733100Swpaul		$(RMV) $(TMP) $@
55815426Swpaul	@$(DBLOAD) -c
55912891Swpaul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
56012891Swpaul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
56131110Swpaul.endif
56212891Swpaul
56312891Swpaul
56412891Swpaulmaster.passwd.byuid: $(MASTER)
56512891Swpaul	@echo "Updating $@..."
56631110Swpaul.if ${MASTER} == "/dev/null"
56731110Swpaul	@echo "Master.passwd source file not found -- skipping"
56831110Swpaul.else
56912891Swpaul	$(CAT) $(MASTER) | \
57062210Sbrian	$(AWK) -F: '{ if ($$1 != "" && $$1 !~ "^#.*" && $$1 != "+") \
57162210Sbrian		print $$3"\t"$$0 }' $^ \
57250159Swpaul		| $(DBLOAD) ${S} -f -i $(MASTER) -o $(YPMAPDIR)/$@ - $(TMP); \
57333100Swpaul		$(RMV) $(TMP) $@
57415426Swpaul	@$(DBLOAD) -c
57512891Swpaul	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
57612891Swpaul	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
57731110Swpaul.endif
57817266Speter
57931110Swpaul
58090320Smarkmamd.map: $(AMDHOST)
58117266Speter	@echo "Updating $@..."
58217266Speter	$(CAT) $(AMDHOST) | \
58332775Ssteve	$(AWK) '$$1 !~ "^#.*"  { \
58417266Speter	  for (i = 1; i <= NF; i++) \
58517266Speter	  if (i == NF) { \
58617266Speter	    if (substr($$i, length($$i), 1) == "\\") \
58717266Speter	      printf("%s", substr($$i, 1, length($$i) - 1)); \
58817266Speter	    else \
58917266Speter	      printf("%s\n", $$i); \
59017266Speter	  } \
59117266Speter	  else \
59217266Speter	    printf("%s ", $$i); \
59317266Speter	}' | \
59433100Swpaul	$(DBLOAD) -i $(AMDHOST) -o $(YPMAPDIR)/$@ - $(TMP); \
59533100Swpaul		$(RMV) $(TMP) $@
59617266Speter	@$(DBLOAD) -c
59717266Speter	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
59817266Speter	@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
59917266Speter
600