From a2b8d53ebbdfdb5639bdeb3fa982e71e4b4c721c Mon Sep 17 00:00:00 2001 From: Eric Harding Date: Wed, 20 Jun 2018 11:22:00 -0400 Subject: [PATCH] Add $HOST variable to install_config.json to make installer deploy easier --- src/server/sparkd/http/WebServer.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/server/sparkd/http/WebServer.cpp b/src/server/sparkd/http/WebServer.cpp index 9450b0799..6a6a09327 100644 --- a/src/server/sparkd/http/WebServer.cpp +++ b/src/server/sparkd/http/WebServer.cpp @@ -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);