aboutsummaryrefslogtreecommitdiffstats
path: root/testing/rmilter/rmilter.initd
blob: 10ea136d36fcce9bea36bdd0efe4337520729a49 (plain)
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
#!/sbin/openrc-run

description="Rapid spam defence mail filter"
user=${user:-rmilter}
group=${group:-rmilter}
cfgfile=${cfgfile:-/etc/rmilter/rmilter.conf}
pidfile=$(grep pidfile $cfgfile | cut -d = -f 2 | sed 's/[ ;]//g')
pidfile=${pidfile:-/run/rmilter/rmilter.pid}
sockfile=$(grep bind_socket $cfgfile | grep unix: | cut -d : -f 2 | sed 's/[ ;]//g')
command=/usr/sbin/rmilter
command_args="-c $cfgfile"
required_files="$cfgfile"
extra_started_commands="reload"
description_reload="Reload configuration"

depend() {
	need net dns localmount
	use logger antivirus antispam
}

start_pre() {
	ebegin
	checkpath --directory --mode 750 --owner $user:$group ${pidfile%/*}
	if [ "$sockfile" ]; then
		checkpath --directory --mode 750 --owner $user:$group ${sockfile%/*}
		rm -f $sockfile
	fi
	eend $?
}

start() {
	ebegin "Starting ${SVCNAME}"
	start-stop-daemon --start \
		--user $user \
		--group $group \
		--pidfile $pidfile \
		--exec $command -- $command_args
	eend $?
}

reload() {
	ebegin "Reloading ${SVCNAME}"
	start-stop-daemon --signal USR1 --pidfile $pidfile
	eend $?
}