/usr/sbin/mono-server4-admin is in mono-apache-server4 4.2-2.1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 | #!/usr/bin/perl
# mono-server4 hosts file creator
#
# With this script the user can create a host file in one step,
# these hosts file are installed in /etc/mono-server4/conf.d/package and
# then used in a 'big' host file (/etc/mono-server4/mono-server2-hosts.conf)
# that will be used by mono-server4
#
# Under GPL, please read:
# http://www.gnu.org/copyleft/gpl.html
#
# Written by: Pablo Fischer
=head1 NAME
mono-server4-admin - mono-server4 hosts file creator, hosts file is part of the debianized mod_mono package
=head1 SYNOPSIS
mono-server4-admin [action] [args]
=head2 OPTIONS
Actions:
add Use 'add' if you want to create an application and want mono-server4 scripts to manage it
del If you want to remove an application
Args:
--path The path where you have your aspx files, MUST EXISTS!, required only with add action
--app The name of your application
--libs If you have dlls outside your path, you must use this!
--port Needed if you are running multiple virtual hosts in different ports in Apache
--vhost If you want to add asp.net support to a virtualhost you must use this. Example: foobar.com
=head1 DESCRIPTION
mono-server4-admin is a perl tool to adminstrate your ASP.NET webapps that will be executed with
mod_mono.
When you try to add an application, mono-server4-admin will verify that your path exists, if it is,
it will add a directory inside /etc/xsp/conf.d with the name of your app, and also as a file with the
filename format: 10_appname. This file will have the information (path, app).
So, when mono-xsp-update is executed it will read those dirs and create a debian.webapp in
/etc/xsp that the xsp daemon will read, also with a mono-server4-hosts that will have your
directory settings with apache directives. Apache will read mono-server4-hosts.conf!
=head1 AUTHOR
Pablo Fischer <pablo@pablo.com.mx>
=cut
use strict;
my (%OPT);
#Initializes vars
$OPT{'port'} = "80";
$OPT{'vhost'} = "*";
my $confd_directory = "/etc/mono-server4/conf.d";
#Read the opts
foreach my $opt (@ARGV) {
if($opt =~ /^add/) {
$OPT{'action'} = "add";
}
elsif($opt =~ /^del/) {
$OPT{'action'} = "del";
}
elsif($opt =~ /--path/) {
$OPT{'path'} = $opt;
}
elsif($opt =~ /--app/) {
$OPT{'app'} = $opt;
}
elsif($opt =~ /--libs/) {
$OPT{'libs'} = $opt;
}
elsif($opt =~ /--port/) {
$OPT{'port'} = $opt;
}
elsif($opt =~ /--vhost/) {
$OPT{'vhost'} = $opt;
}
}
#clean strange chars, like ':', commas, etc.. I don't like those chars
sub clean_opts() {
foreach my $key (keys %OPT) {
next unless $key ne "action";
my $value = $OPT{$key};
$OPT{$key} = (split("=", $OPT{$key}))[1];
if($key ne "path" && $key ne "libs") {
$OPT{$key} =~ s|/*||;
}
$OPT{$key} =~ s{/$}{};
$OPT{$key} =~ s|:*||;
}
}
#We have the path, app, name and the action?
sub verify_neededopts() {
if($OPT{'action'} ne "add" && $OPT{'action'} ne "del") {
&help;
exit;
}
if(!$OPT{'path'} && $OPT{'action'} eq "add") {
print "I need the path of your asp.net application\n";
exit;
}
if(!$OPT{'app'}) {
print "You should declare the application name!\n";
exit;
}
}
#Add the Host file and directory
sub add_host() {
if( ! -d $OPT{'path'} ) {
print "$OPT{'path'} does not exists!\n";
exit;
}
#But what if the conf.d package directory already exists?
if ( -d "$confd_directory/$OPT{'app'}") {
print "Sorry but $confd_directory/$OPT{'app'} already exist, you might change your application name\n";
exit;
}
#Ok, create the conf.d package directory
system("mkdir $confd_directory/$OPT{'app'}");
#And create the file
system("touch $confd_directory/$OPT{'app'}/10_$OPT{'app'}");
open(PACKAGEFILE, "> $confd_directory/$OPT{'app'}/10_$OPT{'app'}");
print PACKAGEFILE "This is the configuration file \n";
print PACKAGEFILE "for the $OPT{'app'} virtualhost\n";
print PACKAGEFILE "path = $OPT{'path'}\n";
print PACKAGEFILE "alias = /$OPT{'app'}\n";
if($OPT{'libs'}) {
print PACKAGEFILE "libs = $OPT{'libs'}\n";
}
if($OPT{'vhost'}) {
print PACKAGEFILE "vhost = $OPT{'vhost'}\n";
} else {
print PACKAGEFILE "vhost = localhost\n";
}
if($OPT{'port'}) {
print PACKAGEFILE "port = $OPT{'port'}\n";
} else {
print PACKAGEFILE "port = 80\n";
}
close(PACKAGEFILE);
system("/usr/sbin/mono-server4-update");
print "done!\n";
}
#Remove the host directory
sub del_host() {
system("rm -Rf $confd_directory/$OPT{'app'}");
system("/usr/sbin/mono-server4-update");
print "done!\n";
}
sub help() {
print "This script let the user to create a application host file in one step \n";
print "for mono-server4 (/etc/mono-server4/conf.d/application\n\n";
print "Use:\n";
print " mono-server4-admin [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-server4/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";
print " --libs=/libs If you have your libs out of path\n";
print " --vhost=vhost The VirtualHost you have in your apache config, Default: localhost\n";
print " --port=port The port of your virtualhost. Default: 80\n";
}
&clean_opts;
&verify_neededopts;
if($OPT{'action'} eq "add") {
&add_host;
}
elsif($OPT{'action'} eq "del") {
&del_host;
}
|