mail-filter/rspamd: version bump to 2.1
[gentoo.git] / mail-filter / rspamd / files / rspamd-r7.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_rspamadm="/usr/bin/rspamadm"
13 command_args="${RSPAMD_OPTS} -c \"${RSPAMD_CONFIGFILE}\" -u ${RSPAMD_USER} -g ${RSPAMD_GROUP} --pid \"${RSPAMD_PIDFILE}\""
14 start_stop_daemon_args=${RSPAMD_SSDARGS:-"--wait 1000"}
15 pidfile="${RSPAMD_PIDFILE}"
16 retry=${RSPAMD_TERMTIMEOUT:-"TERM/60/KILL/5"}
17
18 required_files="${RSPAMD_CONFIGFILE}"
19
20 description="Rapid spam filtering system"
21
22 extra_commands="checkconfig"
23 extra_started_commands="reload"
24
25 description_checkconfig="Validate rspamd's configuration"
26 description_reload="Sends rspamd a signal to reload its configuration"
27
28 depend() {
29         before mta
30         use dns redis
31 }
32
33 checkconfig() {
34         ${command_rspamadm} configtest 1>/dev/null || 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 }