Skip to content

Commit 6f8c257

Browse files
committedMar 2, 2012
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.
1 parent 1ea5666 commit 6f8c257

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed
 

‎wre/sbin/addsite.pl

+23-3
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
"adminPassword=s" => \$adminPassword,
3838
"databaseUser=s" => \$dbUser,
3939
"databasePassword=s" => \$dbPassword,
40-
"databaseName=s" => \$dbName,
41-
"fromConfig=s" => \$fromConfig,
40+
"databaseName=s" => \$dbName,
41+
"fromConfig=s" => \$fromConfig,
4242
);
4343

4444
my $dbAdminUser = $config->get("mysql/adminUser");
@@ -62,7 +62,9 @@
6262
--sitename The name of the site you'd like to create. For example: www.example.com
6363
or intranet.example.com
6464
65-
--fromConfig Pull the sitename, dbUser and dbPassword from the referenced config file
65+
--fromConfig Pull the sitename, dbUser and dbPassword from the referenced config file to build a new site. Then,
66+
it replaces the newly created config file with the old config file. Handy for moving sites to
67+
new servers.
6668
6769
--var0-9 A series of variables you can use to arbitrary information into the site
6870
creation process. These variables will be exposed to all templates used to
@@ -102,6 +104,24 @@
102104
var8 => $var8,
103105
var9 => $var9,
104106
});
107+
if ($fromConfig) {
108+
##Get the spectre information from the newly created config file.
109+
use Config::JSON;
110+
my $new_config = Config::JSON->new($config->getWebguiRoot('etc/'.$sitename.".conf"));
111+
my $spectreSubnets = $new_config->get('spectreSubnets');
112+
undef $new_config;
113+
114+
##Copy the file over
115+
printf "copying file from %s to %s\n", $fromConfig, $config->getWebguiRoot('etc/'.$sitename.".conf");
116+
use WRE::File;
117+
my $file = WRE::File->new(wreConfig=>$config);
118+
$file->copy($fromConfig, $config->getWebguiRoot('etc/'.$sitename.".conf"), { force => 1 });
119+
120+
##Update the spectre information in the old config
121+
print "Setting new spectre information into old config\n";
122+
my $orig_config = Config::JSON->new($config->getWebguiRoot('etc/'.$sitename.".conf"));
123+
$orig_config->set('spectreSubnets', $spectreSubnets);
124+
}
105125
print $site->sitename." was created. Don't forget to restart the web servers and Spectre.\n";
106126
}
107127
else {

0 commit comments

Comments
 (0)
Please sign in to comment.