Add $HOST variable to install_config.json to make installer deploy easier

This commit is contained in:
Eric Harding committed 2018-06-20 11:22:00 -04:00
1 parent 33a1762cb7
commit a2b8d53ebb
1 file changed
+12 -1
+12 -1
View File
@@ -217,11 +217,22 @@ namespace http {
con->set_body(read_file(path.string()));
con->set_status(websocketpp::http::status_code::ok);
}
void return_bts_installer(connection_ptr& con) {
std::string installer_bits = read_file(_www+"/bts_installer.exe");
const std::string installer_config = _www+"install_config.json";
if (boost::filesystem::is_regular_file(installer_config)) {
installer_bits += read_file(installer_config);
auto conf = read_file(installer_config);
std::string needle = "$HOST";
std::size_t pos;
do {
pos = conf.find(needle,0);
if (pos != std::string::npos) {
auto host = con->get_uri()->get_host();
conf.replace(pos, needle.size(), host);
}
} while(pos != std::string::npos);
installer_bits += conf;
}
con->set_body(installer_bits);
con->set_status(websocketpp::http::status_code::ok);