[Pkg-ocaml-maint-commits] r1450 - in trunk/packages/mldonkey/trunk/debian: . utils
Sylvain LE GALL
gildor-guest@costa.debian.org
Tue, 12 Jul 2005 22:59:16 +0000
Author: gildor-guest
Date: 2005-07-12 22:59:15 +0000 (Tue, 12 Jul 2005)
New Revision: 1450
Modified:
trunk/packages/mldonkey/trunk/debian/TODO
trunk/packages/mldonkey/trunk/debian/changelog
trunk/packages/mldonkey/trunk/debian/mldonkey-server.config
trunk/packages/mldonkey/trunk/debian/mldonkey-server.init
trunk/packages/mldonkey/trunk/debian/mldonkey-server.postinst
trunk/packages/mldonkey/trunk/debian/mldonkey-server.preinst
trunk/packages/mldonkey/trunk/debian/utils/mldonkey_server.ml
Log:
Better handling of init and postinst script (allow to have a more explicit message if something goes wrong) -- SLG
Modified: trunk/packages/mldonkey/trunk/debian/TODO
===================================================================
--- trunk/packages/mldonkey/trunk/debian/TODO 2005-07-09 18:27:14 UTC (rev 1449)
+++ trunk/packages/mldonkey/trunk/debian/TODO 2005-07-12 22:59:15 UTC (rev 1450)
@@ -6,9 +6,12 @@
* Explore the possibility to build a package for KMLDonkey (Bug: #274460)
-* Correct the init.d script: we need to be able to print errors on stderr and
- start correctly the script
+* Correct the init.d script: use start-stop-daemon
+* Split downloads.ini in users.ini
+
+* Handle the fasttrack split in postinst
+
* Correct bugs :
Important bugs - outstanding
#244406: mldonkey-server: A new problem of mldonkey_server
Modified: trunk/packages/mldonkey/trunk/debian/changelog
===================================================================
--- trunk/packages/mldonkey/trunk/debian/changelog 2005-07-09 18:27:14 UTC (rev 1449)
+++ trunk/packages/mldonkey/trunk/debian/changelog 2005-07-12 22:59:15 UTC (rev 1450)
@@ -89,6 +89,8 @@
password in users.ini rather than in downloads.ini (this separation is the
new security scheme, the file users.ini has 600 permission)
(Closes: #300560)
+ * Fix the problem of invoke-rc.d creating a defunct process: i need to stop
+ the debconf module (using db_stop in postinst)
-- Sylvain Le Gall <sylvain.le-gall@polytechnique.org> Tue, 28 Jun 2005 00:22:20 +0200
Modified: trunk/packages/mldonkey/trunk/debian/mldonkey-server.config
===================================================================
--- trunk/packages/mldonkey/trunk/debian/mldonkey-server.config 2005-07-09 18:27:14 UTC (rev 1449)
+++ trunk/packages/mldonkey/trunk/debian/mldonkey-server.config 2005-07-12 22:59:15 UTC (rev 1450)
@@ -166,3 +166,4 @@
fi
+db_stop
Modified: trunk/packages/mldonkey/trunk/debian/mldonkey-server.init
===================================================================
--- trunk/packages/mldonkey/trunk/debian/mldonkey-server.init 2005-07-09 18:27:14 UTC (rev 1449)
+++ trunk/packages/mldonkey/trunk/debian/mldonkey-server.init 2005-07-12 22:59:15 UTC (rev 1450)
@@ -1,4 +1,4 @@
-#! /bin/sh
+#!/bin/sh
#
# Original file :
# Written by Miquel van Smoorenburg <miquels@cistron.nl>.
@@ -26,16 +26,14 @@
. $CONFIG
-START_STOP_OPTIONS="--quiet --oknodo"
WRAPPER_OPTIONS=""
# Set the pidfile
-START_STOP_OPTIONS="$START_STOP_OPTIONS --pidfile '$PIDFILE'"
-WRAPPER_OPTIONS="$WRAPPER_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'"
+ WRAPPER_OPTIONS="$WRAPPER_OPTIONS --chdir $MLDONKEY_DIR"
fi
if [ -n "$MLDONKEY_GROUP" ]; then
@@ -59,7 +57,7 @@
echo -n "Starting $DESC: $NAME"
if [ "x$LAUNCH_AT_STARTUP" != "xtrue" ] && [ "x$1" = "xstart" ]; then
- echo "configuration file prevent $NAME to be started (use force-start)."
+ echo " configuration file prevent $NAME to be started (use force-start)."
exit 0
fi
@@ -67,12 +65,12 @@
if [ -z "$MLDONKEY_DIR" ]; then
MLDONKEY_DIR="(unset)"
fi
- echo "$MLDONKEY_DIR is not a valid directory."
+ 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."
+ echo " $MLDONKEY_DIR/downloads.ini is not a valid file."
exit 1
fi
@@ -91,24 +89,20 @@
# export MLDONKEY_CHROOT=$MLDONKEY_DIR
- # BUG : we should not need --background, but if not here, the
- # invoke-rc.d hangs.
- start-stop-daemon --start --background $START_STOP_OPTIONS --exec $WRAPPER \
- -- --start --daemon $WRAPPER_OPTIONS
+ $WRAPPER --start --daemon $WRAPPER_OPTIONS
echo "."
;;
stop)
echo -n "Stopping $DESC: $NAME"
- start-stop-daemon --stop $START_STOP_OPTIONS
+ $WRAPPER --stop --quiet $WRAPPER_OPTIONS
echo "."
;;
reload)
echo -n "Reloading $DESC: $NAME"
- start-stop-daemon --stop --signal 1 $START_STOP_OPTIONS
+ $WRAPPER --restart --quiet $WRAPPER_OPTIONS
echo "."
;;
force-reload|restart)
- echo -n "Restarting $DESC: $NAME."
$0 stop
sleep 1
$0 start
Modified: trunk/packages/mldonkey/trunk/debian/mldonkey-server.postinst
===================================================================
--- trunk/packages/mldonkey/trunk/debian/mldonkey-server.postinst 2005-07-09 18:27:14 UTC (rev 1449)
+++ trunk/packages/mldonkey/trunk/debian/mldonkey-server.postinst 2005-07-12 22:59:15 UTC (rev 1450)
@@ -1,7 +1,5 @@
#!/bin/sh -e
-#set -x
-
# Source debconf library
. /usr/share/debconf/confmodule
@@ -257,5 +255,7 @@
;;
esac
+db_stop
+
# For the rest
#DEBHELPER#
Modified: trunk/packages/mldonkey/trunk/debian/mldonkey-server.preinst
===================================================================
--- trunk/packages/mldonkey/trunk/debian/mldonkey-server.preinst 2005-07-09 18:27:14 UTC (rev 1449)
+++ trunk/packages/mldonkey/trunk/debian/mldonkey-server.preinst 2005-07-12 22:59:15 UTC (rev 1450)
@@ -1,8 +1,5 @@
#!/bin/sh -e
-# Source debconf library
-. /usr/share/debconf/confmodule
-
CONFFILE=/etc/default/mldonkey-server
case "$1" in
Modified: trunk/packages/mldonkey/trunk/debian/utils/mldonkey_server.ml
===================================================================
--- trunk/packages/mldonkey/trunk/debian/utils/mldonkey_server.ml 2005-07-09 18:27:14 UTC (rev 1449)
+++ trunk/packages/mldonkey/trunk/debian/utils/mldonkey_server.ml 2005-07-12 22:59:15 UTC (rev 1450)
@@ -2,7 +2,7 @@
exception No_home_variable;;
exception No_home_to_chdir;;
-exception Fails_forking;;
+exception Fails_daemonize;;
exception Already_running;;
exception No_pidfile;;
exception Cant_find_logger;;
@@ -327,7 +327,7 @@
;;
let fatal st str =
- prerr_string str;
+ prerr_string (" "^str);
prerr_newline ();
ignore (print_log st str)
;;
@@ -435,7 +435,11 @@
List.fold_left Filename.concat "/proc" [ (string_of_int pid) ; "exe" ]
in
if Sys.file_exists proc_filename then
- (Unix.stat proc_filename).Unix.st_ino
+ (* This condition is too hard: when upgrading you loose the inode number
+ because the script is reinstalled
+ *)
+ (*(Unix.stat proc_filename).Unix.st_ino*)
+ Unix.readlink proc_filename
else
raise (No_proc_entry proc_filename)
in
@@ -454,10 +458,10 @@
warning st ("Invalid pidfile: "^(get_pidfile st));
false
)
- | No_proc_entry _ ->
+ | No_proc_entry proc ->
(
- warning st ("Cannot open /proc entry for the given pidfile:
- "^(get_pidfile st));
+ warning st ("Cannot open "^proc^" entry for the given pidfile: "
+ ^(get_pidfile st));
false
)
else
@@ -581,7 +585,7 @@
1;
check_fun
check_tmp_ini_files
- inifiles
+ (inifiles @ passwdfiles)
"temporary file[s] left"
"delete it first"
1;
@@ -632,19 +636,24 @@
if st.daemon then
if Unix.fork () = 0 then
if Unix.setsid () = Unix.getpid () then
- if Unix.fork () = 0 then
- (
- let fd = Unix.openfile "/dev/null" [ Unix.O_RDWR ] 0o0644
- in
- Unix.dup2 fd Unix.stdin;
- Unix.dup2 fd Unix.stdout;
- Unix.dup2 fd Unix.stderr;
- Unix.close fd
- )
+ (
+ let fd = Unix.openfile "/dev/null" [ Unix.O_RDWR ] 0o0644
+ in
+ List.iter (
+ fun fd_std ->
+ Unix.close fd_std;
+ Unix.dup2 fd fd_std
+ )
+ [Unix.stdin; Unix.stdout; Unix.stderr];
+ Unix.close fd;
+ ()
+ (*if Unix.fork () = 0 then
+ ()
+ else
+ exit 0*)
+ )
else
- exit 0
- else
- raise Fails_forking
+ raise Fails_daemonize
else
exit 0
else
@@ -653,18 +662,18 @@
let start_mldonkey_server st =
sanity_check st;
- set_nice st;
- set_uid_gid st;
- set_umask st;
- create_home st;
- go_home st;
if daemon_is_running st then
raise Already_running
else
();
+(* set_nice st;
+ set_uid_gid st;
+ set_umask st;
+ create_home st;
+ go_home st;*)
daemonize st;
create_pidfile st;
- let launch_mlnet st =
+(* let launch_mlnet st =
let (logger_stderr, mlnet_stderr) =
if st.daemon then
Unix.pipe ()
@@ -819,6 +828,10 @@
()
done;
done;
+ *)
+ while true do
+ Unix.sleep 1
+ done;
debug st "MLDonkey server end";
close_pidfile st
;;
@@ -866,42 +879,46 @@
exit 0
with No_home_variable ->
begin
- prerr_string ("Could not guess $HOME environnement variable : provide a --chdir or $HOME");
+ prerr_string (" Could not guess $HOME environnement variable : provide a --chdir or $HOME");
prerr_newline ()
end
| No_home_to_chdir ->
begin
- prerr_string ("Home dir doesn't exist");
+ prerr_string (" Home dir doesn't exist");
prerr_newline ()
end
- | Fails_forking ->
+ | Fails_daemonize ->
begin
- prerr_string ("Cannot fork process");
+ prerr_string (" Cannot daemonize process");
prerr_newline ()
end
| Already_running ->
begin
- prerr_string ("Some others mldonkey_server are running ( a pidfile exists )");
+ prerr_string (" Some others mldonkey_server are running ( a pidfile exists )");
prerr_newline ()
end
| No_pidfile ->
begin
- prerr_string ("No pidfile, maybe no mldonkey_server are running");
+ prerr_string (" No pidfile, maybe no mldonkey_server are running");
prerr_newline ()
end
| Invalid_pidfile ->
begin
- prerr_string ("Invalid pidfile, maybe the pidfile is corrupted");
+ prerr_string (" Invalid pidfile, maybe the pidfile is corrupted");
prerr_newline ();
end
| No_proc_entry str ->
begin
- prerr_string ("Cannot find /proc entry for "^str);
+ prerr_string (" Cannot find /proc entry for "^str);
prerr_newline ();
end
| Unix.Unix_error (error,_,_) ->
begin
- prerr_string (error_message error);
+ prerr_string (" "^(error_message error));
prerr_newline ()
end
+in
+exit 1
;;
+
+