File: courier.sysvinit.in

package info (click to toggle)
courier 1.0.6-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, sid
  • size: 49,084 kB
  • sloc: ansic: 126,176; cpp: 24,278; sh: 8,957; perl: 4,127; makefile: 3,192; sed: 16
file content (279 lines) | stat: -rw-r--r-- 4,903 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
#! @SHELL@
#
# chkconfig: 2345 35 65
# description: Courier - SMTP server
#
# NOTE: The 'restart' here does a "hard" stop, and a start.  Be gentle, use
# "courierd restart" for a kindler, gentler, restart.
#
#

prefix="@prefix@"
exec_prefix="@exec_prefix@"
datarootdir="@datarootdir@"
sysconfdir="@sysconfdir@"
sbindir="@sbindir@"
bindir="@bindir@"
libexecdir="@libexecdir@"
datadir="@datadir@"

if test ! -f ${sysconfdir}/esmtpd
then
	echo "${sysconfdir}/esmtpd does not exist, forgot make install-configure?"
	exit 1
fi

case "$1" in
start)
        cd /
        # Start daemons.
        touch /var/lock/subsys/courier

        echo -n "Starting Courier mail server:"

	# Use default DH parameter file, if it does not exist.

	if test ! -f ${datadir}/dhparams.pem
	then
	    ln ${datadir}/dhparams.pem.dist ${datadir}/dhparams.pem
	fi

	# First time after install create aliases.dat and makesmtpaccess.dat

	test -f ${sysconfdir}/aliases.dat || ${sbindir}/makealiases

	esmtpdcert=0

	. ${sysconfdir}/esmtpd
	case x$ESMTPDSTART in
	x[yY]*)
		esmtpdcert=1
		;;
	esac

	test -f ${ACCESSFILE}.dat || ${sbindir}/makesmtpaccess

	. ${sysconfdir}/esmtpd-msa
	case x$ESMTPDSTART in
	x[yY]*)
		esmtpdcert=1
		;;
	esac

	test -f ${ACCESSFILE}.dat || ${sbindir}/makesmtpaccess-msa

	${sbindir}/courierfilter start
	echo -n " courierfilter"

	if test -x ${sbindir}/courierldapaliasd
	then
		${sbindir}/courierldapaliasd start
		echo -n " courierldapaliasd"
	fi

	if test -f ${libexecdir}/courier/sqwebmaild
	then
		${sbindir}/webmaild start
		echo -n " webmail"
	fi

	${sbindir}/courier start
        echo -n " courierd"

	if test "$esmtpdcert" = 1
	then
# If we do not have a certificate, make one up.

		if test ! -f ${datadir}/esmtpd.pem
		then
			if test -x $COURIERTLS
			then
				echo -n " generating-ESMTP-SSL-certificate..."
				${sbindir}/mkesmtpdcert >/dev/null 2>&1
			fi
		fi
	fi

	. ${sysconfdir}/esmtpd
	case x$ESMTPDSTART in
	x[yY]*)

		${sbindir}/esmtpd start
		echo -n " esmtpd"
		;;
	esac

	. ${sysconfdir}/esmtpd-msa
	case x$ESMTPDSTART in
	x[yY]*)

		${sbindir}/esmtpd-msa start
		echo -n " esmtpd-msa"
		;;
	esac

	if test -f ${sysconfdir}/esmtpd-ssl
	then
		. ${sysconfdir}/esmtpd-ssl
	fi
	case x$ESMTPDSSLSTART in
	x[yY]*)
		if test -x $COURIERTLS
		then
			${sbindir}/esmtpd-ssl start
			echo -n " esmtpd-ssl"
		fi
		;;
	esac

	if test -x ${sbindir}/pop3d
	then
		POP3DSTART=""
		POP3DSSLSTART=""

		if test -f ${sysconfdir}/pop3d
		then
			. ${sysconfdir}/pop3d
		fi
		case x$POP3DSTART in
		x[yY]*)
			${sbindir}/pop3d start
			echo -n " pop3d"
			;;
		esac
		if test -f ${sysconfdir}/pop3d-ssl
		then
			. ${sysconfdir}/pop3d-ssl
		fi
		case x$POP3DSSLSTART in
		x[yY]*)
			if test -x $COURIERTLS
			then
# If we do not have a certificate, make one up.

				if test ! -f ${datadir}/pop3d.pem
				then
					echo -n " generating-POP3-SSL-certificate..."

					${sbindir}/mkpop3dcert >/dev/null 2>&1
				fi

				${sbindir}/pop3d-ssl start && \
					echo -n " pop3d-ssl"
			fi
			;;
		esac
	fi

	if test -x ${sbindir}/imapd
	then
		. ${sysconfdir}/imapd
		case x$IMAPDSTART in
		x[yY]*)
			${sbindir}/imapd start
			echo -n " imapd"
			;;
		esac
		. ${sysconfdir}/imapd-ssl
		case x$IMAPDSSLSTART in
		x[yY]*)
			if test -x $COURIERTLS
			then
# If we do not have a certificate, make one up.

				if test ! -f ${datadir}/imapd.pem
				then
					echo -n " generating-IMAP-SSL-certificate..."

					${sbindir}/mkimapdcert >/dev/null 2>&1
				fi

				${sbindir}/imapd-ssl start && \
					echo -n " imapd-ssl"
			fi
			;;
		esac
	fi

	if test -x ${bindir}/webmlmd
	then
		. ${sysconfdir}/webmlmrc
		if test "$LISTS" != ""
		then
			${bindir}/webmlmd start ${sysconfdir}/webmlmrc && \
				echo -n " webmlmd"
		fi
	fi
	echo ""
        ;;
stop)
        echo -n "Stopping Courier mail server:"

	if test -x ${bindir}/webmlmd
	then
		${bindir}/webmlmd stop ${sysconfdir}/webmlmrc
		echo -n " webmlmd"
	fi

	if test -x ${sbindir}/imapd
	then
		${sbindir}/imapd stop
		echo -n " imapd"
	fi

	if test -x ${sbindir}/imapd-ssl
	then
		${sbindir}/imapd-ssl stop
		echo -n " imapd-ssl"
	fi

	${sbindir}/esmtpd-ssl stop
	echo -n " esmtpd-ssl"

	${sbindir}/esmtpd-msa stop
	echo -n " esmtpd-msa"

	${sbindir}/esmtpd stop
	echo -n " esmtpd"

	if test -x ${sbindir}/pop3d
	then
		${sbindir}/pop3d stop
		echo -n " pop3d"
	fi

	if test -x ${sbindir}/pop3d-ssl
	then
		${sbindir}/pop3d-ssl stop
		echo -n " pop3d-ssl"
	fi

	${sbindir}/courier stop
	echo -n " courierd"


	if test -f ${libexecdir}/courier/sqwebmaild
	then
		${sbindir}/webmaild stop
		echo -n " webmail"
	fi

	if test -x ${sbindir}/courierldapaliasd
	then
		${sbindir}/courierldapaliasd stop
		echo -n " courierldapaliasd"
	fi

	${sbindir}/courierfilter stop
	echo " courierfilter"
        rm -f /var/lock/subsys/courier
	;;
restart)
	$0 stop
	$0 start
        ;;
condrestart)
	test -f /var/lock/subsys/courier && $0 restart || :
	;;
esac
exit 0