#!/sbin/runscript # Copyright 1999-2011 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ dspam_user="root:root" depend() { use logger need net before mta after pg_autovacuum postgresql mysql ldap } checkconfig() { if [ ! -f "/etc/mail/dspam/dspam.conf" ] then eerror "You need a DSPAM configuration in /etc/mail/dspam/dspam.conf" return 1 fi if [ -f "/etc/conf.d/${SVCNAME}" ] then if [ -n "${DSPAM_USER_GROUP}" ] then if ! ( getent passwd "${DSPAM_USER_GROUP/:*}" >/dev/null 2>&1 ) then eerror "Specified user '${DSPAM_USER_GROUP/:*}' for DSPAM unknown" return 1 fi if ! ( getent group "${DSPAM_USER_GROUP/*:}" >/dev/null 2>&1 ) then eerror "Specified group '${DSPAM_USER_GROUP/:*}' for DSPAM unknown" return 1 fi dspam_user="${DSPAM_USER_GROUP}" fi fi } start() { checkconfig || return 1 ebegin "Starting DSPAM" start-stop-daemon \ --start \ --quiet \ --background \ --user "${dspam_user}" \ --exec /usr/bin/dspam -- \ --daemon \ --debug eend ${?} } stop() { checkconfig || return 1 local include_conf="$(sed -n "s:^Include[\t ]*[\"']\{0,1\}\([^\"']*\).*:\1:gp" /etc/mail/dspam/dspam.conf)" local DSPAM_PID="$(sed -n "s:^ServerPID[\t ]*[\"']\{0,1\}\([^\"']*\).*:\1:gp" /etc/mail/dspam/dspam.conf ${include_conf[@]}|sed q)" if [ -z "${DSPAM_PID}" -a -f "/var/run/dspam/dspam.pid" ]; then DSPAM_PID="/var/run/dspam/dspam.pid" fi ebegin "Stopping DSPAM" if [ -n "${DSPAM_PID}" -a -f "${DSPAM_PID}" ]; then start-stop-daemon \ --stop \ --quiet \ --pidfile ${DSPAM_PID} eend ${?} else eend 1 "Could not stop DSPAM. No PID file!" fi }