From 325e9614192bb026ddb6efcb2c2d3ea633f4bf3e Mon Sep 17 00:00:00 2001 From: Christoph Haas Date: Thu, 11 May 2017 11:11:19 +0200 Subject: [PATCH] Added Start/Stop Scripts --- startup/init.d/kopano-spamd | 81 ++++++++++++++++++++++++++++ startup/systemd/kopano-spamd.service | 11 ++++ 2 files changed, 92 insertions(+) create mode 100644 startup/init.d/kopano-spamd create mode 100644 startup/systemd/kopano-spamd.service diff --git a/startup/init.d/kopano-spamd b/startup/init.d/kopano-spamd new file mode 100644 index 0000000..cf74629 --- /dev/null +++ b/startup/init.d/kopano-spamd @@ -0,0 +1,81 @@ +#! /bin/sh +# +### BEGIN INIT INFO +# Provides: kopano-spamd +# Required-Start: $syslog $network $remote_fs +# Required-Stop: $syslog $network $remote_fs +# Should-Start: kopano-server +# Should-Stop: kopano-server +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Kopano Core Spam Daemon +### END INIT INFO + +PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin +SPAMD=/usr/local/bin/kopano-spamd.py +DESC="spamd" +NAME=`basename $SPAMD` +#QUIETDAEMON=--quiet +PIDFILE=/var/run/kopano/spamd.pid + +test -x $SPAMD || exit 0 + +# Include defaults if available +if [ -f /etc/default/kopano ] ; then + . /etc/default/kopano +fi +if [ -z "$KOPANO_LOCALE" ]; then + KOPANO_LOCALE="C" +fi + +SPAMD_OPTS="" + +#set -e + +. /lib/lsb/init-functions + +case "$1" in + start) + if [ "$SPAMD_ENABLED" = "no" ]; then + log_warning_msg "Spam daemon not enabled in /etc/default/kopano ... not starting" + exit 0 + fi + log_begin_msg "Starting $DESC: $NAME" + install -dm0775 -o kopano -g kopano /var/run/kopano + export LC_ALL=$KOPANO_LOCALE + export LANG=$KOPANO_LOCALE + start-stop-daemon --start $QUIETDAEMON --pidfile $PIDFILE --exec /usr/bin/python $SPAMD -- $SPAMD_OPTS >/dev/null 2>&1 + log_end_msg $? + unset LC_ALL LANG + ;; + stop) + log_begin_msg "Stopping $DESC: $NAME" + start-stop-daemon --stop $QUIETDAEMON --pidfile $PIDFILE --retry TERM/15/KILL --exec /usr/bin/python $SPAMD >/dev/null + RETVAL=$? + rm -f $PIDFILE + test "$RETVAL" -eq 0 + log_end_msg "$?" + ;; + restart) + $0 stop + $0 start + ;; + status) + status_of_proc -p $PIDFILE "$SPAMD" "$NAME" && exit 0 || exit $? + ;; + reload|force-reload) + log_begin_msg "Reloading $DESC: $NAME" + start-stop-daemon --stop $QUIETDAEMON --signal HUP --pidfile $PIDFILE --exec /usr/bin/python $SPAMD + log_end_msg $? + ;; +try-restart) + "$0" status >/dev/null && "$0" restart + ;; + *) + N=/etc/init.d/$NAME + echo "Usage: $N {start|stop|restart|reload|force-reload|status}" >&2 + exit 1 + ;; +esac + +exit 0 diff --git a/startup/systemd/kopano-spamd.service b/startup/systemd/kopano-spamd.service new file mode 100644 index 0000000..9bed216 --- /dev/null +++ b/startup/systemd/kopano-spamd.service @@ -0,0 +1,11 @@ +[Unit] +Description=Kopano Core Spam Daemon + +[Service] +Type=simple +Environment=LC_ALL=C LANG=C +ExecStart=/usr/bin/python /usr/sbin/kopano-spamd.py -F +SuccessExitStatus=1 + +[Install] +WantedBy=multi-user.target \ No newline at end of file