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
|
#!/usr/bin/perl
use strict;
use warnings;
use lib qw(/app /opt/bmo/local/lib/perl5);
use Getopt::Long qw(:config gnu_getopt);
use Data::Dumper;
use Bugzilla::Install::Localconfig ();
use Bugzilla::Install::Util qw(install_string);
my %localconfig = (webservergroup => 'app');
my %override = (
'inbound_proxies' => 1,
'shadowdb' => 1,
'shadowdbhost' => 1,
'shadowdbport' => 1,
'shadowdbsock' => 1
);
# clean env.
foreach my $key (keys %ENV) {
if ($key =~ /^BMO_(.+)$/) {
my $name = $1;
if ($override{$name}) {
$localconfig{param_override}{$name} = delete $ENV{$key};
}
else {
$localconfig{$name} = delete $ENV{$key};
}
}
}
write_localconfig(\%localconfig);
system("perl", "checksetup.pl", "--no-templates", "--no-permissions", '--no-assets');
my $cmd = shift @ARGV or die "usage: init.pl CMD";
my $method = "run_$cmd";
__PACKAGE__->$method();
sub run_httpd {
exec("/usr/sbin/httpd", "-DFOREGROUND", "-f", "/opt/bmo/httpd/httpd.conf");
}
sub run_shell {
exec("/bin/bash", "-l");
}
sub write_localconfig {
my ($localconfig) = @_;
no warnings 'once';
foreach my $var (Bugzilla::Install::Localconfig::LOCALCONFIG_VARS) {
my $name = $var->{name};
my $value = $localconfig->{$name};
if (!defined $value) {
$var->{default} = &{$var->{default}} if ref($var->{default}) eq 'CODE';
$localconfig->{$name} = $var->{default};
}
}
my $filename = "/app/localconfig";
# Ensure output is sorted and deterministic
local $Data::Dumper::Sortkeys = 1;
# Re-write localconfig
open my $fh, ">:utf8", $filename or die "$filename: $!";
foreach my $var (Bugzilla::Install::Localconfig::LOCALCONFIG_VARS) {
my $name = $var->{name};
my $desc = install_string("localconfig_$name", { root => Bugzilla::Install::Localconfig::ROOT_USER });
chomp($desc);
# Make the description into a comment.
$desc =~ s/^/# /mg;
print $fh $desc, "\n",
Data::Dumper->Dump([$localconfig->{$name}],
["*$name"]), "\n";
}
close $fh;
}
|