[Pkg-ocaml-maint-commits] r1432 - trunk/packages/mldonkey/trunk/debian

Sylvain LE GALL gildor-guest@costa.debian.org
Mon, 04 Jul 2005 22:34:05 +0000


Author: gildor-guest
Date: 2005-07-04 22:34:04 +0000 (Mon, 04 Jul 2005)
New Revision: 1432

Modified:
   trunk/packages/mldonkey/trunk/debian/mldonkey-server.init
   trunk/packages/mldonkey/trunk/debian/mldonkey-server.postinst
   trunk/packages/mldonkey/trunk/debian/mldonkey-server.preinst
Log:
Correction after trying the package -- SLG


Modified: trunk/packages/mldonkey/trunk/debian/mldonkey-server.init
===================================================================
--- trunk/packages/mldonkey/trunk/debian/mldonkey-server.init	2005-07-04 10:22:46 UTC (rev 1431)
+++ trunk/packages/mldonkey/trunk/debian/mldonkey-server.init	2005-07-04 22:34:04 UTC (rev 1432)
@@ -26,83 +26,93 @@
 
 . $CONFIG
 
-if [ "x$LAUNCH_AT_STARTUP" != "xtrue" ] && [ "x$1" = "xstart" ]; then
-  echo "$DESC is configured not start ( see file /etc/default/mldonkey-server )"
-  exit 0
+START_STOP_OPTIONS="--quiet --oknodo"
+WRAPPER_OPTIONS=""
+
+# Set the pidfile
+START_STOP_OPTIONS="$START_STOP_OPTIONS --pidfile \"$PIDFILE\""
+WRAPPER_OPTIONS="$WRAPPER_OPTIONS --pidfile \"$PIDFILE\""
+
+# Set configuration value, from CONFIG
+if [ -n "$MLDONKEY_DIR" ]; then
+  WRAPPER_OPTIONS="$WRAPPER_OPTIONS --chdir \"$MLDONKEY_DIR\""
 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 0
+if [ -n "$MLDONKEY_GROUP" ]; then
+  WRAPPER_OPTIONS="$WRAPPER_OPTIONS --chgid $MLDONKEY_GROUP"
 fi
 
-if [ ! -f $MLDONKEY_DIR/downloads.ini ]; then
-  echo "$MLDONKEY_DIR/downloads.ini is not a valid file"
-  exit 0
+if [ -n "$MLDONKEY_UMASK" ]; then
+  WRAPPER_OPTIONS="$WRAPPER_OPTIONS --umask $MLDONKEY_UMASK"
 fi
 
-if [ -e $MLDONKEY_DIR/files.ini ] && [ ! -e $MLDONKEY_DIR/files.ini.fasttrack ]; then
-  echo "First reboot after Fasttrack problem see /usr/share/doc/mldonkey-server/README.Debian"
-  echo -n "Splitting $MLDONKEY_DIR/files.ini to remove Fasttrack files : "
-  /usr/bin/mldonkey_files --split Fasttrack -f0 $MLDONKEY_DIR/files.ini \
-  -f1 $MLDONKEY_DIR/files.ini.fasttrack \
-  -f2 $MLDONKEY_DIR/files.ini 
-  echo "done."
+if [ -n "$MLDONKEY_NICENESS" ]; then
+  WRAPPER_OPTIONS="$WRAPPER_OPTIONS --nice $MLDONKEY_NICENESS"
 fi
 
-USER=`/usr/bin/stat --format="%U" $MLDONKEY_DIR/downloads.ini`
+if [ -n "$MAX_ALIVE" ]; then
+  WRAPPER_OPTIONS="$WRAPPER_OPTIONS --max-alive $MAX_ALIVE"
+fi
 
-START_STOP_OPTIONS=""
+case "$1" in
+  start|force-start)
+    echo -n "Starting $DESC: "
 
-if [ -n "$MLDONKEY_NICENESS" ]; then
-  START_STOP_OPTIONS="$START_STOP_OPTIONS --nicelevel $MLDONKEY_NICENESS"
-fi
+    if [ "x$LAUNCH_AT_STARTUP" != "xtrue" ] && [ "x$1" = "xstart" ]; then
+      echo "configuration file prevent $NAME to be started (use force-start)."
+      exit 0
+    fi
 
-case "$1" in
-  start)
-    $0 force-start
-    ;;
-    
-  force-start)
-    echo -n "Starting $DESC: $NAME"
-    
+    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
+    fi
+
+    if [ ! -f "$MLDONKEY_DIR/downloads.ini" ]; then
+      echo "$MLDONKEY_DIR/downloads.ini is not a valid file."
+      exit 1
+    fi
+
+    if [ -e "$MLDONKEY_DIR/files.ini" ] && [ ! -e "$MLDONKEY_DIR/files.ini.fasttrack" ]; then
+      echo ""
+      echo "First reboot after Fasttrack problem see /usr/share/doc/mldonkey-server/README.Debian"
+      echo -n "Splitting $MLDONKEY_DIR/files.ini to remove Fasttrack files: "
+      /usr/bin/mldonkey_files --split Fasttrack -f0 "$MLDONKEY_DIR/files.ini" \
+      -f1 "$MLDONKEY_DIR/files.ini.fasttrack" \
+      -f2 "$MLDONKEY_DIR/files.ini" 
+      echo "done."
+    fi
+
+    USER=`/usr/bin/stat --format="%U" "$MLDONKEY_DIR/downloads.ini"`
+    WRAPPER_OPTIONS="$WRAPPER_OPTIONS --chuid $USER"
+   
     # export MLDONKEY_CHROOT=$MLDONKEY_DIR
 
     # BUG : we should not need --background, but if not here, the 
     # invoke-rc.d hangs.
-    start-stop-daemon --start --quiet --oknodo --background --pidfile $PIDFILE \
-      $START_STOP_OPTIONS --exec $WRAPPER -- \
-      --start --pidfile $PIDFILE --chdir $MLDONKEY_DIR --chuid $USER \
-      --max-alive $MAX_ALIVE --umask $MLDONKEY_UMASK --daemon
-    
+    start-stop-daemon --start --background $START_STOP_OPTIONS --exec $WRAPPER \
+      -- --start --daemon $WRAPPER_OPTIONS
     echo "."
   ;;
   stop)
     echo -n "Stopping $DESC: $NAME"
-    
-    start-stop-daemon --stop --oknodo --quiet --pidfile $PIDFILE
-
+    start-stop-daemon --stop $START_STOP_OPTIONS
     echo "."
   ;;
-  restart)
-    echo -n "Restarting $DESC: $NAME"
-    
-    start-stop-daemon --stop --oknodo --signal 1 --quiet --pidfile $PIDFILE
-    
+  reload)
+    echo -n "Reloading $DESC: $NAME"
+    start-stop-daemon --stop --signal 1 $START_STOP_OPTIONS
     echo "."
   ;;
-  
-  force-reload)
-    echo -n "Reloading $DESC: $NAME."
-    
+  force-reload|restart)
+    echo -n "Restarting $DESC: $NAME."
     $0 stop
     sleep 1
     $0 start
   ;;
-  
   *)
     echo "Usage: $0 {start|stop|restart|force-reload|force-start}" >&2
     exit 1

Modified: trunk/packages/mldonkey/trunk/debian/mldonkey-server.postinst
===================================================================
--- trunk/packages/mldonkey/trunk/debian/mldonkey-server.postinst	2005-07-04 10:22:46 UTC (rev 1431)
+++ trunk/packages/mldonkey/trunk/debian/mldonkey-server.postinst	2005-07-04 22:34:04 UTC (rev 1432)
@@ -112,12 +112,9 @@
 
       if [ -f $MLDONKEY_DIR/downloads.ini ]; then
 	db_get mldonkey-server/reown_file 
-
-	if [ "$RET" = "true" ]; then
+	if [ "$RET" = "true" ] && ! dpkg-statoverride --list $MLDONKEY_DIR >/dev/null; then
 	  $DEBUG && echo -n "Reowning file of $MLDONKEY_DIR: "
-	  if ! dpkg-statoverride --list $MLDONKEY_DIR >/dev/null; then
-	    /bin/chown -R $run_as_user:$mldonkey_group $MLDONKEY_DIR
-	  fi
+          /bin/chown -R $run_as_user:$mldonkey_group $MLDONKEY_DIR
 	  $DEBUG && echo "done."
 	fi
       
@@ -141,15 +138,11 @@
     
       /usr/bin/touch $CONF 
       
-      $DEBUG && echo -n "Creating backup of $new_mldonkey_dir/downloads.ini and $CONF : "
-
+      $DEBUG && echo -n "Creating backup of $new_mldonkey_dir/downloads.ini: "
       /bin/cp -p -f $new_mldonkey_dir/downloads.ini $new_mldonkey_dir/downloads.ini.dpkg
-      /bin/cp -p -f $CONF $CONF.dpkg
-
       $DEBUG && echo "done."
 
-      $DEBUG && echo -n "Writing new values to $new_mldonkey_dir/downloads.ini : "
-
+      $DEBUG && echo -n "Writing new values to $new_mldonkey_dir/downloads.ini: "
       /usr/bin/mldonkey_options -f $new_mldonkey_dir/downloads.ini <<EOF
 run_as_useruid=$run_as_useruid
 run_as_user="$run_as_user"
@@ -164,25 +157,18 @@
 max_hard_upload_rate=$max_hard_upload_rate
 max_hard_download_rate=$max_hard_download_rate
 EOF
-
       $DEBUG && echo "done."
 
       if [  -n "$password" ]; then
-
-	$DEBUG && echo -n "Registering admin password in $new_mldonkey_dir/downloads.ini : "
-
+	$DEBUG && echo -n "Registering admin password in $new_mldonkey_dir/downloads.ini: "
 	/usr/bin/mldonkey_users --add admin -q -f $new_mldonkey_dir/downloads.ini -p $password
-
 	$DEBUG && echo "done."
       fi
 
-
-      
       MLDONKEY_DIR=$new_mldonkey_dir
       MLDONKEY_GROUP=$mldonkey_group
       MLDONKEY_UMASK=$mldonkey_umask
       MAX_ALIVE=$max_alive
-
     fi
 
     CONF_NEW=`/bin/tempfile`

Modified: trunk/packages/mldonkey/trunk/debian/mldonkey-server.preinst
===================================================================
--- trunk/packages/mldonkey/trunk/debian/mldonkey-server.preinst	2005-07-04 10:22:46 UTC (rev 1431)
+++ trunk/packages/mldonkey/trunk/debian/mldonkey-server.preinst	2005-07-04 22:34:04 UTC (rev 1432)
@@ -1,76 +1,17 @@
 #!/bin/sh -e 
 
+# Source debconf library
+. /usr/share/debconf/confmodule
+
 CONFFILE=/etc/default/mldonkey-server
 
 case "$1" in
   install|upgrade)
-    if dpkg --compare-version "$2" lt "2.5.1-5" && [ -e /etc/mldonkey.conf ]; then
+    if dpkg --compare-versions "$2" lt "2.5.1-5" && [ -e /etc/mldonkey.conf ]; then
       echo "Moving /etc/mldonkey.conf to /etc/default/mldonkey-server"
       mv -f /etc/mldonkey.conf $CONFFILE
     fi
-  
-    if dpkg --compare-versions "$2" le "2.5.28-2" && [ -e $CONFFILE ]; then
-      # Moving /etc/default/mldonkey-server from conffile to ucf management
-      echo "Migration of /etc/default/mldonkey-server to ucf"
-      
-      # Read the former CONFFILE
-      echo -n " Loading default:"
-      MLDONKEY_DIR=
-      MLDONKEY_GROUP=
-      MLDONKEY_UMASK=
-      MAX_ALIVE=
-      LAUNCH_AT_STARTUP=
-      MLDONKEY_NICENESS=
-      . $CONFFILE || true
-      echo "done."
-      
-      # Save the default which can be found in /etc/default/mldonkey-server
-      # in debconf
-      echo -n " Saving default: "
-      if [ "$MLDONKEY_DIR" != "" ]; then 
-        echo -n "MLDONKEY_DIR "
-        db_set mldonkey-server/mldonkey_dir $MLDONKEY_DIR
-      fi
-      
-      if [ "$MLDONKEY_GROUP" != "" ]; then 
-        echo -n "MLDONKEY_GROUP "
-        db_set mldonkey-server/mldonkey_group $MLDONKEY_GROUP
-      fi
-      
-      if [ "$MLDONKEY_UMASK" != "" ]; then 
-        echo -n "MLDONKEY_UMASK "
-        db_set mldonkey-server/mldonkey_umask $MLDONKEY_UMASK 
-      fi
-      
-      if [ "$MAX_ALIVE" != "" ]; then
-        echo -n "MAX_ALIVE "
-        db_set mldonkey-server/max_alive $MAX_ALIVE
-      fi
-      
-      if [ "$MLDONKEY_NICENESS" != "" ]; then 
-        echo -n "MLDONKEY_NICENESS "
-        db_set mldonkey-server/mldonkey_niceness $MLDONKEY_NICENESS
-      fi
-      
-      if [ "$LAUNCH_AT_STARTUP" != "" ]; then
-        echo -n "LAUNCH_AT_STARTUP "
-        if [ "$LAUNCH_AT_STARTUP" = "true" ]; then 
-          db_set mldonkey-server/launch_at_startup true
-        else 
-          db_set mldonkey-server/launch_at_startup false
-        fi
-      fi
-
-      echo "done."
-      
-      # Move the file to a backup file
-      echo -n " Removing obsolete conffile (backup is $CONFFILE.dpkg-bak): "
-      mv -f "$CONFFILE" "$CONFILE.dpkg-bak"
-      echo "done."
-
-      
-      echo "The file will be re-created using ucf."
-    fi
+  ;;
 esac
 
 #DEBHELPER#