aboutsummaryrefslogtreecommitdiffstats
path: root/community/rspamd/rspamd.initd
diff options
context:
space:
mode:
authorJakub Jirutka <jakub@jirutka.cz>2018-07-25 02:13:58 +0200
committerJakub Jirutka <jakub@jirutka.cz>2018-07-25 02:52:12 +0200
commit51d7f21cb1cd1b2a475ae0106d93b64d667ee20e (patch)
treeae89197fe85452064df46c340a57e413b44dd6df /community/rspamd/rspamd.initd
parentbfd042a2dfb36acd7c82d37d06e3aaa2759a8225 (diff)
downloadaports-51d7f21cb1cd1b2a475ae0106d93b64d667ee20e.tar.gz
aports-51d7f21cb1cd1b2a475ae0106d93b64d667ee20e.tar.bz2
aports-51d7f21cb1cd1b2a475ae0106d93b64d667ee20e.tar.xz
community/rspamd: rewrite init script, start as unprivileged user
It's init/rc system's job to daemonize process and drop privileges!
Diffstat (limited to 'community/rspamd/rspamd.initd')
-rw-r--r--community/rspamd/rspamd.initd52
1 files changed, 30 insertions, 22 deletions
diff --git a/community/rspamd/rspamd.initd b/community/rspamd/rspamd.initd
index 79e9d0d910..7aaa25a516 100644
--- a/community/rspamd/rspamd.initd
+++ b/community/rspamd/rspamd.initd
@@ -1,46 +1,54 @@
#!/sbin/openrc-run
-description="Rapid spam filtering system"
-
-: ${user:=${RSPAMD_USER:-rspamd}}
-: ${group:=${RSPAMD_GROUP:-rspamd}}
-: ${cfgdir:=${RSPAMD_CONFDIR:-/etc/rspamd}}
-: ${cfgfile:=${RSPAMD_CONFIG:-$cfgdir/rspamd.conf}}
-: ${pidfile:=${RSPAMD_PIDFILE:-/run/$RC_SVCNAME/rspamd.pid}}
-
-command=/usr/sbin/rspamd
-command_args="-u $user -g $group -c $cfgfile -p $pidfile"
-required_files="$cfgfile"
extra_commands="checkconfig"
extra_started_commands="reload reopen"
-description_checkconfig="Verify configuration"
+
+description="Rapid spam filtering system"
+description_checkconfig="Check configuration"
description_reload="Reload configuration"
description_reopen="Reopen log files"
+# Uppercase variables are here for backward compatibility only.
+: ${command_user:="${RSPAMD_USER:-rspamd}:${RSPAMD_GROUP:-rspamd}"}
+: ${cfgfile:=${RSPAMD_CONFIG:-/etc/rspamd/rspamd.conf}}
+: ${startuplog:=${RSPAMD_STARTUPLOG:-/dev/null}}
+
+command="/usr/sbin/rspamd"
+command_args="--config $cfgfile --no-fork ${command_args:-}"
+command_background="yes"
+pidfile="/run/rspamd/$RC_SVCNAME.pid"
+
+required_files="$cfgfile"
+
depend() {
need localmount net
before mta
+ after redis
}
-checkconfig() {
- ebegin "Checking $RC_SVCNAME config"
- $command $command_args -t
- eend $?
+start_pre() {
+ checkpath -d -m 750 -o "$command_user" ${pidfile%/*}
+ checkconfig >/dev/null 2>>"$startuplog" || checkconfig
}
-start_pre() {
- checkpath -d -m 750 -o $user:$group ${pidfile%/*}
- checkconfig >/dev/null 2>>${startuplog:=${RSPAMD_STARTUPLOG:-/dev/null}}
+checkconfig() {
+ ebegin "Checking $name configuration"
+
+ $command $command_args \
+ -u "${command_user%:*}" \
+ -g "${command_user#*:}" \
+ --config-test
+ eend $?
}
reload() {
- ebegin "Reloading $RC_SVCNAME config"
- checkconfig >/dev/null 2>&1 && start-stop-daemon --signal HUP --pidfile $pidfile
+ ebegin "Reloading $name configuration"
+ start_pre && start-stop-daemon --signal HUP --pidfile $pidfile
eend $?
}
reopen() {
- ebegin "Reopening $RC_SVCNAME log files"
+ ebegin "Reopening $name log files"
start-stop-daemon --signal USR1 --pidfile $pidfile
eend $?
}