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