summaryrefslogtreecommitdiff
path: root/debian/init
diff options
context:
space:
mode:
Diffstat (limited to 'debian/init')
-rw-r--r--debian/init82
1 files changed, 44 insertions, 38 deletions
diff --git a/debian/init b/debian/init
index 8a4a7be..f689f90 100644
--- a/debian/init
+++ b/debian/init
@@ -14,48 +14,54 @@ NAME="mailgraph"
DAEMON="/usr/sbin/mailgraph"
PID_FILE="/var/run/mailgraph.pid"
RRD_DIR="/var/lib/mailgraph"
-IGNORE_OPTION=""
-MAIL_LOG="/var/log/mail.log"
-if [ -f $MAILGRAPH_CONFIG ]; then
- . $MAILGRAPH_CONFIG
-else
- exit 0
-fi
+# Default values
+BOOT_START=true
+MAIL_LOG=/var/log/mail.log
+IGNORE_LOCALHOST=true
+EXTRA_OPTIONS=
+HTTP_USER=www-data
+HTTP_GROUP=www-data
-test -x $DAEMON || exit 0
+[ -r $MAILGRAPH_CONFIG ] && . $MAILGRAPH_CONFIG
+[ -x $DAEMON ] || exit 0
-if [ "$BOOT_START" = "false" ] ; then
- exit 0
-fi
+[ "$BOOT_START" = "true" ] || exit 0
+[ "$IGNORE_LOCALHOST" = "true" ] && IGNORE_OPTION="--ignore-localhost"
-if [ "$IGNORE_LOCALHOST" = "true" ]; then
- IGNORE_OPTION="--ignore-localhost"
-fi
+. /lib/lsb/init-functions
case "$1" in
- start)
- echo -n "Starting Postfix Mail Statistics: $NAME"
- start-stop-daemon -S -q -b -p $PID_FILE -x $DAEMON -- -l $MAIL_LOG -d --daemon_pid=$PID_FILE --daemon_rrd=$RRD_DIR $IGNORE_OPTION $EXTRA_OPTIONS
- echo "."
- ;;
- stop)
- echo -n "Stopping Postfix Mail Statistics: $NAME"
- if [ -f $PID_FILE ]; then
- kill `cat $PID_FILE`
- rm $PID_FILE
- fi
- echo "."
- ;;
- restart)
- $0 stop
- $0 start
- ;;
- force-reload)
- $0 restart
- ;;
- *)
- echo "Usage: $0 start|stop|restart|force-reload"
- exit 1
- ;;
+ start)
+ # Check that the data directory is writable by the user running
+ # the HTTP daemon
+ if [ -d $RRD_DIR ]; then
+ chown $HTT_USER:$HTTP_GROUP $RRD_DIR
+ chmod 755 $RRD_DIR
+ fi
+
+ log_begin_msg "Starting $DESC:" "$NAME"
+ if [ -f $PIDFILE ]; then
+ log_action_cont_msg " already running"
+ log_end_msg 1
+ else
+ start-stop-daemon -S -q -b -p $PID_FILE -x $DAEMON -- -l $MAIL_LOG -d --daemon_pid=$PID_FILE \
+ --daemon_rrd=$RRD_DIR $IGNORE_OPTION $EXTRA_OPTIONS
+ log_end_msg $?
+ fi
+ ;;
+ stop)
+ log_begin_msg "Stopping $DESC:" "$NAME"
+ start-stop-daemon --stop --pidfile $PIDFILE
+ rm -f $PIDFILE
+ log_end_msg $?
+ ;;
+ restart|force-reload)
+ $0 stop
+ $0 start
+ ;;
+ *)
+ echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
+ exit 3
+ ;;
esac