mail-filter/rspamd: bump to v1.8.3
[gentoo.git] / mail-filter / rspamd / files / rspamd-r6.init
1 #!/sbin/openrc-run
2 # Copyright 2015-2019 Gentoo Authors
3 # Distributed under the terms of the GNU General Public License v2
4
5 RSPAMD_CONFIGFILE=${RSPAMD_CONFIGFILE:-"/etc/rspamd/rspamd.conf"}
6 RSPAMD_GROUP=${RSPAMD_GROUP:-rspamd}
7 RSPAMD_OPTS=${RSPAMD_OPTS:-""}
8 RSPAMD_PIDFILE=${RSPAMD_PIDFILE:-"/run/rspamd.pid"}
9 RSPAMD_USER=${RSPAMD_USER:-rspamd}
10
11 command="/usr/bin/rspamd"
12 command_args="${RSPAMD_OPTS} -c \"${RSPAMD_CONFIGFILE}\" -u ${RSPAMD_USER} -g ${RSPAMD_GROUP} --pid \"${RSPAMD_PIDFILE}\""
13 start_stop_daemon_args=${RSPAMD_SSDARGS:-"--wait 1000"}
14 pidfile="${RSPAMD_PIDFILE}"
15 retry=${RSPAMD_TERMTIMEOUT:-"TERM/60/KILL/5"}
16
17 required_files="${RSPAMD_CONFIGFILE}"
18
19 description="Rapid spam filtering system"
20
21 extra_commands="checkconfig"
22 extra_started_commands="reload"
23
24 description_checkconfig="Validate rspamd's configuration"
25 description_reload="Sends rspamd a signal to reload its configuration"
26
27 depend() {
28         before mta
29         use dns redis
30 }
31
32 checkconfig() {
33         ${command} -c "${RSPAMD_CONFIGFILE}" -u ${RSPAMD_USER} -g ${RSPAMD_GROUP} -t 1>/dev/null \
34                 || return 1
35 }
36
37 reload() {
38         checkconfig || return 1
39
40         ebegin "Reloading ${SVCNAME}"
41         start-stop-daemon --signal HUP --pidfile "${pidfile}"
42         eend $?
43 }
44
45 start_pre() {
46         if [ "${RC_CMD}" != "restart" ]; then
47                 checkconfig || return 1
48         fi
49 }
50
51 stop_pre() {
52         if [ "${RC_CMD}" = "restart" ]; then
53                 checkconfig || return 1
54         fi
55 }