mirror of
https://github.com/Ponce/slackbuilds
synced 2024-12-02 13:04:42 +01:00
f4d72c6502
Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
72 lines
1.2 KiB
Bash
72 lines
1.2 KiB
Bash
#!/bin/sh
|
|
#
|
|
# rspamd startup script for Slackware Linux
|
|
|
|
NAME=rspamd
|
|
DAEMON=/usr/bin/$NAME
|
|
RSPAMADM=/usr/bin/rspamadm
|
|
PIDFILE=/var/run/rspamd/${NAME}.pid
|
|
CONF=/etc/rspamd/rspamd.conf
|
|
DAEMON_ARGS="-c $CONF -u $NAME -g $NAME"
|
|
|
|
rspamd_start() {
|
|
if [ ! -d $(dirname $PIDFILE) ]; then
|
|
mkdir $(dirname $PIDFILE)
|
|
chown rspamd:rspamd $(dirname $PIDFILE)
|
|
fi
|
|
|
|
if [ ! -r $CONF ]; then
|
|
echo "$CONF does not appear to exist. Abort."
|
|
exit 1
|
|
fi
|
|
|
|
if [ -s $PIDFILE ]; then
|
|
echo "rspamd appears to be already running?"
|
|
exit 1
|
|
fi
|
|
|
|
echo "Starting rspamd ..."
|
|
$DAEMON $DAEMON_ARGS &
|
|
}
|
|
|
|
rspamd_stop() {
|
|
if [ ! -s $PIDFILE ]; then
|
|
echo "$PIDFILE does not exist or is empty."
|
|
exit 1
|
|
fi
|
|
|
|
PID=$(cat $PIDFILE)
|
|
echo -n "Stopping rspamd ..."
|
|
kill -TERM $(cat $PIDFILE)
|
|
rm -f $PIDFILE
|
|
echo " done"
|
|
}
|
|
|
|
rspamd_restart() {
|
|
rspamd_configtest || return $?
|
|
rspamd_stop
|
|
sleep 3
|
|
rspamd_start
|
|
}
|
|
|
|
rspamd_configtest() {
|
|
$RSPAMADM configtest -c $CONF
|
|
}
|
|
|
|
case "$1" in
|
|
start)
|
|
rspamd_start
|
|
;;
|
|
stop)
|
|
rspamd_stop
|
|
;;
|
|
restart)
|
|
rspamd_restart
|
|
;;
|
|
configtest)
|
|
rspamd_configtest
|
|
;;
|
|
*)
|
|
echo "Usage: $0 {start|stop|restart|configtest}"
|
|
exit 1
|
|
esac
|