2013-05-25 14:44:33 +02:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# rspamd - this script starts and stops the rspamd daemon
|
2013-12-19 18:51:53 +01:00
|
|
|
### BEGIN INIT INFO
|
|
|
|
# Provides: rspamd
|
|
|
|
# Required-Start: $remote_fs $network
|
|
|
|
# Required-Stop: $network $remote_fs
|
|
|
|
# Default-Start: 5
|
|
|
|
# Default-Stop:
|
|
|
|
# Short-Description: Rspamd daemon
|
|
|
|
# Description: Rspamd spam filtering daemon process
|
|
|
|
### END INIT INFO
|
2013-05-25 14:44:33 +02:00
|
|
|
#
|
|
|
|
# chkconfig: - 85 15
|
|
|
|
# description: rspamd is a spam filtering system
|
|
|
|
# processname: rspamd
|
2015-03-07 11:53:16 +01:00
|
|
|
# config: /etc/rspamd/rspamd.sysvinit.conf
|
2013-05-25 14:44:33 +02:00
|
|
|
# config: /etc/sysconfig/rspamd
|
|
|
|
# pidfile: /var/run/rspamd/rspamd.pid
|
|
|
|
|
|
|
|
# Source function library.
|
|
|
|
. /etc/rc.d/init.d/functions
|
|
|
|
|
|
|
|
# Source networking configuration.
|
|
|
|
. /etc/sysconfig/network
|
|
|
|
|
|
|
|
# Check that networking is up.
|
|
|
|
[ "$NETWORKING" = "no" ] && exit 0
|
|
|
|
|
|
|
|
rspamd="/usr/bin/rspamd"
|
|
|
|
prog=$(basename $rspamd)
|
|
|
|
|
2015-03-07 11:53:16 +01:00
|
|
|
RSPAMD_CONF_FILE="/etc/rspamd/rspamd.sysvinit.conf"
|
2015-03-11 18:34:11 +01:00
|
|
|
RSPAMD_USER="_rspamd"
|
|
|
|
RSPAMD_GROUP="_rspamd"
|
2013-05-25 14:44:33 +02:00
|
|
|
|
|
|
|
[ -f /etc/sysconfig/rspamd ] && . /etc/sysconfig/rspamd
|
|
|
|
|
|
|
|
lockfile=/var/lock/subsys/rspamd
|
|
|
|
|
|
|
|
start() {
|
|
|
|
[ -x $rspamd ] || exit 5
|
|
|
|
[ -f $rspamd_CONF_FILE ] || exit 6
|
|
|
|
echo -n $"Starting $prog: "
|
|
|
|
daemon $rspamd -c $RSPAMD_CONF_FILE -u $RSPAMD_USER -g $RSPAMD_GROUP
|
|
|
|
retval=$?
|
|
|
|
echo
|
|
|
|
[ $retval -eq 0 ] && touch $lockfile
|
|
|
|
return $retval
|
|
|
|
}
|
|
|
|
|
|
|
|
stop() {
|
|
|
|
echo -n $"Stopping $prog: "
|
2013-05-26 22:06:42 +02:00
|
|
|
killproc $prog -TERM
|
2013-05-25 14:44:33 +02:00
|
|
|
retval=$?
|
|
|
|
if [ $retval -eq 0 ]; then
|
|
|
|
if [ "$CONSOLETYPE" != "serial" ]; then
|
|
|
|
echo -en "\\033[16G"
|
|
|
|
fi
|
|
|
|
while rh_status_q
|
|
|
|
do
|
|
|
|
sleep 1
|
|
|
|
echo -n $"."
|
|
|
|
done
|
|
|
|
rm -f $lockfile
|
|
|
|
fi
|
|
|
|
echo
|
|
|
|
return $retval
|
|
|
|
}
|
|
|
|
|
|
|
|
restart() {
|
|
|
|
configtest || return $?
|
|
|
|
stop
|
|
|
|
start
|
|
|
|
}
|
|
|
|
|
|
|
|
reload() {
|
|
|
|
configtest || return $?
|
|
|
|
echo -n $"Reloading $prog: "
|
|
|
|
killproc $rspamd -HUP
|
|
|
|
RETVAL=$?
|
|
|
|
echo
|
|
|
|
}
|
|
|
|
|
|
|
|
force_reload() {
|
|
|
|
restart
|
|
|
|
}
|
|
|
|
|
|
|
|
configtest() {
|
2015-02-01 04:17:51 +01:00
|
|
|
$rspamd -u $RSPAMD_USER -g $RSPAMD_GROUP -t -c $RSPAMD_CONF_FILE
|
2013-05-25 14:44:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
rh_status() {
|
|
|
|
status $prog
|
|
|
|
}
|
|
|
|
|
|
|
|
rh_status_q() {
|
|
|
|
rh_status >/dev/null 2>&1
|
|
|
|
}
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
start)
|
|
|
|
rh_status_q && exit 0
|
|
|
|
$1
|
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
rh_status_q || exit 0
|
|
|
|
$1
|
|
|
|
;;
|
|
|
|
restart|configtest)
|
|
|
|
$1
|
|
|
|
;;
|
|
|
|
reload)
|
|
|
|
rh_status_q || exit 7
|
|
|
|
$1
|
|
|
|
;;
|
|
|
|
force-reload)
|
|
|
|
force_reload
|
|
|
|
;;
|
|
|
|
status)
|
|
|
|
rh_status
|
|
|
|
;;
|
|
|
|
condrestart|try-restart)
|
|
|
|
rh_status_q || exit 0
|
2015-03-12 14:28:25 +01:00
|
|
|
restart
|
2013-05-25 14:44:33 +02:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
|
|
|
|
exit 2
|
|
|
|
esac
|