[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [cobalt-developers] Turning off Tomcat for specific sites
- Subject: Re: [cobalt-developers] Turning off Tomcat for specific sites
- From: Bruce Timberlake <bruce.timberlake@xxxxxxx>
- Date: Tue Jan 15 21:58:05 2002
- Organization: Sun Microsystems, Inc.
- List-id: Discussion Forum for developers on Sun Cobalt Networks products <cobalt-developers.list.cobalt.com>
travis@xxxxxxxxxxxxxxxx wrote:
>
> Tomcat is automatically setup for every site that we create on
> our Raq4. Now I am wondering how to turn it off on a per site
> basis?
Here is a "hack" that Tim Stonis put together for me for another
customer who had this same question/problem. Note: it is completely
unsupported (but works), and Tim is no longer with Sun Cobalt, so you're
totally on your own with this one.
Sorry I can't attach it as a file - the mailing list manager doesn't
appear to like attachments... email me directly if you can't sort it out
and I'll mail you a copy of the file directly.
Directions for use:
I've attached the script they need to put in:
/usr/java/jakarta-tomcat/bin/cobalt_config.pl
They should rename and save the one that's in there now (make
sure the file is executable, too). By default, all sites will
not have Java enabled on them. To enable Java for a site, just
put a file in /home/sites/[site]/ names ".java_on" and then
restart the webserver with /etc/rc.d/init.d/httpd restart.
#!/usr/bin/perl
#
# Little perl script for hacking in Cobalt vhost to Tomcat
# and enabling fast .war deployment. This is a complete hack
# with duplicate code, hardwired variables, and all!
#
# by Tim Stonis, Sun Microsystems, 09-Nov-2001
use Cobalt::Vsite;
use POSIX;
my($tomcat_home,$tim,@sites,$ip,$path,@users);
$tomcat_home = "/usr/java/jakarta-tomcat";
opendir(DIR, "/home/sites");
@sites = grep { /^.+\..*\./ && -d "/home/sites/$_" } readdir(DIR);
closedir(DIR);
open( MASTER_SERVER, "$tomcat_home/conf/server.xml.master");
open( NEW_SERVER, ">$tomcat_home/conf/server.xml");
open( COBALT_CONFIG, ">$tomcat_home/conf/mod_jk.conf-cobalt-auto");
while (<MASTER_SERVER>) {
if (/.*\[TAG_FOR_COBALT_VHOSTS\]/) {
for $tim (@sites) {
if ( -e "/home/sites/$tim/.java_on" ) {
opendir(DIR, "/home/sites/$tim/users/");
@users = grep { /\w+/ && -d "/home/sites/$tim/users/$_" }
readdir(DIR);
closedir(DIR);
print NEW_SERVER "<Host name=\"$tim\">\n";
print NEW_SERVER " <Context path=\"\" docBase=\"" .
readlink("/home/sites/$tim") . "/web\" debug=\"0\"/>\n";
if ( ! -e "/home/sites/$tim/web/WEB-INF" ) {
system("(cd /home/sites/$tim/web/; tar -xzf
$tomcat_home/conf/jspservletstuff.tar.gz; chown -R --reference=../web
WEB-INF; chmod -R --reference=../web WEB-INF )");
}
opendir(DIR, "/home/sites/$tim/web/");
@wars = grep { /^.+\.war$/ } readdir(DIR);
close(DIR);
for $war (@wars) {
$warname = $war;
$warname =~ s/\.war//;
system("su admin -c \"source /etc/profile ; cd
/home/sites/$tim/web/; if [ ! -e $warname ]; then mkdir $warname ; cd
$warname; jar -xf ../$war; chgrp -R --reference=../../web ../$warname;
fi\"");
print NEW_SERVER " <Context path=\"/$warname\" docBase=\"" .
readlink("/home/sites/$tim") . "/web/$warname\" reloadable=\"true\"
debug=\"0\"/>\n";
printf COBALT_CONFIG "JkMount /$warname/servlet/* ajp12\n";
}
# Do the users
for $user (@users) {
if ( !($user eq 'admin') ) {
if ( ! -e "/home/sites/$tim/users/$user/web/WEB-INF" ) {
system("(cd /home/sites/$tim/users/$user/web/; tar -xzf
$tomcat_home/conf/jspservletstuff.tar.gz; chown -R --reference=../web
WEB-INF; chmod -R --reference=../web WEB-INF )");
}
print NEW_SERVER " <Context path=\"/\~$user\"
docBase=\"/home/sites/$tim/users/$user/web\" reloadable=\"true\"
debug=\"0\"/>\n";
printf COBALT_CONFIG "JkMount /\~$user/servlet/* ajp12\n";
}
}
print NEW_SERVER "</Host>\n";
$path = readlink("/home/sites/$tim");
$path =~ s/.+\///;
($ip, undef, undef, undef) = Cobalt::Vsite::vsite_get_bygroup(
$path );
print NEW_SERVER "<Host name=\"$ip\">\n";
print NEW_SERVER " <Context path=\"\" docBase=\"" .
readlink("/home/sites/$tim") . "/web\" debug=\"0\"/>\n";
if ( ! -e "/home/sites/$tim/web/WEB-INF" ) {
system("(cd /home/sites/$tim/web/; tar -xzf
$tomcat_home/conf/jspservletstuff.tar.gz; chown -R --reference=../web
WEB-INF; chmod -R --reference=../web WEB-INF )");
}
opendir(DIR, "/home/sites/$tim/web/");
@wars = grep { /^.+\.war$/ } readdir(DIR);
close(DIR);
for $war (@wars) {
$warname = $war;
$warname =~ s/\.war//;
system("su admin -c \"source /etc/profile ; cd
/home/sites/$tim/web/; if [ ! -e $warname ]; then mkdir $warname ; cd
$warname; jar -xf ../$war; chgrp -R --reference=../../web ../$warname;
fi\"");
print NEW_SERVER " <Context path=\"/$warname\" docBase=\"" .
readlink("/home/sites/$tim") . "/web/$warname\" reloadable=\"true\"
debug=\"0\"/>\n";
}
# Do the users
for $user (@users) {
if ( !($user eq 'admin') ) {
if ( ! -e "/home/sites/$tim/users/$user/web/WEB-INF" ) {
system("(cd /home/sites/$tim/users/$user/web/; tar -xzf
$tomcat_home/conf/jspservletstuff.tar.gz; chown -R --reference=../web
WEB-INF; chmod -R --reference=../web WEB-INF )");
}
print NEW_SERVER " <Context path=\"/\~$user\"
docBase=\"/home/sites/$tim/users/$user/web\" reloadable=\"true\"
debug=\"0\"/>\n";
printf COBALT_CONFIG "JkMount /\~$user/servlet/* ajp12\n";
}
}
print NEW_SERVER "</Host>\n";
} # If .java_on
}
} else {
print NEW_SERVER $_;
}
}
close MASTER_SERVER;
close NEW_SERVER;
close COBALT_CONFIG;
open( MASTER_POLICY, "$tomcat_home/conf/tomcat.policy.master");
open( NEW_POLICY, ">$tomcat_home/conf/tomcat.policy");
while (<MASTER_POLICY>) {
if (/.*\[COBALT_TOMCAT_POLICY_TAG\]/) {
for $tim (@sites) {
if ( -e "/home/sites/$tim/.java_on" ) {
print NEW_POLICY "grant codeBase \"file:" .
readlink("/home/sites/$tim") . "/web/-\" { \n";
print NEW_POLICY " permission java.net.SocketPermission
\"localhost:1024-\", \"listen,connect,resolve\";\n";
print NEW_POLICY " permission java.util.PropertyPermission \"*\",
\"read,write\";\n";
print NEW_POLICY " permission java.lang.RuntimePermission
\"accessClassInPackage.sun.io\";\n";
print NEW_POLICY " permission java.io.FilePermission \"" .
readlink("/home/sites/$tim") . "/web/-\", \"read,write,delete\";\n";
# Check to see if we have a custom policy file for this site
if ( -e "$tomcat_home/conf/tomcat.policy.$tim" ) {
print "Found custom policy for: $tim\n";
open( ADD_POLICY, "$tomcat_home/conf/tomcat.policy.$tim");
while (<ADD_POLICY>) {
print NEW_POLICY $_;
}
close ADD_POLICY;
}
# See if there are some customizations we should apply to all
sites
if ( -e "$tomcat_home/conf/tomcat.policy.custom" ) {
open( ADD_POLICY, "$tomcat_home/conf/tomcat.policy.custom");
while (<ADD_POLICY>) {
print NEW_POLICY $_;
}
close ADD_POLICY;
}
print NEW_POLICY "};\n";
# Do the users
for $user (@users) {
if ( !($user eq 'admin') ) {
print NEW_POLICY "grant codeBase
\"file:/home/sites/$tim/users/$user/web/-\" { \n";
print NEW_POLICY " permission java.net.SocketPermission
\"localhost:1024-\", \"listen,connect,resolve\";\n";
print NEW_POLICY " permission java.util.PropertyPermission
\"*\", \"read,write\";\n";
print NEW_POLICY " permission java.lang.RuntimePermission
\"accessClassInPackage.sun.io\";\n";
print NEW_POLICY " permission java.io.FilePermission \"" .
readlink("/home/sites/$tim") . "/web/-\", \"read,write,delete\";\n";
# Check to see if we have a custom policy file for this user
if ( -e "$tomcat_home/conf/tomcat.policy.$user" ) {
print "Found custom policy for: $user\n";
open( ADD_POLICY, "$tomcat_home/conf/tomcat.policy.$user");
while (<ADD_POLICY>) {
print NEW_POLICY $_;
}
close ADD_POLICY;
}
print NEW_POLICY "};\n";
}
}
} # if .java_on
}
} else {
print NEW_POLICY $_;
}
}
close MASTER_POLICY;
close NEW_POLICY;
## END OF SCRIPT ##
--
Bruce Timberlake
Technology Engineer
Sun Cobalt Server Appliances
Sun Microsystems, Inc.
E: bruce.timberlake@xxxxxxx
U: http://www.sun.com/cobalt/