Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Extend fromConfig to import the entire old config, and to change the …
…spectre information. Very handy for moving sites between servers while maintaining all config settings.
  • Loading branch information
perlDreamer committed Mar 2, 2012
1 parent 1ea5666 commit 6f8c257
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions wre/sbin/addsite.pl
Expand Up @@ -37,8 +37,8 @@
"adminPassword=s" => \$adminPassword,
"databaseUser=s" => \$dbUser,
"databasePassword=s" => \$dbPassword,
"databaseName=s" => \$dbName,
"fromConfig=s" => \$fromConfig,
"databaseName=s" => \$dbName,
"fromConfig=s" => \$fromConfig,
);

my $dbAdminUser = $config->get("mysql/adminUser");
Expand All @@ -62,7 +62,9 @@
--sitename The name of the site you'd like to create. For example: www.example.com
or intranet.example.com
--fromConfig Pull the sitename, dbUser and dbPassword from the referenced config file
--fromConfig Pull the sitename, dbUser and dbPassword from the referenced config file to build a new site. Then,
it replaces the newly created config file with the old config file. Handy for moving sites to
new servers.
--var0-9 A series of variables you can use to arbitrary information into the site
creation process. These variables will be exposed to all templates used to
Expand Down Expand Up @@ -102,6 +104,24 @@
var8 => $var8,
var9 => $var9,
});
if ($fromConfig) {
##Get the spectre information from the newly created config file.
use Config::JSON;
my $new_config = Config::JSON->new($config->getWebguiRoot('etc/'.$sitename.".conf"));
my $spectreSubnets = $new_config->get('spectreSubnets');
undef $new_config;

##Copy the file over
printf "copying file from %s to %s\n", $fromConfig, $config->getWebguiRoot('etc/'.$sitename.".conf");
use WRE::File;
my $file = WRE::File->new(wreConfig=>$config);
$file->copy($fromConfig, $config->getWebguiRoot('etc/'.$sitename.".conf"), { force => 1 });

##Update the spectre information in the old config
print "Setting new spectre information into old config\n";
my $orig_config = Config::JSON->new($config->getWebguiRoot('etc/'.$sitename.".conf"));
$orig_config->set('spectreSubnets', $spectreSubnets);
}
print $site->sitename." was created. Don't forget to restart the web servers and Spectre.\n";
}
else {
Expand Down

0 comments on commit 6f8c257

Please sign in to comment.