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

367 lines
9.5 KiB
Makefile

# $NetBSD: Makefile.yp,v 1.8 1998/06/08 03:44:34 lukem Exp $
#
# This is the YP Makefile, used to create and push YP maps.
#
# Invoke with NOPUSH != "" to prevent the maps from being yppushed upon rebuild
#
NOPUSH?= ""
# Password maps in standard YP are insecure, because the pw_passwd
# field is accessable by any user. FreeBSD, NetBSD and OpenBSD have
# a common solution: a secure map (generated with makedbm -s) can
# only be accessed by a client bound to a privileged port.
#
# Uncomment out the following if you need compatibility with
# sites that don't support this feature.
#
#INSECURE?= yes
YPDBDIR= /var/yp
DIR= /etc
AMDDIR= /etc/amd
DOMAIN= "`/usr/bin/basename ${.CURDIR}`"
AWK= /usr/bin/awk
CAT= /bin/cat
CP= /bin/cp
CUT= /usr/bin/cut
ECHO= /bin/echo
MAKEDBM= /usr/sbin/makedbm
MAKEDBM_S= ${MAKEDBM} -s
MKALIAS= /usr/sbin/mkalias
MKNETID= /usr/sbin/mknetid
REVNETGROUP= /usr/sbin/revnetgroup
RM= /bin/rm
SED= /usr/bin/sed
SENDMAIL= /usr/sbin/sendmail
STDETHERS= /usr/sbin/stdethers
STDHOSTS= /usr/sbin/stdhosts
TOUCH= /usr/bin/touch
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 aliases amd.home ethers group hosts netgroup networks rpc services protocols netid
passwd.time: ${DIR}/master.passwd
-@if [ -f ${.ALLSRC} ]; then \
umask 077 ; \
if [ "${INSECURE}" != "yes" ]; then \
${CAT} ${.ALLSRC} | ${CUT} -d: -f1-4,8-10 | \
${AWK} 'BEGIN { FS=":"; OFS="\t"; } /^[a-zA-Z0-9_]/ \
{ print $$1, $$1":*:"$$3":"$$4":"$$5":"$$6":"$$7 }' -|\
${MAKEDBM} - passwd.byname; \
${CAT} ${.ALLSRC} | ${CUT} -d: -f1-4,8-10 |\
${AWK} 'BEGIN { FS=":"; OFS="\t"; } /^[a-zA-Z0-9_]/ \
{ print $$3, $$1":*:"$$3":"$$4":"$$5":"$$6":"$$7 }' -|\
${MAKEDBM} - passwd.byuid; \
else \
${CAT} ${.ALLSRC} | ${CUT} -d: -f1-4,8-10 | \
${AWK} 'BEGIN { FS=":"; OFS="\t"; } /^[a-zA-Z0-9_]/ \
{ print $$1, $$0 }' - | ${MAKEDBM} - passwd.byname; \
${CAT} ${.ALLSRC} | ${CUT} -d: -f1-4,8-10 |\
${AWK} 'BEGIN { FS=":"; OFS="\t"; } /^[a-zA-Z0-9_]/ \
{ print $$3, $$0 }' - | ${MAKEDBM} - passwd.byuid; \
fi; \
${CAT} ${.ALLSRC} | \
${AWK} 'BEGIN { FS=":"; OFS="\t"; } /^[a-zA-Z0-9_]/ \
{ print $$1, $$0 }' - | ${MAKEDBM_S} - master.passwd.byname; \
${CAT} ${.ALLSRC} | \
${AWK} 'BEGIN { FS=":"; OFS="\t"; } /^[a-zA-Z0-9_]/ \
{ print $$3, $$0 }' - | ${MAKEDBM_S} - master.passwd.byuid; \
${TOUCH} ${.TARGET}; \
${ECHO} "updated passwd"; \
if [ ! ${NOPUSH} ]; then \
${YPPUSH} -d ${DOMAIN} passwd.byname; \
${YPPUSH} -d ${DOMAIN} passwd.byuid; \
${YPPUSH} -d ${DOMAIN} master.passwd.byname; \
${YPPUSH} -d ${DOMAIN} master.passwd.byuid; \
${ECHO} "pushed passwd"; \
else \
: ; \
fi \
else \
${ECHO} "couldn't find ${.ALLSRC}"; \
fi
aliases.time: ${DIR}/aliases
-@if [ -f ${.ALLSRC} ]; then \
${CP} -p ${.ALLSRC} ${DOMAIN}-aliases; \
${SENDMAIL} -bi -oA${PWD}/${DOMAIN}-aliases; \
${MAKEDBM} -u ${DOMAIN}-aliases | ${MAKEDBM} - mail.aliases; \
${MKALIAS} mail.aliases mail.byaddr; \
${TOUCH} ${.TARGET}; \
${RM} ${DOMAIN}-aliases.db ${DOMAIN}-aliases; \
${ECHO} "updated aliases"; \
if [ ! ${NOPUSH} ]; then \
${YPPUSH} -d ${DOMAIN} mail.aliases; \
${YPPUSH} -d ${DOMAIN} mail.byaddr; \
${ECHO} "pushed aliases"; \
else \
: ; \
fi \
else \
${ECHO} "couldn't find ${.ALLSRC}"; \
fi
amd.home.time: ${AMDDIR}/amd.home
-@if [ -f ${.ALLSRC} ]; then \
${SED} -e "s/#.*$$//" -e "/^$$/d" ${.ALLSRC} | \
${AWK} '{ \
for (i = 1; i <= NF; i++) \
if (i == NF) { \
if (substr($$i, length($$i), 1) == "\\") { \
printf("%s", \
substr($$i, 1, length($$i) - 1)); \
} \
else \
printf("%s\n", $$i); \
} \
else \
printf("%s ", $$i); \
}' | \
${MAKEDBM} - amd.home; \
${TOUCH} ${.TARGET}; \
${ECHO} "updated amd.home"; \
if [ ! ${NOPUSH} ]; then \
${YPPUSH} -d ${DOMAIN} amd.home; \
${ECHO} "pushed amd.home"; \
else \
: ; \
fi \
else \
${ECHO} "couldn't find ${.ALLSRC}"; \
fi
ethers.time: ${DIR}/ethers
-@if [ -f ${.ALLSRC} ]; then \
${STDETHERS} ${.ALLSRC} | ${SED} -e s/#.*$$// | \
${AWK} 'BEGIN { FS="\t"; OFS="\t"; } { print $$1, $$0 }' | \
${MAKEDBM} - ethers.byaddr; \
${STDETHERS} ${.ALLSRC} | \
${AWK} 'BEGIN { FS="\t"; OFS="\t"; } { print $$2, $$0 }' | \
${MAKEDBM} - ethers.byname; \
${TOUCH} ${.TARGET}; \
${ECHO} "updated ethers"; \
if [ ! ${NOPUSH} ]; then \
${YPPUSH} -d ${DOMAIN} ethers.byaddr; \
${YPPUSH} -d ${DOMAIN} ethers.byname; \
${ECHO} "pushed ethers"; \
else \
: ; \
fi \
else \
${ECHO} "couldn't find ${.ALLSRC}"; \
fi
group.time: ${DIR}/group
-@if [ -f ${.ALLSRC} ]; then \
${AWK} 'BEGIN { FS=":"; OFS="\t"; } /^[a-zA-Z0-9_]/ \
{ print $$1, $$0 }' ${.ALLSRC} | \
${MAKEDBM} - group.byname; \
${AWK} 'BEGIN { FS=":"; OFS="\t"; } /^[a-zA-Z0-9_]/ \
{ print $$3, $$0 }' ${.ALLSRC} | \
${MAKEDBM} - group.bygid; \
${TOUCH} ${.TARGET}; \
${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 ${.ALLSRC}"; \
fi
hosts.time: ${DIR}/hosts
-@if [ -f ${.ALLSRC} ]; then \
${STDHOSTS} ${.ALLSRC} | ${SED} -e s/#.*$$// | \
${AWK} '{for (i = 2; i <= NF; i++) print $$i, $$0 }' | \
${MAKEDBM} - hosts.byname; \
${STDHOSTS} ${.ALLSRC} | \
${AWK} 'BEGIN { OFS="\t"; } { print $$1, $$0 }' | \
${MAKEDBM} - hosts.byaddr; \
${TOUCH} ${.TARGET}; \
${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 ${.ALLSRC}"; \
fi
netgroup.time: ${DIR}/netgroup
-@if [ -f ${.ALLSRC} ]; then \
${CAT} ${.ALLSRC} | ${MAKEDBM} - netgroup; \
${CAT} ${.ALLSRC} | ${REVNETGROUP} -u -f - | \
${MAKEDBM} - netgroup.byuser; \
${CAT} ${.ALLSRC} | ${REVNETGROUP} -h -f - | \
${MAKEDBM} - netgroup.byhost; \
${TOUCH} ${.TARGET}; \
${ECHO} "updated netgroup"; \
if [ ! ${NOPUSH} ]; then \
${YPPUSH} -d ${DOMAIN} netgroup; \
${YPPUSH} -d ${DOMAIN} netgroup.byuser; \
${YPPUSH} -d ${DOMAIN} netgroup.byhost; \
${ECHO} "pushed netgroup"; \
else \
: ; \
fi \
else \
${ECHO} "couldn't find ${.ALLSRC}"; \
fi
networks.time: ${DIR}/networks
-@if [ -f ${.ALLSRC} ]; then \
${SED} -e "/^#/d" -e s/#.*$$// ${.ALLSRC} | \
${AWK} '{print $$1, $$0; \
for (i = 3;i <= NF;i++) print $$i,$$0}' | \
${MAKEDBM} - networks.byname; \
${AWK} 'BEGIN { OFS="\t"; } $$1 !~ /^#/ { print $$2, $$0 }' \
${.ALLSRC} | \
${MAKEDBM} - networks.byaddr; \
${TOUCH} ${.TARGET}; \
${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 ${.ALLSRC}"; \
fi
protocols.time: ${DIR}/protocols
-@if [ -f ${.ALLSRC} ]; then \
${AWK} 'BEGIN { OFS="\t"; } $$1 !~ /^#/ { print $$2, $$0 }' \
${.ALLSRC} | \
${MAKEDBM} - protocols.bynumber; \
${SED} -e "/^#/d" -e s/#.*$$// ${.ALLSRC} | \
${AWK} '{print $$1, $$0; \
for (i = 3;i <= NF;i++) print $$i,$$0}' | \
${MAKEDBM} - protocols.byname; \
${TOUCH} ${.TARGET}; \
${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 ${.ALLSRC}"; \
fi
rpc.time: ${DIR}/rpc
-@if [ -f ${.ALLSRC} ]; then \
${AWK} 'BEGIN { OFS="\t"; } $$1 !~ /^#/ { print $$2, $$0 }' \
${.ALLSRC} | \
${MAKEDBM} - rpc.bynumber; \
${TOUCH} ${.TARGET}; \
${ECHO} "updated rpc"; \
if [ ! ${NOPUSH} ]; then \
${YPPUSH} -d ${DOMAIN} rpc.bynumber; \
${ECHO} "pushed rpc"; \
else \
: ; \
fi \
else \
${ECHO} "couldn't find ${.ALLSRC}"; \
fi
services.time: ${DIR}/services
-@if [ -f ${.ALLSRC} ]; then \
${AWK} 'BEGIN { OFS="\t"; } $$1 !~ /^#/ { print $$2, $$0 }' \
${.ALLSRC} | \
${MAKEDBM} - services.byname; \
${TOUCH} ${.TARGET}; \
${ECHO} "updated services"; \
if [ ! ${NOPUSH} ]; then \
${YPPUSH} -d ${DOMAIN} services.byname; \
${ECHO} "pushed services"; \
else \
: ; \
fi \
else \
${ECHO} "couldn't find ${.ALLSRC}"; \
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} ${.TARGET}; \
${ECHO} "updated netid"; \
if [ ! ${NOPUSH} ]; then \
${YPPUSH} -d ${DOMAIN} netid.byname; \
${ECHO} "pushed netid"; \
else \
: ; \
fi
ypservers.time: ${.CURDIR}/ypservers
-@${MAKEDBM} ypservers ypservers; \
${TOUCH} ${.TARGET}; \
${ECHO} "updated ypservers"; \
if [ ! ${NOPUSH} ]; then \
${YPPUSH} -d ${DOMAIN} ypservers; \
${ECHO} "pushed ypservers"; \
else \
: ; \
fi
passwd: passwd.time
group: group.time
hosts: hosts.time
aliases: aliases.time
amd.home: amd.home.time
ethers: ethers.time
netgroup: netgroup.time
networks: networks.time
rpc: rpc.time
services: services.time
protocols: protocols.time
netid: netid.time
ypservers: ypservers.time
${DIR}/passwd:
${DIR}/group:
${DIR}/hosts:
${DIR}/aliases:
${AMDDIR}/amd.home:
${DIR}/ethers:
${DIR}/master.passwd:
${DIR}/netgroup:
${DIR}/networks:
${DIR}/rpc:
${DIR}/services:
${DIR}/protocols:
${DIR}/netid: