Skip to content

Commit 6ead253

Browse files
committedJan 8, 2012
Move demo setup into its own file, add webgui log file setup
1 parent 9822078 commit 6ead253

File tree

2 files changed

+92
-6
lines changed

2 files changed

+92
-6
lines changed
 

‎wre/sbin/wredemosetup.pl

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#!/data/wre/prereqs/bin/perl
2+
3+
#-------------------------------------------------------------------
4+
# WRE is Copyright 2005-2012 Plain Black Corporation.
5+
#-------------------------------------------------------------------
6+
# Please read the legal notices (docs/legal.txt) and the license
7+
# (docs/license.txt) that came with this distribution before using
8+
# this software.
9+
#-------------------------------------------------------------------
10+
# http://www.plainblack.com info@plainblack.com
11+
#-------------------------------------------------------------------
12+
13+
use strict;
14+
use lib '/data/wre/lib';
15+
use WRE::Config;
16+
use WRE::File;
17+
use WRE::Host;
18+
use Getopt::Long ();
19+
use Pod::Usage ();
20+
21+
my $help;
22+
23+
use 5.010;
24+
25+
Getopt::Long::GetOptions(
26+
'help'=>\$help
27+
);
28+
29+
Pod::Usage::pod2usage( verbose => 2 ) if $help;
30+
31+
#-------------------------------------------------------------------
32+
# server daemon
33+
my $config = WRE::Config->new;
34+
my $host = WRE::Host->new(wreConfig => $config);
35+
my $file = WRE::File->new(wreConfig => $config);
36+
37+
if ($config->get('demo/enabled') {
38+
say "Setting up demo files";
39+
$file->makePath($config->getDomainRoot("/demo"));
40+
$file->copy($config->getRoot("/var/setupfiles/demo.nginx"), $config->getRoot("/etc/demo.nginx"),
41+
{ force => 1, templateVars=>{ sitename=>$config->get("demo/hostname") } });
42+
}
43+
else {
44+
say "Skipping demo files";
45+
}
46+
47+
48+
49+
__END__
50+
51+
=head1 NAME
52+
53+
wredemosetup.pl
54+
55+
=head1 SYNOPSIS
56+
57+
./wredemosetup.pl
58+
59+
=head1 DESCRIPTION
60+
61+
Sets up the demo server on this instance by installing various config files and servers.
62+
63+
=over
64+
65+
=item B<--help>
66+
67+
Shows this documentation and then exits.
68+
69+
=back
70+
71+
=head1 AUTHOR
72+
73+
Copyright 2001-2012 Plain Black Corporation.
74+
75+
=cut
76+

‎wre/sbin/wresetup.pl

+16-6
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,6 @@
3434
my $host = WRE::Host->new(wreConfig => $config);
3535
my $file = WRE::File->new(wreConfig => $config);
3636

37-
say "Setting up demo files";
38-
$file->makePath($config->getDomainRoot("/demo"));
39-
$file->copy($config->getRoot("/var/setupfiles/demo.nginx"), $config->getRoot("/etc/demo.nginx"),
40-
{ force => 1, templateVars=>{ sitename=>$config->get("demo/hostname") } });
41-
4237
say "Setting up nginx main config";
4338
$file->copy($config->getRoot("/var/setupfiles/nginx.conf"),
4439
$config->getRoot("/etc/nginx.conf"),
@@ -62,6 +57,21 @@
6257
{ force => 1 });
6358
$file->changeOwner($config->getWebguiRoot("/etc"));
6459

60+
say "Setting up WebGUI logging";
61+
eval {
62+
open my $in, '<', $config->getWebguiRoot("/etc/log.conf.original")
63+
or die "Unable to open '" . $config->getWebguiRoot("/etc/log.conf.original") . "': $!\n";
64+
open my $out, '>', $config->getWebguiRoot("/etc/log.conf")
65+
or die "Unable to open '" . $config->getWebguiRoot("/etc/log.conf") . "': $!\n";
66+
while (my $line = <$in>) {
67+
$line =~ s{/var/log/webgui\.log}{ $config->getRoot("/var/logs/webgui.log") }ge;
68+
print {$out} $line;
69+
}
70+
close $out;
71+
close $in;
72+
};
73+
74+
6575
say "Creating log and run directory";
6676
$file->makePath($config->getRoot("/var/logs"));
6777
$file->makePath($config->getRoot("/var/run"));
@@ -74,7 +84,7 @@ =head1 NAME
7484
7585
=head1 SYNOPSIS
7686
77-
./wresetup.pl --configFile=/data/wre/etc/wre.conf
87+
wresetup.pl
7888
7989
=head1 DESCRIPTION
8090

0 commit comments

Comments
 (0)
Please sign in to comment.