[Pkg-mono-svn-commits] rev 381 - xsp-snapshot/trunk/debian/official

Pablo Fischer pabl0-guest@quantz.debian.org
Sun, 29 Feb 2004 09:25:19 +0100


Author: pabl0-guest
Date: 2004-02-29 09:25:19 +0100 (Sun, 29 Feb 2004)
New Revision: 381

Modified:
   xsp-snapshot/trunk/debian/official/asp.net-examples.postinst
   xsp-snapshot/trunk/debian/official/asp.net-examples.prerm
   xsp-snapshot/trunk/debian/official/mono-server.init
   xsp-snapshot/trunk/debian/official/mono-xsp.init
Log:
* asp.net-examples.(postinst|prerm):
 + Fixed the file, you we use a pure debconf file, with a case switch. 
   Fixed what? We only do the thing that debconf needs, configure?, 
   ok configure it.. exit? ok, exit.. 
 + Added two functions: restart_xsp and restart_monoserver. Each one verifies 
   if the daemon is running and if it needs to be started, it will.
 + Also, to the prerm script, we check if it's a remove (with the case switch)
* mono-server.init
 + Added two new functions: should_stop, and should_restart, the first will verify
   if mono-server is running, if it isn't there's no need to stop it, so it prints 
   a message and exit, the second just check if it's running, if it's running it 
   returns a value.
 + Removed the .pid of the pidfile, looks horrible :)
 + Added a new rule, if there's no 500mod_mono.info file in /usr/lib/apache/1.3/
   we should not start the daemons
 + And another rule is to check if the VirtualHost file is empty, if it is empty, 
   we should print an error and exit.. NOT STARTING THE DAEMON
* mono-xsp.init
 + Same as mono-server, but we don't neeed to remove the .pid file, cause it 
   doesn't have it :)



Modified: xsp-snapshot/trunk/debian/official/asp.net-examples.postinst
===================================================================
--- xsp-snapshot/trunk/debian/official/asp.net-examples.postinst	2004-02-29 05:48:51 UTC (rev 380)
+++ xsp-snapshot/trunk/debian/official/asp.net-examples.postinst	2004-02-29 08:25:19 UTC (rev 381)
@@ -1,17 +1,60 @@
 #!/bin/sh -e
 
-if [ -x /usr/share/dotnet/bin/xsp.exe -a -d /etc/xsp ]; then
-    #Add the host
-    echo "Updating Root Servers..."
-    mono-vhostmanager add --config-file=/etc/xsp/virtual.conf \
-	--path=/usr/share/asp.net-demos/asp \
-	--alias=/samples
-fi
+restart_xsp() {
+    #XSP is running?
+    if [ -f /var/run/mono-xsp ]; then
+        # Are we really running xsp?
+	xsp_pid=`cat /var/run/mono-xsp`
+	xsp_ps=`ps -p $xsp_pid | wc -l`
+ 	# Are there any process running by that pid?
+	if [ $xsp_ps != "1" ]; then
+	    /etc/init.d/mono-xsp restart
+	fi
+    fi
+}
 
-if [ -x /usr/share/dotnet/bin/mod-mono-server.exe -a -d /etc/mono-server ]; then
-    #Add the host
-    echo "Updating Root Servers..."
-    mono-vhostmanager add --config-file=/etc/mono-server/virtual.conf \
-        --path=/usr/share/asp.net-demos/asp \
-	--alias=/samples
-fi
+restart_monoserver() {
+    #MonoServer is running?
+    if [ -f /var/run/mono-server ]; then
+        # Are we really running xsp?
+	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
+	    /etc/init.d/mono-server restart
+	fi
+    fi
+}
+
+case "$1" in
+    configure)
+	if [ -x /usr/share/dotnet/bin/xsp.exe -a -d /etc/xsp ]; then
+            #Add the host
+	    echo "Updating Root Servers..."
+	    mono-vhostmanager add --config-file=/etc/xsp/virtual.conf \
+		--path=/usr/share/asp.net-demos/asp \
+		--alias=/samples
+	    #Restart XSP
+	    restart_xsp
+	fi
+
+	if [ -x /usr/share/dotnet/bin/mod-mono-server.exe -a -d /etc/mono-server ]; then
+            #Add the host
+	    echo "Updating Root Servers..."
+	    mono-vhostmanager add --config-file=/etc/mono-server/virtual.conf \
+		--path=/usr/share/asp.net-demos/asp \
+		--alias=/samples
+	    #Restart mono-server
+	    restart_monoserver
+	fi
+	;;
+    
+    abort-upgrade|abort-remove|abort-deconfigure)
+        #Do nothing..
+    ;;
+
+    *)
+	;;
+esac
+
+exit 0

Modified: xsp-snapshot/trunk/debian/official/asp.net-examples.prerm
===================================================================
--- xsp-snapshot/trunk/debian/official/asp.net-examples.prerm	2004-02-29 05:48:51 UTC (rev 380)
+++ xsp-snapshot/trunk/debian/official/asp.net-examples.prerm	2004-02-29 08:25:19 UTC (rev 381)
@@ -1,18 +1,61 @@
 #!/bin/sh -e
 
-if [ -x /usr/share/dotnet/bin/xsp.exe -a -d /etc/xsp ]; then
-    #Add the host
-    echo "Updating Root Servers..."
-    mono-vhostmanager del --config-file=/etc/xsp/virtual.conf \
-	--path=/usr/share/asp.net-demos/asp \
-	--alias=/samples
-fi
+restart_xsp() {
+    #XSP is running?
+    if [ -f /var/run/mono-xsp ]; then
+        # Are we really running xsp?
+	xsp_pid=`cat /var/run/mono-xsp`
+	xsp_ps=`ps -p $xsp_pid | wc -l`
+ 	# Are there any process running by that pid?
+	if [ $xsp_ps != "1" ]; then
+	    /etc/init.d/mono-xsp restart
+	fi
+    fi
+}
 
-if [ -x /usr/share/dotnet/bin/mod-mono-server.exe -a -d /etc/mono-server ]; then
-    #Add the host
-    echo "Updating Root Servers..."
-    mono-vhostmanager del --config-file=/etc/mono-server/virtual.conf \
-        --path=/usr/share/asp.net-demos/asp \
-	--alias=/samples
-fi
+restart_monoserver() {
+    #MonoServer is running?
+    if [ -f /var/run/mono-server ]; then
+        # Are we really running xsp?
+	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
+	    /etc/init.d/mono-server restart
+	fi
+    fi
+}
 
+case "$1" in
+    configure)
+	if [ -x /usr/share/dotnet/bin/xsp.exe -a -d /etc/xsp ]; then
+            #Add the host
+	    echo "Updating Root Servers..."
+	    mono-vhostmanager del --config-file=/etc/xsp/virtual.conf \
+		--path=/usr/share/asp.net-demos/asp \
+		--alias=/samples
+	    #Restart XSP
+	    restart_xsp
+	fi
+
+	if [ -x /usr/share/dotnet/bin/mod-mono-server.exe -a -d /etc/mono-server ]; then
+            #Add the host
+	    echo "Updating Root Servers..."
+	    mono-vhostmanager del --config-file=/etc/mono-server/virtual.conf \
+		--path=/usr/share/asp.net-demos/asp \
+		--alias=/samples
+	    #Restart mono-server
+	    restart_monoserver
+	fi
+	;;
+    
+    abort-upgrade|abort-remove|abort-deconfigure)
+        #Do nothing..
+    ;;
+
+    *)
+	;;
+esac
+
+exit 0
+

Modified: xsp-snapshot/trunk/debian/official/mono-server.init
===================================================================
--- xsp-snapshot/trunk/debian/official/mono-server.init	2004-02-29 05:48:51 UTC (rev 380)
+++ xsp-snapshot/trunk/debian/official/mono-server.init	2004-02-29 08:25:19 UTC (rev 381)
@@ -40,6 +40,11 @@
             exit 0
         fi
     fi
+
+    if [ ! -f /usr/lib/apache/1.3/500mod_mono.info ]; then
+	echo "There's no need to start me if you don't have libapache-mod-mono, sorry!"
+    fi
+	
     if [ ! -x $DAEMON ]; then
         echo "$NAME is not executable, not starting"
         exit 0
@@ -62,8 +67,36 @@
 }
 
 
-set -e
+should_stop() {
+    if [ ! -f /var/run/$NAME ]; then
+	echo "Sorry, mono-server is not running at the moment"
+	exit 0	
+    else
+	# Are we really running xsp?
+	monoserver_pid=`cat /var/run/$NAME`
+	monoserver_ps=`ps -p $monoserver_pid | wc -l`
+	# Are there any process running by that pid?
+	if [ $monoserver_ps = "1" ]; then
+	    echo "Sorry, mono-server is not running at the moment"
+	    exit 0		
+	fi
+    fi
+}
 
+should_restart() {
+    if [ ! -f /var/run/$NAME ]; then
+	return 255
+    else
+	# Are we really running xsp?
+	monoserver_pid=`cat /var/run/$NAME`
+	monoserver_ps=`ps -p $monoserver_pid | wc -l`
+	# Are there any process running by that pid?
+	if [ $monoserver_ps = "1" ]; then
+	    return 255
+	fi
+    fi
+}
+
 case "$1" in
   start)
 	should_start
@@ -71,15 +104,16 @@
 	. $DEFAULT
 	echo -n "Starting $DESC: $NAME"
 	start-stop-daemon --start --background --make-pidfile \
-	    --quiet --pidfile /var/run/$NAME.pid \
+	    --quiet --pidfile /var/run/$NAME \
 	    --exec $DAEMON -- --applications $virtual_dirs --filename $socket_file --nonstop	
 	echo "."
 	sleep 2
 	fix_privileges
 	;;
   stop)
+	should_stop
 	echo -n "Stopping $DESC: $NAME "
-	start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid 		
+	start-stop-daemon --stop --quiet --pidfile /var/run/$NAME
 	echo "."
 	;;
   restart|force-reload)
@@ -88,16 +122,18 @@
 	#	option to the "reload" entry above. If not, "force-reload" is
 	#	just the same as "restart".
 	#
-	echo -n "Restarting $DESC: $NAME"
-	start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid
-	sleep 1
+	if [ ! should_restart ]; then
+	    echo "Restarting $DESC: $NAME"
+	    start-stop-daemon --stop --quiet --pidfile /var/run/$NAME
+	    sleep 1
+	fi
 	
 	should_start
 
 	virtual_dirs=`mono-vhostmanager print --config-file=$VIRTUALFILE`
 	. $DEFAULT	
 	start-stop-daemon --start --background --make-pidfile \
-	    --quiet --pidfile /var/run/$NAME.pid \
+	    --quiet --pidfile /var/run/$NAME \
 	    --exec $DAEMON -- --applications $virtual_dirs --filename $socket_file --nonstop	
 	echo "."
 	sleep 2

Modified: xsp-snapshot/trunk/debian/official/mono-xsp.init
===================================================================
--- xsp-snapshot/trunk/debian/official/mono-xsp.init	2004-02-29 05:48:51 UTC (rev 380)
+++ xsp-snapshot/trunk/debian/official/mono-xsp.init	2004-02-29 08:25:19 UTC (rev 381)
@@ -45,6 +45,36 @@
     fi
 }
 
+should_stop() {
+    if [ ! -f /var/run/$NAME ]; then
+	echo "Sorry, mono-xsp is not running at the moment"
+	exit 0	
+    else
+	# Are we really running xsp?
+	xsp_pid=`cat /var/run/$NAME`
+	xsp_ps=`ps -p $xsp_pid | wc -l`
+	# Are there any process running by that pid?
+	if [ $xsp_ps = "1" ]; then
+	    echo "Sorry, mono-xsp is not running at the moment"
+	    exit 0		
+	fi
+    fi
+}
+
+should_restart() {
+    if [ ! -f /var/run/$NAME ]; then
+	return 255
+    else
+	# Are we really running xsp?
+	xsp_pid=`cat /var/run/$NAME`
+	xsp_ps=`ps -p $xsp_pid | wc -l`
+	# Are there any process running by that pid?
+	if [ $xsp_ps = "1" ]; then
+	    return 255
+	fi
+    fi  
+}
+
 case "$1" in
     start)
 	should_start
@@ -58,6 +88,7 @@
 	echo "."
 	;;
     stop)
+	should_stop
 	echo -n "Stopping $DESC: $NAME "
 	start-stop-daemon --stop --quiet --pidfile /var/run/$NAME
 	echo "."
@@ -68,9 +99,12 @@
 	#	option to the "reload" entry above. If not, "force-reload" is
 	#	just the same as "restart".
 	#
-	echo -n "Restarting $DESC: $NAME"
-	start-stop-daemon --stop --quiet --pidfile /var/run/$NAME
-	sleep 1
+	
+	if [ ! should_restart ]; then
+	    echo "Restarting $DESC: $NAME"	
+	    start-stop-daemon --stop --quiet --pidfile /var/run/$NAME
+	    sleep 1
+	fi
 
 	should_start
 	virtual_dirs=`mono-vhostmanager print --config-file=$VIRTUALFILE`