[Pkg-mono-svn-commits] rev 315 - / libapache-mod-mono/trunk/debian libapache-mod-mono-snapshot/trunk/debian mono-nethostmanager mono-nethostmanager/src mono-nethostmanager/trunk xsp-snapshot/trunk/debian

Pablo Fischer pabl0-guest@quantz.debian.org
Sun, 22 Feb 2004 17:16:38 +0100


Author: pabl0-guest
Date: 2004-02-22 17:16:37 +0100 (Sun, 22 Feb 2004)
New Revision: 315

Added:
   mono-nethostmanager/
   mono-nethostmanager/src/
   mono-nethostmanager/src/Manager.cs
   mono-nethostmanager/src/VirtualSchema.cs
   mono-nethostmanager/trunk/
   mono-nethostmanager/trunk/debian/
Modified:
   libapache-mod-mono-snapshot/trunk/debian/control
   libapache-mod-mono/trunk/debian/mono.conf
   xsp-snapshot/trunk/debian/asp.net-examples-snapshot.postinst
Log:


Modified: libapache-mod-mono/trunk/debian/mono.conf
===================================================================
--- libapache-mod-mono/trunk/debian/mono.conf	2004-02-19 06:14:45 UTC (rev 314)
+++ libapache-mod-mono/trunk/debian/mono.conf	2004-02-22 16:16:37 UTC (rev 315)
@@ -3,11 +3,9 @@
 
 <IfModule mod_mono.c>
 	AddType application/x-asp-net .aspx .ashx .asmx .ascx .asax .config .ascx
-	MonoUnixSocket /tmp/mod_mono_server
+	MonoUnixSocket /tmp/.mono-server/mod_mono_server
 
 	# The ASP.NET examples directory, create an Alias
-	<Directory /usr/share/asp.net-demos/asp>
-		Alias /samples /usr/share/asp.net-demos/asp
-	</Directory>
+	Alias /samples /usr/share/asp.net-demos/asp
 </IfModule>
 

Modified: libapache-mod-mono-snapshot/trunk/debian/control
===================================================================
--- libapache-mod-mono-snapshot/trunk/debian/control	2004-02-19 06:14:45 UTC (rev 314)
+++ libapache-mod-mono-snapshot/trunk/debian/control	2004-02-22 16:16:37 UTC (rev 315)
@@ -7,7 +7,7 @@
 
 Package: libapache-mod-mono-snapshot
 Architecture: i386
-Depends: ${shlibs:Depends}, ${misc:Depends}, apache (>= 1.3.27-0.1), mono-jit-snapshot, mono-server-snapshot
+Depends: ${shlibs:Depends}, ${misc:Depends}, apache (>= 1.3.27-0.1), mono-jit, mono-server-snapshot
 Conflicts: libapache-mod-mono
 Description: Run ASP.NET Pages on UNIX with Apache and Mono
  Run ASP.NET pages on Unix with Apache and Mono!

Added: mono-nethostmanager/src/Manager.cs
===================================================================
--- mono-nethostmanager/src/Manager.cs	2004-02-19 06:14:45 UTC (rev 314)
+++ mono-nethostmanager/src/Manager.cs	2004-02-22 16:16:37 UTC (rev 315)
@@ -0,0 +1,161 @@
+using System;
+using System.IO;
+using System.Xml;
+using System.Xml.Serialization;
+using System.Xml.XPath;
+using System.Collections;
+
+
+public class HostManager {
+
+  private static VirtualHosts hosts;
+  
+  private static string config_file;
+  private static string host_path;
+  private static string host_alias;
+    
+  ///<summary>
+  ///Verifies if the config file exists (the one that receives from the cmd line)
+  ///if the file is found return true, else, return false.
+  ///</summary>
+  private static bool ExistsConfig() {
+    if(System.IO.File.Exists(config_file)) {
+      return true;
+    }
+    else {
+      return false;
+    }
+  }
+
+  ///<summary>
+  ///Open the config file, read it, and look for errors, if there are no errors
+  ///we should return true, else, return false
+  ///</summary>
+  private static bool IsConfigValid() {
+    //Create the stream to check if it can be deserialized
+    System.Xml.XmlReader fStream = new System.Xml.XmlTextReader(config_file);
+    //Now the deserializer
+    try {
+      XmlSerializer xSerial = new XmlSerializer(typeof(VirtualHosts));
+      if(xSerial.CanDeserialize(fStream)) {
+	fStream.Close();
+	return true;
+      }
+      else {
+	fStream.Close();
+	return false;  
+      }
+    }catch(System.Xml.XmlException ex) {
+      fStream.Close();
+      return false;
+    }
+  }
+  
+  ///<summary>
+  ///Open the file and load it inside @hosts
+  ///</summary>
+  private void LoadConfigInfo() {
+    //Create that object
+    hosts = new VirtualHosts();
+    //So, lets load it
+    XmlSerializer xSerial = new XmlSerializer(typeof(VirtualHosts));
+      //Lets open that file
+    FileStream fStream = new FileStream(config_file, FileMode.Open);
+    //Load, load!
+    hosts = (VirtualHosts)xSerial.Deserialize(fStream);
+    //CLose that file
+    fStream.Close();
+  }
+
+
+  ///<summary>
+  ///Save the file
+  ///</summary>
+  private static void Save() {
+    StreamWriter myWriter = new StreamWriter(config_file);
+    XmlSerializer xs = new XmlSerializer(typeof(VirtualHosts));
+    xs.Serialize(myWriter, hosts);
+    myWriter.Close();
+  }
+
+  ///<summary>
+  ///TODO AND TOFIX....
+  ///</summary>
+  private static void PrintHosts() {
+    VirtualHosts vh_tmp = new VirtualHosts();
+    XmlSerializer mySerializer = new XmlSerializer(typeof(VirtualHosts));
+    FileStream myFileStream = new FileStream(config_file, FileMode.Open);
+    vh_tmp = (VirtualHosts)mySerializer.Deserialize(myFileStream);
+  }
+
+  ///<summary>
+  ///Detects the option that is given from the command line
+  ///</summary>
+  private static void WhatIsIt(string option) {
+    if(option.StartsWith("--config-file")) {
+      //Get the file name, after the '=' char
+      config_file = option.Split('=')[1];
+      //Does the file exists?
+      if(!ExistsConfig()) {
+	Console.WriteLine("[FNE] The filename does not exists");
+      }
+      if(!IsConfigValid()) {
+	Console.WriteLine("[FNV] The file format is not valid");
+      }      
+    }
+    if(option.StartsWith("--path")) {
+      host_path = option.Split('=')[1];
+      if(!System.IO.Directory.Exists(host_path)) {
+	Console.WriteLine("[DNE] The Path Directory does not exists");
+      }
+    }
+    if(option.StartsWith("--alias")) {
+      host_alias = option.Split('=')[1];
+      //Remove the /      
+      host_alias.Replace("/", "");
+    }
+    if(option.StartsWith("del") || option.StartsWith("del") || option.StartsWith("up")) {
+      //Ok..
+    }
+    else {
+      Console.WriteLine("[ONR] Option not Recognized");
+    }
+  }
+
+
+
+  ///<summary>
+  ///The main
+  ///</summary>
+  public static void Main(string[] args) {
+    if(args.Length == 0) {
+      Console.WriteLine("VirtualHost Manager");
+      Console.WriteLine("Use: netvirtualhost action options \n");
+      Console.WriteLine("Actions:");
+      Console.WriteLine(" add                         Add a VirtualHost");
+      Console.WriteLine(" del                         Delete a VirtualHost");
+      Console.WriteLine(" up                          Update the information of the host");
+      Console.WriteLine("Options:");
+      Console.WriteLine("   --config-file=<file>      The full path where the config file is");
+      Console.WriteLine("   --alias=<alias>           The alias that you want for the host");
+      Console.WriteLine("   --path=<path>             The path where your web files are");
+      Console.WriteLine("\nFor example:");
+      Console.WriteLine(" netvirtualhost add --config-file=/etc/xsp/files.conf --alias=/examples --path=/usr/share/foo/bar\n");
+    }
+    else {
+      foreach(string option in args) {
+	WhatIsIt(option);
+      }
+    }
+  }
+}
+
+      
+
+
+      
+      
+
+      
+
+	

Added: mono-nethostmanager/src/VirtualSchema.cs
===================================================================
--- mono-nethostmanager/src/VirtualSchema.cs	2004-02-19 06:14:45 UTC (rev 314)
+++ mono-nethostmanager/src/VirtualSchema.cs	2004-02-22 16:16:37 UTC (rev 315)
@@ -0,0 +1,53 @@
+using System;
+using System.IO;
+using System.Xml;
+using System.Xml.Serialization;
+using System.Collections;
+
+[XmlRoot("VirtualHosts")]
+public class VirtualHosts {
+  
+  [System.Xml.Serialization.XmlArray("Hosts")]
+  [System.Xml.Serialization.XmlArrayItem("Host", typeof(Host))]
+  public ArrayList hostArray;
+  private int position;
+
+  public VirtualHosts() {
+    hostArray = new ArrayList();
+  }
+
+  public int AddHost(Host new_host) {
+    return hostArray.Add(new_host);
+  }
+
+  public void RemoveHost(int host_position) {
+    hostArray.RemoveAt(host_position);
+  }
+
+  public int GetHostPosition(string alias_match, string path_match) {
+    for(position=0; position<hostArray.Count; position++) 
+      if( ((Host)hostArray[position]).path == path_match )
+	return position;
+    return -1;
+  }
+  
+  public void ModifyHost(int host_position, string alias, string path) {
+    ((Host)hostArray[position]).alias = alias;
+    ((Host)hostArray[position]).path  = path;
+  }
+}
+
+public class Host {
+  [XmlElement("path")]  public string path;
+  [XmlElement("alias")] public string alias;
+  
+  public Host() {}
+
+  public Host(string new_path, string new_alias) {
+    path  = new_path;
+    alias = new_alias;
+  }
+
+}
+
+	

Modified: xsp-snapshot/trunk/debian/asp.net-examples-snapshot.postinst
===================================================================
--- xsp-snapshot/trunk/debian/asp.net-examples-snapshot.postinst	2004-02-19 06:14:45 UTC (rev 314)
+++ xsp-snapshot/trunk/debian/asp.net-examples-snapshot.postinst	2004-02-22 16:16:37 UTC (rev 315)
@@ -1,11 +1,17 @@
 #!/bin/sh -e
 
 if [ -x /usr/bin/xsp.exe -a -d /etc/xsp-snapshot ]; then
-    echo "Updating Root Servers..."
-    echo "/samples:/usr/share/asp.net-demos/asp" >> /etc/xsp-snapshot/virtual.conf
+    #We already have that line?
+    wehaveit=`grep -x '/samples:/usr/share/asp.net-demos/asx' /etc/xsp/virtual.conf  | wc -l`
+    if [ $wehaveit = "0" ]; then
+	echo "Updating Root Servers..."
+	echo "/samples:/usr/share/asp.net-demos/asp" >> /etc/xsp-snapshot/virtual.conf
+    fi
 fi
 
 if [ -x /usr/bin/mod-mono-server.exe -a -d /etc/mono-server-snapshot ]; then
+    wehaveit=`grep -x '/samples:/usr/share/asp.net-demos/asx' /etc/xsp/virtual.conf  | wc -l`
+
     echo "Updating Root Servers..."
     echo "/samples:/usr/share/asp.net-demos/asp" >> /etc/mono-server-snapshot/virtual.conf
 fi