ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/mports/trunk/mail/courier/files/courier.in
Revision: 16349
Committed: Sun Apr 20 18:32:36 2014 UTC (10 years ago) by laffer1
File size: 7760 byte(s)
Log Message:
remove cvs2svn:cvs-rev prop

File Contents

# Content
1 #!/bin/sh
2 #
3 # $FreeBSD$
4 #
5 # Adapted for FreeBSD from courier.sysvinit
6 #
7 # NOTE: The 'restart' here does a "hard" stop, and a start. Be gentle, use
8 # "courierd restart" for a kindler, gentler, restart.
9 #
10 # PROVIDE: mail
11 # REQUIRE: LOGIN courier_authdaemond
12 # BEFORE: securelevel
13 # KEYWORD: shutdown
14
15 prefix="%%PREFIX%%"
16 exec_prefix="${prefix}"
17 sysconfdir="${prefix}/etc/courier"
18 sbindir="${exec_prefix}/sbin"
19 bindir="${exec_prefix}/bin"
20 libexecdir="${prefix}/libexec"
21 datadir="${prefix}/share/courier"
22
23 # Define these courier_* variables in one of these files:
24 # /etc/rc.conf
25 # /etc/rc.conf.local
26 # /etc/rc.conf.d/courier
27 #
28 # DO NOT CHANGE THESE DEFAULT VALUES HERE
29 #
30 courier_enable=${courier_enable:-"NO"} # Run Courier-MTA (YES/NO).
31
32 . /etc/rc.subr
33
34 name="courier"
35 rcvar=courier_enable
36
37 start_precmd="${name}_prestart"
38 start_cmd="${name}_start"
39 stop_cmd="${name}_stop"
40 extra_commands="restart"
41
42 courier_prestart()
43 { # Ensure runtime directories exist with correct permissions
44 /usr/bin/install -o %%BINOWN%% -g %%BINGRP%% -m 0755 -d %%LOCALSTATEDIR%%
45 /usr/bin/install -o %%MAILOWN%% -g %%MAILGRP%% -m 0750 -d %%LOCALSTATEDIR%%/allfilters
46 /usr/bin/install -o %%MAILOWN%% -g %%MAILGRP%% -m 0700 -d %%LOCALSTATEDIR%%/faxtmp
47 /usr/bin/install -o %%MAILOWN%% -g %%MAILGRP%% -m 0750 -d %%LOCALSTATEDIR%%/filters
48 /usr/bin/install -o %%MAILOWN%% -g %%MAILGRP%% -m 0750 -d %%LOCALSTATEDIR%%/msgq
49 /usr/bin/install -o %%MAILOWN%% -g %%MAILGRP%% -m 0750 -d %%LOCALSTATEDIR%%/msgs
50 /usr/bin/install -o %%MAILOWN%% -g %%MAILGRP%% -m 0770 -d %%LOCALSTATEDIR%%/tmp
51 /usr/bin/install -o %%MAILOWN%% -g %%MAILGRP%% -m 0755 -d %%LOCALSTATEDIR%%/track
52 /usr/bin/install -o %%MAILOWN%% -g %%MAILGRP%% -m 0400 -c /dev/null %%LOCALSTATEDIR%%/.noident
53
54 /usr/bin/install -o %%BINOWN%% -g %%BINGRP%% -m 0755 -d %%CALENDIR%%
55 /usr/bin/install -o %%CACHEOWN%% -g %%MAILGRP%% -m 0700 -d %%CALENDIR%%/localcache
56 /usr/bin/install -o %%CACHEOWN%% -g %%MAILGRP%% -m 0750 -d %%CALENDIR%%/private
57 /usr/bin/install -o %%CACHEOWN%% -g %%MAILGRP%% -m 0755 -d %%CALENDIR%%/public
58
59 /usr/bin/install -o %%CACHEOWN%% -g mail -m 0700 -d %%CACHEDIR%%
60 }
61
62 courier_start()
63 { # First time after install create aliases.dat and makesmtpaccess.dat
64 echo -n "Starting"
65
66 if [ -f ${sysconfdir}/crontab ]; then
67 /usr/bin/crontab -u %%CACHEOWN%% ${sysconfdir}/crontab
68 fi
69
70 if [ ! -f ${sysconfdir}/aliases.dat \
71 -a -x ${sbindir}/makealiases ]; then
72 ${sbindir}/makealiases
73 fi
74
75 esmtpdcert=0
76
77 ESMTPDSTART=""
78 if [ -f ${sysconfdir}/esmtpd ]; then
79 . ${sysconfdir}/esmtpd
80 case "$ESMTPDSTART" in
81 [Yy]*)
82 esmtpdcert=1
83 ;;
84 esac
85 if [ ! -f ${sysconfdir}/esmtpacceptmailfor.dat \
86 -a -x ${sbindir}/makeacceptmailfor ]; then
87 ${sbindir}/makeacceptmailfor
88 fi
89 if [ ! -f ${sysconfdir}/${ACCESSFILE}.dat \
90 -a -x ${sbindir}/makesmtpaccess ]; then
91 ${sbindir}/makesmtpaccess
92 fi
93 fi
94
95 ESMTPDSTART=""
96 if [ -f ${sysconfdir}/esmtpd-msa ]; then
97 . ${sysconfdir}/esmtpd-msa
98 case "$ESMTPDSTART" in
99 [Yy]*)
100 esmtpdcert=1
101 ;;
102 esac
103 if [ ! -f ${sysconfdir}/${ACCESSFILE}.dat \
104 -a -x ${sbindir}/makesmtpaccess-msa ]; then
105 ${sbindir}/makesmtpaccess-msa
106 fi
107 fi
108
109 if [ -x ${sbindir}/courierfilter ]; then
110 echo -n " courierfilter"
111 ${sbindir}/courierfilter start
112 fi
113
114 if [ -x ${sbindir}/courierldapaliasd ]; then
115 echo -n " courierldapaliasd"
116 ${sbindir}/courierldapaliasd start
117 fi
118
119 if [ -x ${libexecdir}/courier/sqwebmaild \
120 -a -x ${sbindir}/webmaild ]; then
121 echo -n " webmail"
122 ${sbindir}/webmaild start
123 fi
124
125 if [ -x ${sbindir}/courier ]; then
126 echo -n " courierd"
127 ${sbindir}/courier start
128 fi
129
130 if [ "$esmtpdcert" = 1 ]; then
131 # If we do not have a certificate, make one up.
132 if [ ! -f ${sysconfdir}/esmtpd.pem \
133 -a -x "$COURIERTLS" \
134 -a -x ${sbindir}/mkesmtpdcert ]; then
135 echo -n " generating-ESMTP-SSL-certificate..."
136 ${sbindir}/mkesmtpdcert >/dev/null 2>&1
137 fi
138 fi
139
140 ESMTPDSTART=""
141 if [ -f ${sysconfdir}/esmtpd ]; then
142 . ${sysconfdir}/esmtpd
143 case "$ESMTPDSTART" in
144 [Yy]*)
145 if [ -x ${sbindir}/esmtpd ]; then
146 echo -n " esmtpd"
147 ${sbindir}/esmtpd start
148 fi
149 ;;
150 esac
151 fi
152
153 ESMTPDSTART=""
154 if [ -f ${sysconfdir}/esmtpd-msa ]; then
155 . ${sysconfdir}/esmtpd-msa
156 case "$ESMTPDSTART" in
157 [Yy]*)
158 if [ -x ${sbindir}/esmtpd-msa ]; then
159 echo -n " esmtpd-msa"
160 ${sbindir}/esmtpd-msa start
161 fi
162 ;;
163 esac
164 fi
165
166 ESMTPDSSLSTART=""
167 if [ -f ${sysconfdir}/esmtpd-ssl ]; then
168 . ${sysconfdir}/esmtpd-ssl
169 case "$ESMTPDSSLSTART" in
170 [Yy]*)
171 if [ -x "$COURIERTLS" \
172 -a -x ${sbindir}/esmtpd-ssl ]; then
173 echo -n " esmtpd-ssl"
174 ${sbindir}/esmtpd-ssl start
175 fi
176 ;;
177 esac
178 fi
179
180 IMAPDSTART=""
181 if [ -f ${sysconfdir}/imapd ]; then
182 . ${sysconfdir}/imapd
183 case "$IMAPDSTART" in
184 [Yy]*)
185 if [ -x ${sbindir}/imapd ]; then
186 echo -n " imapd"
187 ${sbindir}/imapd start
188 fi
189 ;;
190 esac
191 fi
192
193 IMAPDSSLSTART=""
194 if [ -f ${sysconfdir}/imapd-ssl ]; then
195 . ${sysconfdir}/imapd-ssl
196 case "$IMAPDSSLSTART" in
197 [Yy]*) # If we do not have a certificate, make one up.
198 if [ -x "$COURIERTLS" ]; then
199 if [ ! -f ${sysconfdir}/imapd.pem \
200 -a -x ${sbindir}/mkimapdcert ]; then
201 echo -n " generating-IMAP-SSL-certificate..."
202 ${sbindir}/mkimapdcert >/dev/null 2>&1
203 fi
204 if [ -x ${sbindir}/imapd-ssl ]; then
205 echo -n " imapd-ssl"
206 ${sbindir}/imapd-ssl start
207 fi
208 fi
209 ;;
210 esac
211 fi
212
213 POP3DSTART=""
214 if [ -f ${sysconfdir}/pop3d ]; then
215 . ${sysconfdir}/pop3d
216 case "$POP3DSTART" in
217 [Yy]*)
218 if [ -x ${sbindir}/pop3d ]; then
219 echo -n " pop3d"
220 ${sbindir}/pop3d start
221 fi
222 ;;
223 esac
224 fi
225
226 POP3DSSLSTART=""
227 if [ -f ${sysconfdir}/pop3d-ssl ]; then
228 . ${sysconfdir}/pop3d-ssl
229 case "$POP3DSSLSTART" in
230 [Yy]*) # If we do not have a certificate, make one up.
231 if [ -x "$COURIERTLS" ]; then
232 if [ ! -f ${sysconfdir}/pop3d.pem \
233 -a -x ${sbindir}/mkpop3dcert ]; then
234 echo -n " generating-POP3-SSL-certificate..."
235 ${sbindir}/mkpop3dcert >/dev/null 2>&1
236 fi
237 if [ -x ${sbindir}/pop3d-ssl ]; then
238 echo -n " pop3d-ssl"
239 ${sbindir}/pop3d-ssl start
240 fi
241 fi
242 ;;
243 esac
244 fi
245
246 LISTS=""
247 if [ -f ${sysconfdir}/webmlmrc ]; then
248 . ${sysconfdir}/webmlmrc
249 if [ -n "$LISTS" \
250 -a -x ${bindir}/webmlmd \
251 -a -x ${bindir}/webmlmd.rc ]; then
252 echo -n " webmlmd"
253 ${bindir}/webmlmd.rc start ${sysconfdir}/webmlmrc
254 fi
255 fi
256 echo "."
257 }
258
259 courier_stop()
260 { # kill courier services in the reverse order of starting them
261 echo -n "Stopping"
262
263 if [ -x ${bindir}/webmlmd \
264 -a -x ${bindir}/webmlmd.rc ]; then
265 echo -n " webmlmd"
266 ${bindir}/webmlmd.rc stop ${sysconfdir}/webmlmrc
267 fi
268
269 if [ -x ${sbindir}/pop3d-ssl ]; then
270 echo -n " pop3d-ssl"
271 ${sbindir}/pop3d-ssl stop
272 fi
273
274 if [ -x ${sbindir}/pop3d ]; then
275 echo -n " pop3d"
276 ${sbindir}/pop3d stop
277 fi
278
279 if [ -x ${sbindir}/imapd-ssl ]; then
280 echo -n " imapd-ssl"
281 ${sbindir}/imapd-ssl stop
282 fi
283
284 if [ -x ${sbindir}/imapd ]; then
285 echo -n " imapd"
286 ${sbindir}/imapd stop
287 fi
288
289 if [ -x ${sbindir}/esmtpd-ssl ]; then
290 echo -n " esmtpd-ssl"
291 ${sbindir}/esmtpd-ssl stop
292 fi
293
294 if [ -x ${sbindir}/esmtpd-msa ]; then
295 echo -n " esmtpd-msa"
296 ${sbindir}/esmtpd-msa stop
297 fi
298
299 if [ -x ${sbindir}/esmtpd ]; then
300 echo -n " esmtpd"
301 ${sbindir}/esmtpd stop
302 fi
303
304 if [ -x ${sbindir}/courier ]; then
305 echo -n " courierd"
306 ${sbindir}/courier stop
307 fi
308
309 if [ -x ${sbindir}/webmaild ]; then
310 echo -n " webmail"
311 ${sbindir}/webmaild stop
312 fi
313
314 if [ -x ${sbindir}/courierldapaliasd ]; then
315 echo -n " courierldapaliasd"
316 ${sbindir}/courierldapaliasd stop
317 fi
318
319 if [ -x ${sbindir}/courierfilter ]; then
320 echo -n " courierfilter"
321 ${sbindir}/courierfilter stop
322 fi
323
324 echo y | /usr/bin/crontab -u %%CACHEOWN%% -r || true
325 echo "."
326 }
327
328 load_rc_config $name
329 run_rc_command "$1"