[Pkg-mono-svn-commits] rev 761 - xsp/trunk/debian

Pablo Fischer pabl0-guest@haydn.debian.org
Fri, 21 May 2004 09:46:12 -0600


Author: pabl0-guest
Date: 2004-05-21 09:46:09 -0600 (Fri, 21 May 2004)
New Revision: 761

Modified:
   xsp/trunk/debian/changelog
   xsp/trunk/debian/control
   xsp/trunk/debian/mono-server-update.conf
   xsp/trunk/debian/mono-server.config
   xsp/trunk/debian/mono-server.default
   xsp/trunk/debian/mono-server.postinst
   xsp/trunk/debian/mono-server.templates
Log:
Fixes for the next release, we don't need a mono-server daemon, damn!



Modified: xsp/trunk/debian/changelog
===================================================================
--- xsp/trunk/debian/changelog	2004-05-20 22:47:17 UTC (rev 760)
+++ xsp/trunk/debian/changelog	2004-05-21 15:46:09 UTC (rev 761)
@@ -1,3 +1,11 @@
+xsp (0.12) unstable; urgency=low
+
+  * NEW Release!
+  * This new release use the new mod-mono-server, that for now it will not be
+    a daemon, it will be just a parser/wrapper for the mod_mono apache module
+
+ -- Pablo Fischer <pablo@pablo.com.mx>  Fri, 20 May 2004 23:21:13 -0600	
+
 xsp (0.9-15) unstable; urgency=low
 
   * I noted that the daemon was not starting when the user boots the computer, 

Modified: xsp/trunk/debian/control
===================================================================
--- xsp/trunk/debian/control	2004-05-20 22:47:17 UTC (rev 760)
+++ xsp/trunk/debian/control	2004-05-21 15:46:09 UTC (rev 761)
@@ -26,8 +26,9 @@
 Architecture: all
 Depends: ${shlibs:Depends}, mono-jit, libapache-mod-mono, mono-mcs
 Description: The mod-mono server
- It contains the mod-mono-server, that will start the mod-mono server 
- and create the *socket* (the one in /tmp).
+ It contains the mod-mono-server, a wrapper for mod_mono that let apache 
+ users to run ASP.NET applications, so mod_mono call mod-mono-server to 
+ parse/compile the aspx code.
 
 
  

Modified: xsp/trunk/debian/mono-server-update.conf
===================================================================
--- xsp/trunk/debian/mono-server-update.conf	2004-05-20 22:47:17 UTC (rev 760)
+++ xsp/trunk/debian/mono-server-update.conf	2004-05-21 15:46:09 UTC (rev 761)
@@ -16,13 +16,18 @@
 use Digest::MD5;
 
 #Main vars..
-my ($monoserver_dir, $monoserver_confd, $monoserver_hostfile, $daemon);
+my ($monoserver_dir, $monoserver_confd, $monoserver_hostfile, 
+    $daemon, $daemon_pid, $default_file,
+    $applications);
 
 #Setup main vars
 $monoserver_dir = "/etc/mono-server";
 $monoserver_confd = "$monoserver_dir/conf.d";
 $monoserver_hostfile = "$monoserver_dir/mono-server-hosts.conf";
 $daemon = "/etc/init.d/apache";
+$daemon_pid = "/var/run/apache.pid";
+$applications = "";
+$default_file = "/etc/default/mono-server";
 
 
 my $restart = "yes";
@@ -31,25 +36,31 @@
 
 #Check write access to $monoserver_hostfile
 if( ( -e "$monoserver_hostfile" && ! -w "$monoserver_hostfile" ) || ! -w "$monoserver_dir" ) {
-    print "mono-xsp-update.conf requires write access to $monoserver_hostfile or run it
-as root\n" ; 
+    print "mono-xsp-update.conf requires write access to $monoserver_hostfile or 
+be executed by root\n" ; 
     exit 1 ;
 }
 
+#Read the default file
+&read_default_file;
 #Orig md5
 $orig_md5 = &get_md5;
 #Read directory..
 &read_dir;
 if(-f "$monoserver_hostfile.tmp") {
-    #cp the temp file to the original one..
-    system("cp -f $monoserver_hostfile.tmp $monoserver_hostfile");
+    #Prepare the application string
+    $applications =~ s/,$//;
+    #sed the $monoserver_hostfile to replace the Applications
+    &replace_applications;
+    #cp the temp file to the original one..    
+    system("cp -f $monoserver_hostfile.tmp $monoserver_hostfile");    
     #rm the temp
     system("rm -Rf $monoserver_hostfile.tmp");
     #Final md5
     $new_md5 = &get_md5;
     #Equal?
     if(("$new_md5" ne "$orig_md5") && ($restart eq "yes")) {
-	if( -f $daemon ) {
+	if(( -f $daemon ) && ( -f $daemon_pid )) {
 	    system("$daemon restart");
 	}
     }
@@ -67,7 +78,23 @@
     }
 }
 
+sub read_default_file {
+    
+    open(DEFAULT_FILE, "$default_file");
+    while(my $line = <DEFAULT_FILE>) {
+	if($line =~ /start_apache/i) {
+	    if($line =~ /true/i) {
+		$restart = "yes";
+	    }
+	    else {
+		$restart = "no";
+	    }
+	}
+    }
+    close(DEFAULT_FILE);
+}
 
+
 sub read_dir {
     opendir(DIR, $monoserver_confd);
     my @host_dirs = sort (grep { -d "$monoserver_confd/$_" } readdir(DIR));
@@ -79,6 +106,8 @@
 
     #How many dirs?
     if($#host_dirs ne "0") {
+	#Write default content
+	&write_tempdefault;
 	foreach my $dir (@host_dirs) {
 	    if(($dir ne "..") && ($dir ne ".")) {
 		#Ok, in the dir.. we have more files, so read them
@@ -101,31 +130,87 @@
     }
 }
 
+sub replace_applications {
+    local $/;
+
+    open(TEMPHOST, "$monoserver_hostfile.tmp");
+    my $content = <TEMPHOST>;
+    close(TEMPHOST);
+
+    $content =~ s/MonoApplications .*/MonoApplications $applications/gi;
+
+    open(TEMPHOST, "> $monoserver_hostfile.tmp");
+    print TEMPHOST $content;
+    close(TEMPHOST);
+}
+
+   
+sub write_tempdefault {
+    open(TEMPHOST, ">> $monoserver_hostfile.tmp");
+
+    print TEMPHOST "# Default configuration, don't edit it!\n";
+    print TEMPHOST "MonoUnixSocket /tmp/mod_mono_server\n";    
+    print TEMPHOST "MonoServerPath /usr/share/dotnet/bin/mod-mono-server.exe\n";
+    print TEMPHOST "MonoApplications \n";
+    print TEMPHOST "\n\n\n";
+
+    close(TEMPHOST);
+    
+}
+    
 sub write_tempxsphostfile {
     my $hostfile = shift;
-    local $/;
 
     #Write the content to a temp file..
     open(TEMPHOST, ">> $monoserver_hostfile.tmp");
     #And open the hostfile..
     open(HOSTFILE, "$hostfile");
     #Read it..
-    my $content_hostfile = <HOSTFILE>;
+    my @content_hostfile = <HOSTFILE>;
     #Close it..
     close(HOSTFILE);
     #Write the header to the monoserver_hostfile
-    print TEMPHOST "###########################################\n";
-    print TEMPHOST "### begin $hostfile\n";
-    print TEMPHOST "###########################################\n";
-    print TEMPHOST $content_hostfile, "\n";
-    print TEMPHOST "###########################################\n";
-    print TEMPHOST "### end $hostfile\n";
-    print TEMPHOST "###########################################\n";
-    close(TEMPHOST);
-}
-
     
+    my ($path, $alias);
 
+    foreach my $line (@content_hostfile) {
+	if($line =~ /path/i) {
+	    #Ok, the directory exists?
+	    my $dir = (split /\=/, $line)[1];
+	    #Remove blank spaces
+	    $dir =~ tr/\ //d;
+	    #remove that \n
+	    $dir =~ s/\n//;
+ 	    if ( ! -d "$dir" ) {
+		$dir = "";
+		last;
+ 	    }
+	    else {
+		$path = $dir;
+	    }
+	}
+
+	if($line =~ /alias/i) {
+	    $alias = (split /\=/, $line)[1];
+	    #Blank Spaces
+	    $alias =~ tr/\ //d;
+	    #New lines..
+	    $alias =~ s/\n//;
+	}
+    }	
     
+    $applications = "$applications$alias:$path,";
     
-    
+    if($path) {
+	print TEMPHOST "# start $hostfile\n";
+	print TEMPHOST "   Alias $alias \"$path\"\n";
+	print TEMPHOST "     <Directory $path>\n";
+	print TEMPHOST "       SetHandler mono\n";
+	print TEMPHOST "         <IfModule mod_dir.c>\n";
+	print TEMPHOST "            DirectoryIndex index.aspx\n";
+	print TEMPHOST "         </IfModule>\n";
+	print TEMPHOST "     </Directory>\n";
+	print TEMPHOST "# end $hostfile\n";
+    }
+    close(TEMPHOST);
+}  

Modified: xsp/trunk/debian/mono-server.config
===================================================================
--- xsp/trunk/debian/mono-server.config	2004-05-20 22:47:17 UTC (rev 760)
+++ xsp/trunk/debian/mono-server.config	2004-05-21 15:46:09 UTC (rev 761)
@@ -9,13 +9,13 @@
 while [ "$STATE"  != 0 -a "$STATE" != 2 ]; do
     case "$STATE" in
 	1) 
-	    db_input medium monoserver/monoserver_addmodule || true
+	    db_input medium monoserver/monoserver_restartapache || true
 	    if db_go; then
-		db_get monoserver/monoserver_addmodule || true
+		db_get monoserver/monoserver_restartapache || true
 		if [ "$RET" = "true" ]; then
 		    STATE=2
 		else
-		    db_set  monoserver/monoserver_addmodule false || true
+		    db_set  monoserver/monoserver_restartapache false || true
 		    STATE=2
 		fi
 	    else

Modified: xsp/trunk/debian/mono-server.default
===================================================================
--- xsp/trunk/debian/mono-server.default	2004-05-20 22:47:17 UTC (rev 760)
+++ xsp/trunk/debian/mono-server.default	2004-05-21 15:46:09 UTC (rev 761)
@@ -1,14 +1,7 @@
-# Defaults for mono-server, official version
-# sourced by /etc/init.d/mono-server
+# Defaults for mono-server
 
-# Should we start it?
-start_boot=true
+# Should mono-server start apache?
+start_apache=true
 
-# User and group to chmod the *socket*
-user=www-data
-group=www-data
 
-# Name of the socket file
-socket_file=/tmp/.mono-server/mod_mono_server
 
-

Modified: xsp/trunk/debian/mono-server.postinst
===================================================================
--- xsp/trunk/debian/mono-server.postinst	2004-05-20 22:47:17 UTC (rev 760)
+++ xsp/trunk/debian/mono-server.postinst	2004-05-21 15:46:09 UTC (rev 761)
@@ -5,21 +5,28 @@
 . /usr/share/debconf/confmodule
 db_version 2.0
 
-add_module() {
-    
+tempfile=`/bin/tempfile`
+modmono_default="/etc/default/mono-server"
+
+restart_apache_on() {
+    sed s/start_apache=false/start_apache=true/g $modmono_default > $tempfile
+    cp -f $tempfile $modmono_default
+    rm -Rf $tempfile   
 }
 
-remove_module() {
-
+restart_apache_off() {
+    sed s/start_apache=true/start_apache=false/g $modmono_default > $tempfile
+    cp -f $tempfile $modmono_default
+    rm -Rf $tempfile   
 }
 
 case "$1" in
     configure)
-	db_get monoserver/monoserver_addmodule || true
+	db_get monoserver/monoserver_restartapache || true
 	if [ "$RET" = "true" ]; then
-	    add_module
+	    restart_apache_on
 	else
-	    remove_module
+	    restart_apache_off
 	fi
 
 	mono-server-update.conf

Modified: xsp/trunk/debian/mono-server.templates
===================================================================
--- xsp/trunk/debian/mono-server.templates	2004-05-20 22:47:17 UTC (rev 760)
+++ xsp/trunk/debian/mono-server.templates	2004-05-21 15:46:09 UTC (rev 761)
@@ -1,4 +1,6 @@
-Template: monoserver/monoserver_addmodule
+Template: monoserver/monoserver_restartapache
 Type: boolean
 Default: true
-Description: Would you like to add mod_mono to Apache?
+Description: Let mono-server restart Apache
+Extended_description: The debian version of mono-server includes a mono-server-update.conf that creates a configuration file for apache to start the ASP.NET applications, and mono-server-update.conf can restart apache if there's a new configuration file (/etc/mono-server/mono-server-hosts.conf). Would you like to restart apache if there's a new mono-server-hosts.conf file?
+