Support additional config per-server files for services.

This commit is contained in:
Your Name 2025-04-25 18:06:23 +12:00
parent 09035aa2aa
commit 0be0b71056
2 changed files with 7 additions and 6 deletions

View File

@ -44,7 +44,7 @@ bool service_runner::init(const std::string& server_name, const std::string& ser
mRemote_service_config_path = get_remote_service_config_path(m_server_name, m_service_info.service_name); mRemote_service_config_path = get_remote_service_config_path(m_server_name, m_service_info.service_name);
mRemote_service_template_path = get_remote_service_template_path(m_server_name, m_service_info.service_name); mRemote_service_template_path = get_remote_service_template_path(m_server_name, m_service_info.service_name);
mRemote_service_env_file = get_remote_service_env_file(m_server_name, m_service_info.service_name); mRemote_service_env_file = get_remote_service_env_file(m_server_name, m_service_info.service_name);
return !m_service_info.path.empty(); return !m_service_info.path.empty();
} }
@ -152,7 +152,7 @@ bool service_runner::install() {
// Run install script // Run install script
{ {
std::string install_cmd = "'cd " + mRemote_service_template_path + std::string install_cmd = "'cd " + mRemote_service_template_path +
" && /bin/bash install.sh " + mRemote_service_env_file + "'"; " && /bin/bash install.sh " + mRemote_service_config_path + "'";
bool ok= execute_ssh_command(install_cmd, "Failed to run install script"); bool ok= execute_ssh_command(install_cmd, "Failed to run install script");
if (!ok) if (!ok)
return false; return false;
@ -180,7 +180,7 @@ bool service_runner::uninstall() {
if (script_exists) { if (script_exists) {
std::string uninstall_cmd = "'cd " + mRemote_service_template_path + std::string uninstall_cmd = "'cd " + mRemote_service_template_path +
" && /bin/bash _uninstall.sh " + mRemote_service_env_file + "'"; " && /bin/bash _uninstall.sh " + mRemote_service_config_path + "'";
if (!execute_ssh_command(uninstall_cmd, "Failed to run uninstall script")) { if (!execute_ssh_command(uninstall_cmd, "Failed to run uninstall script")) {
std::cerr << "Warning: Uninstall script failed, but continuing with directory removal" << std::endl; std::cerr << "Warning: Uninstall script failed, but continuing with directory removal" << std::endl;
} }
@ -242,7 +242,7 @@ bool service_runner::run_command(const std::string& command) {
// Run the generic command // Run the generic command
std::string run_cmd = "'cd " + mRemote_service_template_path + std::string run_cmd = "'cd " + mRemote_service_template_path +
" && /bin/bash " + script_path + " " + mRemote_service_env_file + "'"; " && /bin/bash " + script_path + " " + mRemote_service_config_path + "'";
return execute_ssh_command(run_cmd, "Command returned error code: " + script_path); return execute_ssh_command(run_cmd, "Command returned error code: " + script_path);
} }
@ -335,7 +335,7 @@ service_runner::HealthStatus service_runner::is_healthy()
} }
// Run status script, does not display output. // Run status script, does not display output.
bool ok = execute_ssh_command("'cd " + mRemote_service_template_path + " && /bin/bash " + script_path + " " + mRemote_service_env_file + " > /dev/null 2>&1'", ""); bool ok = execute_ssh_command("'cd " + mRemote_service_template_path + " && /bin/bash " + script_path + " " + mRemote_service_config_path + " > /dev/null 2>&1'", "");
if (!ok) if (!ok)
return HealthStatus::UNHEALTHY; return HealthStatus::UNHEALTHY;
@ -395,7 +395,7 @@ std::vector<int> service_runner::get_ports()
// Run the ports script and capture output // Run the ports script and capture output
std::string run_cmd = "'cd " + mRemote_service_template_path + std::string run_cmd = "'cd " + mRemote_service_template_path +
" && /bin/bash " + script_path + " " + mRemote_service_env_file + "'"; " && /bin/bash " + script_path + " " + mRemote_service_config_path + "'";
// Create a temporary file to store the output // Create a temporary file to store the output
std::string temp_file = "/tmp/dropshell_ports_" + std::to_string(getpid()); std::string temp_file = "/tmp/dropshell_ports_" + std::to_string(getpid());

View File

@ -37,6 +37,7 @@ namespace dropshell {
std::string get_remote_service_backups_path(const std::string &server_name, const std::string &service_name); std::string get_remote_service_backups_path(const std::string &server_name, const std::string &service_name);
std::string get_remote_service_env_file(const std::string &server_name, const std::string &service_name); std::string get_remote_service_env_file(const std::string &server_name, const std::string &service_name);
std::string get_remote_service_env_file_parent(const std::string &server_name, const std::string &service_name);
} // namespace dropshell } // namespace dropshell
#endif #endif