|
37 | 37 | "adminPassword=s" => \$adminPassword,
|
38 | 38 | "databaseUser=s" => \$dbUser,
|
39 | 39 | "databasePassword=s" => \$dbPassword,
|
40 |
| - "databaseName=s" => \$dbName, |
41 |
| - "fromConfig=s" => \$fromConfig, |
| 40 | + "databaseName=s" => \$dbName, |
| 41 | + "fromConfig=s" => \$fromConfig, |
42 | 42 | );
|
43 | 43 |
|
44 | 44 | my $dbAdminUser = $config->get("mysql/adminUser");
|
|
62 | 62 | --sitename The name of the site you'd like to create. For example: www.example.com
|
63 | 63 | or intranet.example.com
|
64 | 64 |
|
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. |
66 | 68 |
|
67 | 69 | --var0-9 A series of variables you can use to arbitrary information into the site
|
68 | 70 | creation process. These variables will be exposed to all templates used to
|
|
102 | 104 | var8 => $var8,
|
103 | 105 | var9 => $var9,
|
104 | 106 | });
|
| 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 | + } |
105 | 125 | print $site->sitename." was created. Don't forget to restart the web servers and Spectre.\n";
|
106 | 126 | }
|
107 | 127 | else {
|
|
0 commit comments