]> git.saurik.com Git - apple/network_cmds.git/blob - ypinit.tproj/Makefile.yp
network_cmds-176.tar.gz
[apple/network_cmds.git] / ypinit.tproj / Makefile.yp
1 YPDBDIR=/private/var/yp
2 DIR=/etc
3 AMDDIR=/etc/amd
4 NOPUSH=""
5 #
6 AWK=/usr/bin/awk
7 CAT=/bin/cat
8 CP=/bin/cp
9 RM=/bin/rm
10 CUT=/usr/bin/cut
11 ECHO=/bin/echo
12 MAKEDBM=/usr/sbin/makedbm
13 SED=/usr/bin/sed
14 SENDMAIL=/usr/sbin/sendmail
15 STDHOSTS=/usr/sbin/stdhosts
16 STDETHERS=/usr/sbin/stdethers
17 MKALIAS=/usr/sbin/mkalias
18 MKNETID=/usr/sbin/mknetid
19 REVNETGROUP=/usr/sbin/revnetgroup
20 TOUCH=/usr/bin/touch
21 DOMAIN:=`/usr/bin/basename ${.CURDIR}`
22 YPPUSH=/usr/sbin/yppush
23
24 # Password maps in standard YP is unsecure. This is due to the fact that
25 # passwords are accessable for anyone.
26 # As a solution, maps can be secure (makedbm -s). If a map is secure only
27 # a privileged user can access it.
28 MAKEDBM-S=$(MAKEDBM) -s
29 UNSECURE="True"
30
31 all: passwd group hosts ethers networks rpc services protocols netid netgroup aliases
32
33 passwd.time: $(DIR)/master.passwd
34 -@if [ -f $(>) ]; then \
35 if [ ! $(UNSECURE) ]; then \
36 $(CAT) $(>) | $(CUT) -d: -f1-4,8-10 | \
37 $(AWK) 'BEGIN { FS=":"; OFS="\t"; } /^[a-zA-Z0-9_]/ \
38 { print $$1, $$1":*:"$$3":"$$4":"$$5":"$$6":"$$7 }' -|\
39 $(MAKEDBM) - passwd.byname; \
40 $(CAT) $(>) | $(CUT) -d: -f1-4,8-10 |\
41 $(AWK) 'BEGIN { FS=":"; OFS="\t"; } /^[a-zA-Z0-9_]/ \
42 { print $$3, $$1":*:"$$3":"$$4":"$$5":"$$6":"$$7 }' -|\
43 $(MAKEDBM) - passwd.byuid; \
44 else \
45 $(CAT) $(>) | $(CUT) -d: -f1-4,8-10 | \
46 $(AWK) 'BEGIN { FS=":"; OFS="\t"; } /^[a-zA-Z0-9_]/ \
47 { print $$1, $$0 }' - | $(MAKEDBM) - passwd.byname; \
48 $(CAT) $(>) | $(CUT) -d: -f1-4,8-10 |\
49 $(AWK) 'BEGIN { FS=":"; OFS="\t"; } /^[a-zA-Z0-9_]/ \
50 { print $$3, $$0 }' - | $(MAKEDBM) - passwd.byuid; \
51 fi; \
52 $(CAT) $(>) | \
53 $(AWK) 'BEGIN { FS=":"; OFS="\t"; } /^[a-zA-Z0-9_]/ \
54 { print $$1, $$0 }' - | $(MAKEDBM-S) - master.passwd.byname; \
55 $(CAT) $(>) | \
56 $(AWK) 'BEGIN { FS=":"; OFS="\t"; } /^[a-zA-Z0-9_]/ \
57 { print $$3, $$0 }' - | $(MAKEDBM-S) - master.passwd.byuid; \
58 $(TOUCH) $(@); \
59 $(ECHO) "updated passwd"; \
60 if [ ! $(NOPUSH) ]; then \
61 $(YPPUSH) -d $(DOMAIN) passwd.byname; \
62 $(YPPUSH) -d $(DOMAIN) passwd.byuid; \
63 $(YPPUSH) -d $(DOMAIN) master.passwd.byname; \
64 $(YPPUSH) -d $(DOMAIN) master.passwd.byuid; \
65 $(ECHO) "pushed passwd"; \
66 else \
67 : ; \
68 fi \
69 else \
70 $(ECHO) "couldn't find $(>)"; \
71 fi
72
73
74 group.time: $(DIR)/group
75 -@if [ -f $(>) ]; then \
76 $(AWK) 'BEGIN { FS=":"; OFS="\t"; } /^[a-zA-Z0-9_]/ \
77 { print $$1, $$0 }' $(>) | \
78 $(MAKEDBM) - group.byname; \
79 $(AWK) 'BEGIN { FS=":"; OFS="\t"; } /^[a-zA-Z0-9_]/ \
80 { print $$3, $$0 }' $(>) | \
81 $(MAKEDBM) - group.bygid; \
82 $(TOUCH) $(@); \
83 $(ECHO) "updated group"; \
84 if [ ! $(NOPUSH) ]; then \
85 $(YPPUSH) -d $(DOMAIN) group.byname; \
86 $(YPPUSH) -d $(DOMAIN) group.bygid; \
87 $(ECHO) "pushed group"; \
88 else \
89 : ; \
90 fi \
91 else \
92 $(ECHO) "couldn't find $(>)"; \
93 fi
94
95 hosts.time: $(DIR)/hosts
96 -@if [ -f $(DIR)/hosts ]; then \
97 $(STDHOSTS) $(>) | $(SED) -e s/#.*$$// | \
98 $(AWK) '{for (i = 2; i <= NF; i++) print $$i, $$0 }' | \
99 $(MAKEDBM) - hosts.byname; \
100 $(STDHOSTS) $(>) | \
101 $(AWK) 'BEGIN { OFS="\t"; } { print $$1, $$0 }' | \
102 $(MAKEDBM) - hosts.byaddr; \
103 $(TOUCH) $(@); \
104 $(ECHO) "updated hosts"; \
105 if [ ! $(NOPUSH) ]; then \
106 $(YPPUSH) -d $(DOMAIN) hosts.byname; \
107 $(YPPUSH) -d $(DOMAIN) hosts.byaddr; \
108 $(ECHO) "pushed hosts"; \
109 else \
110 : ; \
111 fi \
112 else \
113 $(ECHO) "couldn't find $(>)"; \
114 fi
115
116 ethers.time: $(DIR)/ethers
117 -@if [ -f $(DIR)/ethers ]; then \
118 $(STDETHERS) $(>) | $(SED) -e s/#.*$$// | \
119 $(AWK) 'BEGIN { FS="\t"; OFS="\t"; } { print $$1, $$0 }' | \
120 $(MAKEDBM) - ethers.byaddr; \
121 $(STDETHERS) $(>) | \
122 $(AWK) 'BEGIN { FS="\t"; OFS="\t"; } { print $$2, $$0 }' | \
123 $(MAKEDBM) - ethers.byname; \
124 $(TOUCH) $(@); \
125 $(ECHO) "updated ethers"; \
126 if [ ! $(NOPUSH) ]; then \
127 $(YPPUSH) -d $(DOMAIN) ethers.byaddr; \
128 $(YPPUSH) -d $(DOMAIN) ethers.byname; \
129 $(ECHO) "pushed ethers"; \
130 else \
131 : ; \
132 fi \
133 else \
134 $(ECHO) "couldn't find $(>)"; \
135 fi
136
137 networks.time: $(DIR)/networks
138 -@if [ -f $(>) ]; then \
139 $(SED) -e "/^#/d" -e s/#.*$$// $(>) | \
140 $(AWK) '{print $$1, $$0; for (i = 3;i <= NF;i++) print $$i,$$0}' | \
141 $(MAKEDBM) - networks.byname; \
142 $(AWK) 'BEGIN { OFS="\t"; } $$1 !~ /^#/ { print $$2, $$0 }' $(>) | \
143 $(MAKEDBM) - networks.byaddr; \
144 $(TOUCH) $(@); \
145 $(ECHO) "updated networks"; \
146 if [ ! $(NOPUSH) ]; then \
147 $(YPPUSH) -d $(DOMAIN) networks.byname; \
148 $(YPPUSH) -d $(DOMAIN) networks.byaddr; \
149 $(ECHO) "pushed networks"; \
150 else \
151 : ; \
152 fi \
153 else \
154 $(ECHO) "couldn't find $(>)"; \
155 fi
156
157 rpc.time: $(DIR)/rpc
158 -@if [ -f $(>) ]; then \
159 $(AWK) 'BEGIN { OFS="\t"; } $$1 !~ /^#/ { print $$2, $$0 }' $(>) | \
160 $(MAKEDBM) - rpc.bynumber; \
161 $(SED) -e "/^#/d" -e s/#.*$$// $(>) | \
162 $(AWK) '{print $$1, $$0; for (i = 3;i <= NF;i++) print $$i,$$0}' | \
163 $(MAKEDBM) - rpc.byname; \
164 $(TOUCH) $(@); \
165 $(ECHO) "updated rpc"; \
166 if [ ! $(NOPUSH) ]; then \
167 $(YPPUSH) -d $(DOMAIN) rpc.bynumber; \
168 $(YPPUSH) -d $(DOMAIN) rpc.byname; \
169 $(ECHO) "pushed rpc"; \
170 else \
171 : ; \
172 fi \
173 else \
174 $(ECHO) "couldn't find $(>)"; \
175 fi
176
177
178 services.time: $(DIR)/services
179 -@if [ -f $(>) ]; then \
180 $(AWK) 'BEGIN { OFS="\t"; } $$1 !~ /^#/ { print $$2, $$0 }' $(>) | \
181 $(MAKEDBM) - services.byname; \
182 $(TOUCH) $(@); \
183 $(ECHO) "updated services"; \
184 if [ ! $(NOPUSH) ]; then \
185 $(YPPUSH) -d $(DOMAIN) services.byname; \
186 $(ECHO) "pushed services"; \
187 else \
188 : ; \
189 fi \
190 else \
191 $(ECHO) "couldn't find $(>)"; \
192 fi
193
194
195 protocols.time: $(DIR)/protocols
196 -@if [ -f $(>) ]; then \
197 $(AWK) 'BEGIN { OFS="\t"; } $$1 !~ /^#/ { print $$2, $$0 }' $(>) | \
198 $(MAKEDBM) - protocols.bynumber; \
199 $(SED) -e "/^#/d" -e s/#.*$$// $(>) | \
200 $(AWK) '{print $$1, $$0; for (i = 3;i <= NF;i++) print $$i,$$0}' | \
201 $(MAKEDBM) - protocols.byname; \
202 $(TOUCH) $(@); \
203 $(ECHO) "updated protocols"; \
204 if [ ! $(NOPUSH) ]; then \
205 $(YPPUSH) -d $(DOMAIN) protocols.bynumber; \
206 $(YPPUSH) -d $(DOMAIN) protocols.byname; \
207 $(ECHO) "pushed protocols"; \
208 else \
209 : ; \
210 fi \
211 else \
212 $(ECHO) "couldn't find $(>)"; \
213 fi
214
215
216 netid.time: $(DIR)/passwd $(DIR)/group $(DIR)/hosts $(DIR)/netid
217 -@$(MKNETID) -q -d $(DOMAIN) -p $(DIR)/passwd -g $(DIR)/group -h $(DIR)/hosts -m $(DIR)/netid | \
218 $(MAKEDBM) - netid.byname; \
219 $(TOUCH) $(@); \
220 $(ECHO) "updated netid"; \
221 if [ ! $(NOPUSH) ]; then \
222 $(YPPUSH) -d $(DOMAIN) netid.byname; \
223 $(ECHO) "pushed netid"; \
224 else \
225 : ; \
226 fi
227
228
229 netgroup.time: $(DIR)/netgroup
230 -@if [ -f $(>) ]; then \
231 $(CAT) $(>) | $(MAKEDBM) - netgroup; \
232 $(CAT) $(>) | $(REVNETGROUP) -u -f - | \
233 $(MAKEDBM) - netgroup.byuser; \
234 $(CAT) $(>) | $(REVNETGROUP) -h -f - | \
235 $(MAKEDBM) - netgroup.byhost; \
236 $(TOUCH) $(@); \
237 $(ECHO) "updated netgroup"; \
238 if [ ! $(NOPUSH) ]; then \
239 $(YPPUSH) -d $(DOMAIN) netgroup; \
240 $(YPPUSH) -d $(DOMAIN) netgroup.byuser; \
241 $(YPPUSH) -d $(DOMAIN) netgroup.byhost; \
242 $(ECHO) "pushed netgroup"; \
243 else \
244 : ; \
245 fi \
246 else \
247 $(ECHO) "couldn't find $(>)"; \
248 fi
249
250
251 amd.home.time: $(AMDDIR)/amd.home
252 -@if [ -f $(>) ]; then \
253 $(SED) -e "s/#.*$$//" -e "/^$$/d" $(>) | \
254 $(AWK) '{ \
255 for (i = 1; i <= NF; i++) \
256 if (i == NF) { \
257 if (substr($$i, length($$i), 1) == "\\") { \
258 printf("%s", substr($$i, 1, length($$i) - 1)); \
259 } \
260 else \
261 printf("%s\n", $$i); \
262 } \
263 else \
264 printf("%s ", $$i); \
265 }' | \
266 $(MAKEDBM) - amd.home; \
267 $(TOUCH) $(@); \
268 $(ECHO) "updated amd.home"; \
269 if [ ! $(NOPUSH) ]; then \
270 $(YPPUSH) -d $(DOMAIN) amd.home; \
271 $(ECHO) "pushed amd.home"; \
272 else \
273 : ; \
274 fi \
275 else \
276 $(ECHO) "couldn't find $(>)"; \
277 fi
278
279
280 aliases.time: $(DIR)/aliases
281 -@if [ -f $(>) ]; then \
282 $(CP) -p $(>) $(DOMAIN)-aliases; \
283 $(SENDMAIL) -bi -oA$(PWD)/$(DOMAIN)-aliases; \
284 $(MAKEDBM) -U $(DOMAIN)-aliases | $(MAKEDBM) - mail.aliases; \
285 $(MKALIAS) mail.aliases mail.byaddr; \
286 $(TOUCH) $(@); \
287 $(RM) $(DOMAIN)-aliases.db $(DOMAIN)-aliases; \
288 $(ECHO) "updated aliases"; \
289 if [ ! $(NOPUSH) ]; then \
290 $(YPPUSH) -d $(DOMAIN) mail.aliases; \
291 $(YPPUSH) -d $(DOMAIN) mail.byaddr; \
292 $(ECHO) "pushed aliases"; \
293 else \
294 : ; \
295 fi \
296 else \
297 $(ECHO) "couldn't find $(>)"; \
298 fi
299
300
301
302 passwd: passwd.time
303 group: group.time
304 hosts: hosts.time
305 ethers: ethers.time
306 networks: networks.time
307 rpc: rpc.time
308 services: services.time
309 protocols: protocols.time
310 netid: netid.time
311 netgroup: netgroup.time
312 amd.home: amd.home.time
313 aliases: aliases.time
314 $(DIR)/passwd:
315 $(DIR)/group:
316 $(DIR)/hosts:
317 $(DIR)/ethers:
318 $(DIR)/networks:
319 $(DIR)/rpc:
320 $(DIR)/services:
321 $(DIR)/protocols:
322 $(DIR)/netid:
323 $(DIR)/master.passwd:
324 $(DIR)/netgroup:
325 $(DIR)/aliases:
326 $(AMDDIR)/amd.home: