5
my $eucalyptus = $ENV{'EUCALYPTUS'};
6
my $dynpath = "$eucalyptus/var/lib/eucalyptus/dynserv";
8
my $dynpath = shift @ARGV;
9
my @allowhosts = @ARGV;
11
$rc = setup_dynpath($dynpath);
13
print "ERROR: could not create directory structure\n";
17
$rc = open(OFH, ">$dynpath/dynserv-httpd.conf");
19
print "ERROR: could not create config file '$dynpath/dynserv-httpd.conf'\n";
23
$authz = find_authz();
24
$apache = find_apache2();
25
if ($authz eq "none" || $apache eq "none") {
26
print "ERROR: cannot find authz module ($authz) or apache2 ($apache)\n";
30
$rc = prepare_configfile($eucalyptus, $dynpath, "eucalyptus", "eucalyptus", $authz, $apache, @allowhosts);
32
print "ERROR: could not set up configfile\n";
36
$rc = restart_apache($dynpath, $apache);
38
print "ERROR: could not restart apache2\n";
44
sub restart_apache() {
45
my $dynpath = shift @_;
46
my $apache = shift @_;
48
my $cmd = "$apache -f $dynpath/dynserv-httpd.conf -k graceful";
49
my $rc = system("$cmd");
51
print "ERROR: could not run cmd '$cmd'\n";
56
sub prepare_configfile() {
57
my $eucalyptus = shift @_;
58
my $dynpath = shift @_;
62
my $apache = shift @_;
65
if (!-d "$eucalyptus/var/run/eucalyptus" || !-d "$eucalyptus/var/log/eucalyptus") {
66
print "ERROR: eucalyptus root '$eucalyptus' not found\n";
69
if (!-d "$eucalyptus" || !-d "$dynpath" || !-e "$authz" || !-x "$apache") {
70
print "ERROR: eucalyptus=$eucalyptus dynpath=$dynpath user=$user group=$group authz=$authz apache=$apache\n";
74
$allows = "127.0.0.0/8";
75
foreach $host (@allowhosts) {
76
$allows = $allows . " $host";
85
PidFile $eucalyptus/var/run/eucalyptus/httpd-dynserv.pid
88
ErrorLog $eucalyptus/var/log/eucalyptus/httpd-dynserv-err.log
90
LoadModule authz_host_module $authz
91
DocumentRoot "$dynpath/data/"
92
<Directory "$dynpath/data/">
94
# Allow from 127.0.0.1
105
my @known_locations = ('/usr/lib64/httpd/modules/mod_authz_host.so',
106
'/usr/lib/httpd/modules/mod_authz_host.so',
107
'/usr/lib64/apache2/mod_authz_host.so',
108
'/usr/lib/apache2/mod_authz_host.so',
109
'/usr/lib/apache2/modules/mod_authz_host.so');
112
foreach $file (@known_locations) {
121
my @known_locations = ('/usr/sbin/apache2',
125
foreach $file (@known_locations) {
133
sub setup_dynpath() {
136
mkpath("$root/data/", {error => \my $err});
138
print "ERROR: could not create directory '$root/data'\n";