[Pkg-ocaml-maint-commits] [SCM] mldonkey packaging branch, master, updated. debian/2.9.5-2-40-g67e29ab

Samuel Mimram samuel.mimram at ens-lyon.org
Tue Jan 13 12:04:30 UTC 2009


The following commit has been merged in the master branch:
commit 14b9211d25f3cc00d26b5ccd81ad022f9d127006
Author: Samuel Mimram <samuel.mimram at ens-lyon.org>
Date:   Tue Jan 13 12:55:21 2009 +0100

    Better handling of errors in init script.

diff --git a/debian/changelog b/debian/changelog
index 227ce02..676998d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -10,8 +10,9 @@ mldonkey (2.9.6-1) UNRELEASED; urgency=low
   * New upstream release, closes: #508280.
   * Fixes alignement problem on ARM, closes: #487803.
   * Remove useless line in init script, closes: #509001.
+  * Better handling of errors in init script, closes: #508538.
 
- -- Samuel Mimram <smimram at debian.org>  Tue, 13 Jan 2009 12:41:20 +0100
+ -- Samuel Mimram <smimram at debian.org>  Tue, 13 Jan 2009 12:53:45 +0100
 
 mldonkey (2.9.5-2) unstable; urgency=low
 
diff --git a/debian/mldonkey-server.init b/debian/mldonkey-server.init
index fe3a1f7..7c6a9d8 100644
--- a/debian/mldonkey-server.init
+++ b/debian/mldonkey-server.init
@@ -31,11 +31,36 @@ CONFIG=/etc/default/mldonkey-server
 PIDDIR=/var/run/mldonkey
 PIDFILE=$PIDDIR/$NAME.pid
 LOGFILE=/var/log/mldonkey/$NAME.log
+SERVERLOG=/var/lib/mldonkey/mlnet.log
 
 test -e $CONFIG || exit 0
 
 set -e
 
+Warn ()
+{
+    echo "$*" >&2
+}
+
+Error ()
+{
+    code=$1
+    shift
+
+    echo "."
+    Warn "$DESC: $NAME [ERROR] $@"
+    exit $code
+}
+
+StartErrorCheck ()
+{
+    if tail -n 2 $SERVERLOG | grep -qi 'aborting' ; then
+        Warn "$DESC: $NAME [ERROR] server start error"
+        tail --verbose $SERVERLOG
+        exit 1
+    fi
+}
+
 . $CONFIG
 
 # /var/run might be on tempfs, see #354701.
@@ -71,24 +96,21 @@ fi
 
 case "$1" in
   start|force-start)
-    echo -n "Starting $DESC: $NAME"
+    echo "Starting $DESC: $NAME"
 
     if [ "x$LAUNCH_AT_STARTUP" != "xtrue" ] && [ "x$1" = "xstart" ]; then
-      echo " configuration file prevent $NAME to be started (use force-start)."
-      exit 0
+      Error 0 "[ERROR] configuration file prevent $NAME to be started (use force-start)."
     fi
 
     if [ -z "$MLDONKEY_DIR" ] || [ ! -d "$MLDONKEY_DIR" ]; then
       if [ -z "$MLDONKEY_DIR" ]; then
         MLDONKEY_DIR="(unset)"
       fi
-      echo " $MLDONKEY_DIR is not a valid directory."
-      exit 1
+      Error 1 "$MLDONKEY_DIR is not a valid directory."
     fi
 
     if [ ! -f "$MLDONKEY_DIR/downloads.ini" ]; then
-      echo " $MLDONKEY_DIR/downloads.ini is not a valid file."
-      exit 1
+      Error 1 "$MLDONKEY_DIR/downloads.ini is not a valid file."
     fi
 
     USER=`/usr/bin/stat --format="%U" "$MLDONKEY_DIR/downloads.ini"`
@@ -98,7 +120,7 @@ case "$1" in
     --pidfile $PIDFILE --background --exec $EXEC \
     -- -pid $PIDDIR > $LOGFILE 2>&1
 
-    echo "."
+    StartErrorCheck
   ;;
 
   stop)
@@ -113,8 +135,7 @@ case "$1" in
   ;;
 
   *)
-    echo "Usage: $0 {start|stop|restart|force-reload|force-start}" >&2
-    exit 1
+    Error 1 "Usage: $0 {start|stop|restart|force-reload|force-start}"
   ;;
 esac
 

-- 
mldonkey packaging



More information about the Pkg-ocaml-maint-commits mailing list