#!/sbin/openrc-run # Copyright 1999-2018 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 RSPAMD_USER="${RSPAMD_USER:-rspamd}" RSPAMD_GROUP="${RSPAMD_GROUP:-rspamd}" RSPAMD_CONFIG="${RSPAMD_CONFIG:-/etc/rspamd/rspamd.conf}" RSPAMD_RUNDIR="${RSPAMD_RUNDIR:-/run/rspamd}" extra_commands="checkconfig" extra_started_commands="reload" pidfile="/run/${RC_SVCNAME}.pid" command="/usr/bin/rspamd" command_args="-p ${pidfile} -u ${RSPAMD_USER} -g ${RSPAMD_GROUP} ${RSPAMD_OPTS}" required_files="${RSPAMD_CONFIG}" retry="${retry:-TERM/30/KILL/5}" start_stop_daemon_args="${SSD_OPTS}" depend() { need net } start_pre() { checkpath -d -m 2750 -o "${RSPAMD_USER}:${RSPAMD_GROUP}" "${RSPAMD_RUNDIR}" rm -f "${RSPAMD_RUNDIR}"/*.sock if [ "${RC_CMD}" != "restart" ]; then checkconfig || return 1 fi } stop_pre() { if [ "${RC_CMD}" = "restart" ]; then checkconfig || return 1 fi } reload() { checkconfig || return 1 ebegin "Reloading ${RC_SVCNAME}" start-stop-daemon --signal HUP --pidfile "${pidfile}" eend $? "Failed to reload ${RC_SVCNAME}" } checkconfig() { ebegin "Checking ${RC_SVCNAME} configuration" if ! /usr/bin/rspamadm configtest -c "${RSPAMD_CONFIG}" >/dev/null 2>&1; then /usr/bin/rspamadm configtest -c "${RSPAMD_CONFIG}" fi eend $? "Failed, please correct the errors above" }