Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Move demo setup into its own file, add webgui log file setup
  • Loading branch information
perlDreamer committed Jan 8, 2012
1 parent 9822078 commit 6ead253
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 6 deletions.
76 changes: 76 additions & 0 deletions wre/sbin/wredemosetup.pl
@@ -0,0 +1,76 @@
#!/data/wre/prereqs/bin/perl

#-------------------------------------------------------------------
# WRE is Copyright 2005-2012 Plain Black Corporation.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------

use strict;
use lib '/data/wre/lib';
use WRE::Config;
use WRE::File;
use WRE::Host;
use Getopt::Long ();
use Pod::Usage ();

my $help;

use 5.010;

Getopt::Long::GetOptions(
'help'=>\$help
);

Pod::Usage::pod2usage( verbose => 2 ) if $help;

#-------------------------------------------------------------------
# server daemon
my $config = WRE::Config->new;
my $host = WRE::Host->new(wreConfig => $config);
my $file = WRE::File->new(wreConfig => $config);

if ($config->get('demo/enabled') {
say "Setting up demo files";
$file->makePath($config->getDomainRoot("/demo"));
$file->copy($config->getRoot("/var/setupfiles/demo.nginx"), $config->getRoot("/etc/demo.nginx"),
{ force => 1, templateVars=>{ sitename=>$config->get("demo/hostname") } });
}
else {
say "Skipping demo files";
}



__END__
=head1 NAME
wredemosetup.pl
=head1 SYNOPSIS
./wredemosetup.pl
=head1 DESCRIPTION
Sets up the demo server on this instance by installing various config files and servers.
=over
=item B<--help>
Shows this documentation and then exits.
=back
=head1 AUTHOR
Copyright 2001-2012 Plain Black Corporation.
=cut
22 changes: 16 additions & 6 deletions wre/sbin/wresetup.pl
Expand Up @@ -34,11 +34,6 @@
my $host = WRE::Host->new(wreConfig => $config);
my $file = WRE::File->new(wreConfig => $config);

say "Setting up demo files";
$file->makePath($config->getDomainRoot("/demo"));
$file->copy($config->getRoot("/var/setupfiles/demo.nginx"), $config->getRoot("/etc/demo.nginx"),
{ force => 1, templateVars=>{ sitename=>$config->get("demo/hostname") } });

say "Setting up nginx main config";
$file->copy($config->getRoot("/var/setupfiles/nginx.conf"),
$config->getRoot("/etc/nginx.conf"),
Expand All @@ -62,6 +57,21 @@
{ force => 1 });
$file->changeOwner($config->getWebguiRoot("/etc"));

say "Setting up WebGUI logging";
eval {
open my $in, '<', $config->getWebguiRoot("/etc/log.conf.original")
or die "Unable to open '" . $config->getWebguiRoot("/etc/log.conf.original") . "': $!\n";
open my $out, '>', $config->getWebguiRoot("/etc/log.conf")
or die "Unable to open '" . $config->getWebguiRoot("/etc/log.conf") . "': $!\n";
while (my $line = <$in>) {
$line =~ s{/var/log/webgui\.log}{ $config->getRoot("/var/logs/webgui.log") }ge;
print {$out} $line;
}
close $out;
close $in;
};


say "Creating log and run directory";
$file->makePath($config->getRoot("/var/logs"));
$file->makePath($config->getRoot("/var/run"));
Expand All @@ -74,7 +84,7 @@ =head1 NAME
=head1 SYNOPSIS
./wresetup.pl --configFile=/data/wre/etc/wre.conf
wresetup.pl
=head1 DESCRIPTION
Expand Down

0 comments on commit 6ead253

Please sign in to comment.