[Pkg-mono-svn-commits] rev 534 - libapache-mod-mono/trunk/debian

Pablo Fischer pabl0-guest@haydn.debian.org
Fri, 09 Apr 2004 18:09:53 -0600


Author: pabl0-guest
Date: 2004-04-09 18:09:43 -0600 (Fri, 09 Apr 2004)
New Revision: 534

Modified:
   libapache-mod-mono/trunk/debian/libapache-mod-mono.postinst
   libapache-mod-mono/trunk/debian/libapache-mod-mono.prerm
Log:
Added a should_start function to both prerm and postinst, now we 
start (stop or restart) mono-server only if it's required and valid.



Modified: libapache-mod-mono/trunk/debian/libapache-mod-mono.postinst
===================================================================
--- libapache-mod-mono/trunk/debian/libapache-mod-mono.postinst	2004-04-10 00:07:26 UTC (rev 533)
+++ libapache-mod-mono/trunk/debian/libapache-mod-mono.postinst	2004-04-10 00:09:43 UTC (rev 534)
@@ -9,6 +9,7 @@
 apachecfg="/etc/apache"
 modmono_conf="$apachecfg/conf.d/mono.conf"
 tempfile=`/bin/tempfile`
+virtual_dirs=`mono-server-reader.conf`
 
 activate_module() {
 for i in apache apache-ssl; do
@@ -47,13 +48,38 @@
 
 }
 
+
+shouldrestart_monoserver() {
+    if [ -e "/etc/default/mono-server" ]; then
+        . "/etc/default/mono-server"
+        if [ "$start_boot" != "true" ]; then
+	    return 1
+        fi
+    fi
+
+    if [ ! -f /usr/lib/apache/1.3/500mod_mono.info ]; then
+	return 1
+    fi
+	
+    if [ ! -e "/etc/mono-server/mono-server-hosts.conf" ]; then
+	return 1
+    fi
+
+    if [[ $virtual_dirs = *Sorry* ]]; then
+	return 1
+    fi
+                                                                                                                              
+    if [[ -z $virtual_dirs ]]; then
+	return 1
+    fi
+    return 0
+}
+
 restart_monoserver() {
-    #Can we start the mono-server?
-    start_monoserver=`grep start_boot /etc/default/mono-server | awk -F '=' '{ print $2}'`
-    if [ $start_monoserver = "true" ]; then
-        # Ok, start it..
-	/etc/init.d/mono-server start
-    fi    
+    if shouldrestart_monoserver ; then
+	echo -n "Starting Mono Server, mono-server: mono-server"
+	/etc/init.d/mono-server start > /dev/null 2>&1 || true
+    fi
 }
 
 

Modified: libapache-mod-mono/trunk/debian/libapache-mod-mono.prerm
===================================================================
--- libapache-mod-mono/trunk/debian/libapache-mod-mono.prerm	2004-04-10 00:07:26 UTC (rev 533)
+++ libapache-mod-mono/trunk/debian/libapache-mod-mono.prerm	2004-04-10 00:09:43 UTC (rev 534)
@@ -27,17 +27,25 @@
     fi
 }
 
-restart_monoserver() {
-    #MonoServer is running?
-    if [ -f /var/run/mono-server ]; then
-        # Are we really running xsp?
+shouldstop_monoserver() {
+    if [ -f "/var/run/mono-server" ]; then
+	# Are we really running monoserver?
 	monoserver_pid=`cat /var/run/mono-server`
 	monoserver_ps=`ps -p $monoserver_pid | wc -l`
- 	# Are there any process running by that pid?
-	if [ "$xsp_ps" != "1" ]; then
-	    #Ok.. is recommended to start it, but, should we do this?, NO!
-	    /etc/init.d/mono-server stop
+	# Are there any process running by that pid?
+	if [ "$monoserver_ps" = "2" ]; then
+	    return 0
+	else
+	    return 1
 	fi
+    fi  
+    return 0
+}
+
+restart_monoserver() {
+    if shouldstop_monoserver ; then
+	echo "Stopping Mono Server, mono-server: mono-server "
+	/etc/init.d/mono-server stop > /dev/null 2>&1 || true
     fi
 }