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

Pablo Fischer pabl0-guest@haydn.debian.org
Fri, 21 May 2004 11:30:13 -0600


Author: pabl0-guest
Date: 2004-05-21 11:30:06 -0600 (Fri, 21 May 2004)
New Revision: 763

Added:
   xsp/trunk/debian/mono-xsp-admin.conf
Log:
Same as mono-server-admin.conf, mono-xsp-admin is a tool to create 
packages hosts in /etc/xsp


Added: xsp/trunk/debian/mono-xsp-admin.conf
===================================================================
--- xsp/trunk/debian/mono-xsp-admin.conf	2004-05-21 15:46:41 UTC (rev 762)
+++ xsp/trunk/debian/mono-xsp-admin.conf	2004-05-21 17:30:06 UTC (rev 763)
@@ -0,0 +1,120 @@
+#!/usr/bin/perl -w
+# mono-xsp hosts file creator
+#
+# With this script the user can create a host file in one step, 
+# these hosts file are installed in /etc/xsp/conf.d/package and 
+# then used in a 'big' host file (/etc/xsp/mono-xsp*-hosts.conf) 
+# that will be used by mono-server
+#
+# Under GPL, please read: 
+# http://www.gnu.org/copyleft/gpl.html
+#
+# Written by: Pablo Fischer
+
+use strict;
+
+my ($action, $app, $path);
+
+
+my $confd_directory = "/etc/xsp/conf.d";
+
+if($#ARGV eq "2") {
+
+    if($ARGV[0] eq "add") {
+	$action = "add";
+    }
+    
+    elsif($ARGV[0] eq "del") {
+	$action = "del";
+    }
+
+    else {
+	print "ERROR: Invalid $ARGV[0] option!\n";
+	&show_help;
+	exit;
+    }
+
+    
+    if($ARGV[1] =~ "--app") {
+	$app = $ARGV[1];
+    }
+
+    elsif($ARGV[2] =~ "--app") {
+	$app = $ARGV[2];
+    }
+
+    else {
+	print "ERROR: Missing --app!\n";
+	&show_help;
+	exit;
+    }
+
+
+    if($ARGV[1] =~ "--path") {
+	$path = $ARGV[1];		
+    }
+
+    elsif($ARGV[2] =~ "--path") {
+	$path = $ARGV[2];
+    }
+    
+    else {
+	print "ERROR: Missing --path!\n";
+	&show_help;
+	exit;
+    }
+    
+}
+
+else {
+    &show_help;
+    exit;
+}
+
+$path = (split("=", $path))[1];
+$app  = (split("=", $app))[1];
+
+
+if ($app =~ /^\//) {
+    $app =~ s|/*||;
+}
+
+#path exists?
+if ( ! -d $path ) {
+    print "$path does not exists!\n";
+    exit;
+}
+
+ 
+#But what if the conf.d package directory already exists?
+if ( -d "$confd_directory/$app") {
+    print "Sorry but $conf_directory/$app already exist, you might change your application name\n";
+    exit;
+}
+
+#Ok, create the conf.d package directory
+system("mkdir $confd_directory/$app");
+#And create the file
+system("touch $confd_directory/$app/10_$app");
+
+open(PACKAGEFILE, "> $confd_directory/$app/10_$app");
+print PACKAGEFILE "# This is the configuration file \n";
+print PACKAGEFILE "# for the $app virtualhost\n";
+print PACKAGEFILE "path = $path\n";
+print PACKAGEFILE "alias = /$app\n";
+close(PACKAGEFILE);
+
+print "done!\n";
+
+sub show_help() {
+    print "This script let the user to create a application host file in one step \n";
+    print "for mono-server (/etc/mono-server/conf.d/application\n\n";
+    print "Use:\n";
+    print " mono-server-admin.conf [action] --path=/real/path --app=/applicationame\n\n";
+    print "Where:\n";
+    print " action:\n";
+    print " add                   Creates an application\n";
+    print " del                   Delete an application (the directory /etc/mono-server/conf.d/application\n";
+    print " --path=/real/path     A real and true path where you have your ASP.NET applicatio running\n";
+    print " --app=/application  The name of the application\n";
+}