summaryrefslogtreecommitdiff
path: root/debian
diff options
context:
space:
mode:
authorJulien Valroff <julien@kirya.net>2010-01-06 21:00:34 +0100
committerJulien Valroff <julien@kirya.net>2010-01-06 21:00:34 +0100
commit619ed1f6bb0cca01b01b92d438072c20f5f47574 (patch)
treeb7aeb18f60b47cd4be88d7ab3ee01df145c0bb17 /debian
parentcc0712f26b594e7f9815de236da5c94f36daf8c0 (diff)
Make sure the rrd dir is writable by the HTTP daemon (Closes: #543900)
Diffstat (limited to 'debian')
-rw-r--r--debian/changelog6
-rw-r--r--debian/default5
-rw-r--r--debian/init82
3 files changed, 53 insertions, 40 deletions
diff --git a/debian/changelog b/debian/changelog
index 424b93c..ef4f0ae 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -20,9 +20,11 @@ mailgraph (1.14-2) UNRELEASED; urgency=low
* Add ${misc:Depends} to the dependencies
* Make sure the rrd directory has the correct ownership
* Add mailgraph.css to the package (Closes: #513527)
- * Call mailgraph with --daemon_pid option (Closes: #508786)
+ * Rewrite of the init script using lsb functions:
+ + Call mailgraph with --daemon_pid option (Closes: #508786)
+ + Make sure the rrd dir is writable by the HTTP daemon (Closes: #543900)
- -- Julien Valroff <julien@kirya.net> Tue, 05 Jan 2010 21:00:16 +0100
+ -- Julien Valroff <julien@kirya.net> Wed, 06 Jan 2010 20:57:23 +0100
mailgraph (1.14-1.2) unstable; urgency=low
diff --git a/debian/default b/debian/default
index eb76247..16f1e33 100644
--- a/debian/default
+++ b/debian/default
@@ -16,3 +16,8 @@ IGNORE_LOCALHOST=true
# Extra options to be passed to mailgraph daemon
# See mailgraph -h output (no default)
EXTRA_OPTIONS=
+
+# User and group http daemon runs as (default: www-data for both options)
+# Restart mailgraph daemon so that these values are taken into account
+HTTP_USER=www-data
+HTTP_GROUP=www-data
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