home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2 / Openstep-4.2-Intel-User.iso / usr / template / client / etc / yp / Makefile next >
Makefile  |  1997-03-28  |  7KB  |  236 lines

  1. DIR =/etc
  2. DOM = `domainname`
  3. NOPUSH = ""
  4. ALIASES = /etc/sendmail/aliases
  5. YPPUSH = /usr/etc/yp/yppush
  6. MAKEDBM = /usr/etc/yp/makedbm
  7. REVNETGROUP = /usr/etc/yp/revnetgroup
  8. MKGRPBYUSR = /usr/etc/yp/mkgrpbyusr
  9. STDHOSTS = /usr/etc/yp/stdhosts
  10.  
  11. all: passwd group hosts ethers networks rpc services protocols \
  12.     netgroup aliases
  13.  
  14. passwd.time: $(DIR)/passwd
  15.     -@if [ -f $(DIR)/passwd ]; then \
  16.         awk 'BEGIN { FS=":"; OFS="\t"; } /^[a-zA-Z0-9_]/ { print $$1, $$0 }' \
  17.           $(DIR)/passwd  | $(MAKEDBM) - /etc/yp/$(DOM)/passwd.byname; \
  18.         awk 'BEGIN { FS=":"; OFS="\t"; } /^[a-zA-Z0-9_]/ { print $$3, $$0 }' \
  19.           $(DIR)/passwd | $(MAKEDBM) - /etc/yp/$(DOM)/passwd.byuid; \
  20.         touch passwd.time; \
  21.         echo "updated passwd"; \
  22.         if [ ! $(NOPUSH) ]; then \
  23.             $(YPPUSH) passwd.byname; \
  24.             $(YPPUSH) passwd.byuid; \
  25.             echo "pushed passwd"; \
  26.         else \
  27.             : ; \
  28.         fi \
  29.     else \
  30.         echo "couldn't find $(DIR)/passwd"; \
  31.     fi
  32.  
  33. group.time: $(DIR)/group
  34.     -@if [ -f $(DIR)/group ]; then \
  35.         awk 'BEGIN { FS=":"; OFS="\t"; } { print $$1, $$0 }' \
  36.             $(DIR)/group | $(MAKEDBM) - /etc/yp/$(DOM)/group.byname; \
  37.         awk 'BEGIN { FS=":"; OFS="\t"; } { print $$3, $$0 }' \
  38.             $(DIR)/group | $(MAKEDBM) - /etc/yp/$(DOM)/group.bygid; \
  39.         $(MKGRPBYUSR) $(DIR)/group | \
  40.             awk 'BEGIN { OFS="\t"; } { print $$1, $$2 }' | \
  41.             $(MAKEDBM) - /etc/yp/$(DOM)/group.byusr; \
  42.         touch group.time; \
  43.         echo "updated group"; \
  44.         if [ ! $(NOPUSH) ]; then \
  45.             $(YPPUSH) group.byname; \
  46.             $(YPPUSH) group.bygid; \
  47.             $(YPPUSH) group.byusr; \
  48.             echo "pushed group"; \
  49.         else \
  50.             : ; \
  51.         fi \
  52.     else \
  53.         echo "couldn't find $(DIR)/group"; \
  54.     fi
  55.  
  56. hosts.time: $(DIR)/hosts
  57.     -@if [ -f $(DIR)/hosts ]; then \
  58.         sed -e "/^#/d" -e s/#.*$$// $(DIR)/hosts | $(STDHOSTS) \
  59.             | awk '{for (i = 2; i <= NF; i++) print $$i, $$0}' \
  60.             | $(MAKEDBM) - /etc/yp/$(DOM)/hosts.byname; \
  61.         $(STDHOSTS) $(DIR)/hosts | \
  62.             awk 'BEGIN { OFS="\t"; } $$1 !~ /^#/ { print $$1, $$0 }' \
  63.             | $(MAKEDBM) - /etc/yp/$(DOM)/hosts.byaddr; \
  64.         touch hosts.time; \
  65.         echo "updated hosts"; \
  66.         if [ ! $(NOPUSH) ]; then \
  67.             $(YPPUSH) hosts.byname; \
  68.             $(YPPUSH) hosts.byaddr; \
  69.             echo "pushed hosts"; \
  70.         else \
  71.             : ; \
  72.         fi \
  73.     else \
  74.         echo "couldn't find $(DIR)/hosts"; \
  75.     fi
  76.  
  77. ethers.time: $(DIR)/ethers
  78.     -@if [ -f $(DIR)/ethers ]; then \
  79.         sed -e "/^#/d" -e s/#.*$$// $(DIR)/ethers \
  80.         | awk 'BEGIN { X["A"]="a"; X["B"]="b"; X["C"]="c"; X["D"]="d";X["E"]="e"; X["F"]="f"; } \
  81.             { for (i = 1; i <= length($$1); i++) \
  82.               if (substr($$1, i, 1) >= "A" && substr($$1, i, 1) <= "Z") \
  83.             printf("%s", X[substr($$1, i, 1)]) ; \
  84.               else \
  85.             printf("%s", substr($$1, i, 1)); printf(" "); \
  86.             print $$2}' \
  87.         |awk '{print $$1, $$0; for (i = 3;i <= NF;i++) print $$i,$$0}' \
  88.         | $(MAKEDBM) - /etc/yp/$(DOM)/ethers.byaddr; \
  89.         awk 'BEGIN { OFS="\t"; } $$1 !~ /^#/ { print $$2, $$0 }' \
  90.            $(DIR)/ethers | \
  91.         $(MAKEDBM) - /etc/yp/$(DOM)/ethers.byname;\
  92.         touch ethers.time; \
  93.         echo "updated ethers"; \
  94.         if [ ! $(NOPUSH) ]; then \
  95.             $(YPPUSH) ethers.byname; \
  96.             $(YPPUSH) ethers.byaddr; \
  97.             echo "pushed ethers"; \
  98.         else \
  99.             : ; \
  100.         fi \
  101.     else \
  102.         echo "couldn't find $(DIR)/ethers"; \
  103.     fi
  104.  
  105. networks.time: $(DIR)/networks
  106.     -@if [ -f $(DIR)/networks ]; then \
  107.         sed -e "/^#/d" -e s/#.*$$// $(DIR)/networks | awk \
  108.             '{print $$1, $$0; for (i = 3;i <= NF;i++) print $$i,$$0}' \
  109.             | $(MAKEDBM) - /etc/yp/$(DOM)/networks.byname; \
  110.         awk 'BEGIN { OFS="\t"; } $$1 !~ /^#/ { print $$2, $$0 }' \
  111.            $(DIR)/networks | $(MAKEDBM) - /etc/yp/$(DOM)/networks.byaddr;\
  112.         touch networks.time; \
  113.         echo "updated networks"; \
  114.         if [ ! $(NOPUSH) ]; then \
  115.             $(YPPUSH) networks.byname; \
  116.             $(YPPUSH) networks.byaddr; \
  117.             echo "pushed networks"; \
  118.         else \
  119.             : ; \
  120.         fi \
  121.     else \
  122.         echo "couldn't find $(DIR)/networks"; \
  123.     fi
  124.  
  125. services.time: $(DIR)/services
  126.     -@if [ -f $(DIR)/services ]; then \
  127.         awk 'BEGIN { OFS="\t"; } $$1 !~ /^#/ { print $$2, $$0 }' \
  128.             $(DIR)/services| $(MAKEDBM) - /etc/yp/$(DOM)/services.byname;\
  129.         touch services.time; \
  130.         echo "updated services"; \
  131.         if [ ! $(NOPUSH) ]; then \
  132.             $(YPPUSH) services.byname; \
  133.             echo "pushed services"; \
  134.         else \
  135.             : ; \
  136.         fi \
  137.     else \
  138.         echo "couldn't find $(DIR)/services"; \
  139.     fi
  140.  
  141. rpc.time: $(DIR)/rpc
  142.     -@if [ -f $(DIR)/rpc ]; then \
  143.         awk 'BEGIN { OFS="\t"; } $$1 !~ /^#/ { print $$2, $$0 }' \
  144.             $(DIR)/rpc| $(MAKEDBM) - /etc/yp/$(DOM)/rpc.bynumber;\
  145.         touch rpc.time; \
  146.         echo "updated rpc"; \
  147.         if [ ! $(NOPUSH) ]; then \
  148.             $(YPPUSH) rpc.bynumber; \
  149.             echo "pushed rpc"; \
  150.         else \
  151.             : ; \
  152.         fi \
  153.     else \
  154.         echo "couldn't find $(DIR)/rpc"; \
  155.     fi
  156.  
  157. protocols.time: $(DIR)/protocols
  158.     -@if [ -f $(DIR)/protocols ]; then \
  159.         awk 'BEGIN { OFS="\t"; } $$1 !~ /^#/ { print $$2, $$0 }' \
  160.             $(DIR)/protocols | $(MAKEDBM) - \
  161.             /etc/yp/$(DOM)/protocols.bynumber; \
  162.         sed -e "/^#/d" -e s/#.*$$// $(DIR)/protocols | awk \
  163.             '{print $$1,$$0; for (i = 3;i <= NF;i++) print $$i, $$0}' \
  164.             | $(MAKEDBM) - /etc/yp/$(DOM)/protocols.byname; \
  165.         touch protocols.time; \
  166.         echo "updated protocols"; \
  167.         if [ ! $(NOPUSH) ]; then \
  168.             $(YPPUSH) protocols.byname; \
  169.             $(YPPUSH) protocols.bynumber; \
  170.             echo "pushed protocols"; \
  171.             else \
  172.             : ; \
  173.         fi \
  174.     else \
  175.         echo "couldn't find $(DIR)/protocols"; \
  176.     fi
  177.  
  178. netgroup.time: $(DIR)/netgroup
  179.     -@if [ -f $(DIR)/netgroup ]; then \
  180.         $(MAKEDBM) $(DIR)/netgroup /etc/yp/$(DOM)/netgroup; \
  181.         $(REVNETGROUP) -u < $(DIR)/netgroup \
  182.             | $(MAKEDBM) - /etc/yp/$(DOM)/netgroup.byuser; \
  183.         $(REVNETGROUP) -h < $(DIR)/netgroup \
  184.             | $(MAKEDBM) - /etc/yp/$(DOM)/netgroup.byhost; \
  185.         touch netgroup.time; \
  186.         echo "updated netgroup"; \
  187.         if [ ! $(NOPUSH) ]; then \
  188.             $(YPPUSH) netgroup; \
  189.             $(YPPUSH) netgroup.byuser; \
  190.             $(YPPUSH) netgroup.byhost; \
  191.             echo "pushed netgroup"; \
  192.         else \
  193.             : ; \
  194.         fi \
  195.     else \
  196.         echo "couldn't find $(DIR)/netgroup"; \
  197.     fi
  198.  
  199. aliases.time: $(ALIASES)
  200.     -@if [ -f $(ALIASES) ]; then \
  201.         cp $(ALIASES) /etc/yp/$(DOM)/mail.aliases; \
  202.         /usr/lib/sendmail -bi -oA/etc/yp/$(DOM)/mail.aliases; \
  203.         rm /etc/yp/$(DOM)/mail.aliases; \
  204.         touch aliases.time; \
  205.         echo "updated aliases"; \
  206.         if [ ! $(NOPUSH) ]; then \
  207.             $(YPPUSH) mail.aliases; \
  208.             echo "pushed aliases"; \
  209.         else \
  210.             : ; \
  211.         fi \
  212.     else \
  213.         echo "couldn't find $(ALIASES)"; \
  214.     fi
  215.  
  216. passwd: passwd.time
  217. group: group.time
  218. hosts: hosts.time
  219. ethers: ethers.time
  220. networks: networks.time
  221. rpc: rpc.time
  222. services: services.time
  223. protocols: protocols.time
  224. netgroup: netgroup.time
  225. aliases: aliases.time
  226. $(DIR)/passwd:
  227. $(DIR)/group:
  228. $(DIR)/hosts:
  229. $(DIR)/ethers:
  230. $(DIR)/networks:
  231. $(DIR)/rpc:
  232. $(DIR)/services:
  233. $(DIR)/protocols:
  234. $(DIR)/netgroup:
  235. $(ALIASES):
  236.