NetBSD/usr.sbin/ypserv/ypinit/Makefile.yp

230 lines
5.7 KiB
Makefile
Raw Normal View History

# $NetBSD: Makefile.yp,v 1.3 1996/08/09 21:04:32 thorpej Exp $
#
# This is the YP Makefile, used to create and push YP maps.
#
YPDBDIR=/var/yp
DIR=/etc
NOPUSH=""
AWK=/usr/bin/awk
CAT=/bin/cat
CUT=/usr/bin/cut
ECHO=/bin/echo
MAKEDBM=/usr/sbin/makedbm
SED=/usr/bin/sed
STDHOSTS=/usr/sbin/stdhosts
STDETHERS=/usr/sbin/stdethers
MKNETID=/usr/sbin/mknetid
TOUCH=/usr/bin/touch
DOMAIN="`/usr/bin/basename ${.CURDIR}`"
YPPUSH=/usr/sbin/yppush
# We have a rule for ypservers, but we don't build it by default, since
# it seldom changes (only when slaves are added/deleted).
all: passwd group hosts ethers networks rpc services protocols netid
passwd.time: $(DIR)/master.passwd
-@if [ -f $(>) ]; then \
$(CAT) $(>) | $(CUT) -d: -f1-4,8-10 | \
$(AWK) 'BEGIN { FS=":"; OFS="\t"; } /^[a-zA-Z0-9_]/ \
{ print $$1, $$0 }' - | $(MAKEDBM) - passwd.byname; \
$(CAT) $(>) | $(CUT) -d: -f1-4,8-10 |\
$(AWK) 'BEGIN { FS=":"; OFS="\t"; } /^[a-zA-Z0-9_]/ \
{ print $$3, $$0 }' - | $(MAKEDBM) - passwd.byuid; \
$(TOUCH) $(@); \
$(ECHO) "updated passwd"; \
if [ ! $(NOPUSH) ]; then \
$(YPPUSH) -d $(DOMAIN) passwd.byname; \
$(YPPUSH) -d $(DOMAIN) passwd.byuid; \
$(ECHO) "pushed passwd"; \
else \
: ; \
fi \
else \
$(ECHO) "couldn't find $(>)"; \
fi
group.time: $(DIR)/group
-@if [ -f $(>) ]; then \
$(AWK) 'BEGIN { FS=":"; OFS="\t"; } /^[a-zA-Z0-9_]/ \
{ print $$1, $$0 }' $(>) | \
$(MAKEDBM) - group.byname; \
$(AWK) 'BEGIN { FS=":"; OFS="\t"; } /^[a-zA-Z0-9_]/ \
{ print $$3, $$0 }' $(>) | \
$(MAKEDBM) - group.bygid; \
$(TOUCH) $(@); \
$(ECHO) "updated group"; \
if [ ! $(NOPUSH) ]; then \
$(YPPUSH) -d $(DOMAIN) group.byname; \
$(YPPUSH) -d $(DOMAIN) group.bygid; \
$(ECHO) "pushed group"; \
else \
: ; \
fi \
else \
$(ECHO) "couldn't find $(>)"; \
fi
hosts.time: $(DIR)/hosts
-@if [ -f $(DIR)/hosts ]; then \
$(STDHOSTS) $(>) | $(SED) -e s/#.*$$// | \
$(AWK) '{for (i = 2; i <= NF; i++) print $$i, $$0 }' | \
$(MAKEDBM) - hosts.byname; \
$(STDHOSTS) $(>) | \
$(AWK) 'BEGIN { OFS="\t"; } { print $$1, $$0 }' | \
$(MAKEDBM) - hosts.byaddr; \
$(TOUCH) $(@); \
$(ECHO) "updated hosts"; \
if [ ! $(NOPUSH) ]; then \
$(YPPUSH) -d $(DOMAIN) hosts.byname; \
$(YPPUSH) -d $(DOMAIN) hosts.byaddr; \
$(ECHO) "pushed hosts"; \
else \
: ; \
fi \
else \
$(ECHO) "couldn't find $(>)"; \
fi
ethers.time: $(DIR)/ethers
-@if [ -f $(DIR)/ethers ]; then \
$(STDETHERS) $(>) | $(SED) -e s/#.*$$// | \
$(AWK) 'BEGIN { FS="\t"; OFS="\t"; } { print $$1, $$0 }' | \
$(MAKEDBM) - ethers.byaddr; \
$(STDETHERS) $(>) | \
$(AWK) 'BEGIN { FS="\t"; OFS="\t"; } { print $$2, $$0 }' | \
$(MAKEDBM) - ethers.byname; \
$(TOUCH) $(@); \
$(ECHO) "updated ethers"; \
if [ ! $(NOPUSH) ]; then \
$(YPPUSH) -d $(DOMAIN) ethers.byaddr; \
$(YPPUSH) -d $(DOMAIN) ethers.byname; \
$(ECHO) "pushed hosts"; \
else \
: ; \
fi \
else \
$(ECHO) "couldn't find $(>)"; \
fi
networks.time: $(DIR)/networks
-@if [ -f $(>) ]; then \
$(SED) -e "/^#/d" -e s/#.*$$// $(>) | \
$(AWK) '{print $$1, $$0; for (i = 3;i <= NF;i++) print $$i,$$0}' | \
$(MAKEDBM) - networks.byname; \
$(AWK) 'BEGIN { OFS="\t"; } $$1 !~ /^#/ { print $$2, $$0 }' $(>) | \
$(MAKEDBM) - networks.byaddr; \
$(TOUCH) $(@); \
$(ECHO) "updated networks"; \
if [ ! $(NOPUSH) ]; then \
$(YPPUSH) -d $(DOMAIN) networks.byname; \
$(YPPUSH) -d $(DOMAIN) networks.byaddr; \
$(ECHO) "pushed networks"; \
else \
: ; \
fi \
else \
$(ECHO) "couldn't find $(>)"; \
fi
rpc.time: $(DIR)/rpc
-@if [ -f $(>) ]; then \
$(AWK) 'BEGIN { OFS="\t"; } $$1 !~ /^#/ { print $$2, $$0 }' $(>) | \
$(MAKEDBM) - rpc.bynumber; \
$(TOUCH) $(@); \
$(ECHO) "updated rpc"; \
if [ ! $(NOPUSH) ]; then \
$(YPPUSH) -d $(DOMAIN) rpc.bynumber; \
$(ECHO) "pushed rpc"; \
else \
: ; \
fi \
else \
$(ECHO) "couldn't find $(>)"; \
fi
services.time: $(DIR)/services
-@if [ -f $(>) ]; then \
$(AWK) 'BEGIN { OFS="\t"; } $$1 !~ /^#/ { print $$2, $$0 }' $(>) | \
$(MAKEDBM) - services.byname; \
$(TOUCH) $(@); \
$(ECHO) "updated services"; \
if [ ! $(NOPUSH) ]; then \
$(YPPUSH) -d $(DOMAIN) services.byname; \
$(ECHO) "pushed services"; \
else \
: ; \
fi \
else \
$(ECHO) "couldn't find $(>)"; \
fi
protocols.time: $(DIR)/protocols
-@if [ -f $(>) ]; then \
$(AWK) 'BEGIN { OFS="\t"; } $$1 !~ /^#/ { print $$2, $$0 }' $(>) | \
$(MAKEDBM) - protocols.bynumber; \
$(SED) -e "/^#/d" -e s/#.*$$// $(>) | \
$(AWK) '{print $$1, $$0; for (i = 3;i <= NF;i++) print $$i,$$0}' | \
$(MAKEDBM) - protocols.byname; \
$(TOUCH) $(@); \
$(ECHO) "updated protocols"; \
if [ ! $(NOPUSH) ]; then \
$(YPPUSH) -d $(DOMAIN) protocols.bynumber; \
$(YPPUSH) -d $(DOMAIN) protocols.byname; \
$(ECHO) "pushed protocols"; \
else \
: ; \
fi \
else \
$(ECHO) "couldn't find $(>)"; \
fi
netid.time: $(DIR)/passwd $(DIR)/group $(DIR)/hosts $(DIR)/netid
-@$(MKNETID) -q -d $(DOMAIN) -p $(DIR)/passwd -g $(DIR)/group -h \
$(DIR)/hosts -m $(DIR)/netid | \
$(MAKEDBM) - netid.byname; \
$(TOUCH) $(@); \
$(ECHO) "updated netid"; \
if [ ! $(NOPUSH) ]; then \
$(YPPUSH) -d $(DOMAIN) netid.byname; \
$(ECHO) "pushed netid"; \
else \
: ; \
fi
ypservers:
-@$(TOUCH) ypservers; \
$(MAKEDBM) ypservers ypservers; \
$(ECHO) "updated ypservers"; \
if [ ! $(NOPUSH) ]; then \
$(YPPUSH) -d $(DOMAIN) ypservers; \
$(ECHO) "pushed ypservers"; \
else \
: ; \
fi
passwd: passwd.time
group: group.time
hosts: hosts.time
ethers: ethers.time
networks: networks.time
rpc: rpc.time
services: services.time
protocols: protocols.time
netid: netid.time
$(DIR)/passwd:
$(DIR)/group:
$(DIR)/hosts:
$(DIR)/ethers:
$(DIR)/networks:
$(DIR)/rpc:
$(DIR)/services:
$(DIR)/protocols:
$(DIR)/netid: