This commit is contained in:
Your Name
2025-04-25 10:48:38 +12:00
parent 5dd4a9dce6
commit 5e8ec90064
25 changed files with 566 additions and 64 deletions

View File

@ -100,9 +100,8 @@ bool service_runner::install() {
}
// Check if template exists
template_manager tm;
template_info tinfo;
if (!tm.get_template_info(m_service_info.template_name, tinfo)) {
if (!get_template_info(m_service_info.template_name, tinfo)) {
std::cerr << "Error: Template '" << m_service_info.template_name << "' not found" << std::endl;
return false;
}
@ -164,6 +163,11 @@ bool service_runner::run_command(const std::string& command) {
return false;
}
if (!template_command_exists(m_service_info.template_name, command)) {
std::cout << "No command script for " << m_service_info.template_name << " : " << command << std::endl;
return true; // nothing to run.
}
std::string script_path = mRemote_service_template_path + "/" + command + ".sh";
// Check if service directory exists
@ -195,7 +199,13 @@ bool service_runner::backup() {
return false;
}
std::string script_path = mRemote_service_template_path + "/_backup.sh";
std::string command = "_backup";
std::string script_path = mRemote_service_template_path + "/" + command + ".sh";
if (!template_command_exists(m_service_info.template_name, command)) {
std::cout << "No backup script for " << m_service_info.template_name << std::endl;
return true; // nothing to back up.
}
// Check if basic installed stuff is in place.
if (!check_remote_dir_exists(mRemote_service_path) || !check_remote_file_exists(script_path) || !check_remote_file_exists(mRemote_service_env_file))
@ -252,7 +262,13 @@ service_runner::HealthStatus service_runner::is_healthy()
}
// Check if status script exists
std::string script_path = mRemote_service_template_path + "/_status.sh";
std::string command = "_status";
if (!template_command_exists(m_service_info.template_name, command)) {
return HealthStatus::UNKNOWN;
}
std::string script_path = mRemote_service_template_path + "/" + command + ".sh";
if (!check_remote_file_exists(script_path)) {
return HealthStatus::NOTINSTALLED;
}
@ -270,16 +286,34 @@ std::string service_runner::healthtick()
std::string green_tick = "\033[32m✓\033[0m";
std::string red_cross = "\033[31m✗\033[0m";
std::string yellow_exclamation = "\033[33m!\033[0m";
std::string unknown = "\033[33m?\033[0m";
HealthStatus status = is_healthy();
if (status == HealthStatus::HEALTHY)
return green_tick;
else if (status == HealthStatus::UNHEALTHY)
return red_cross;
else if (status == HealthStatus::UNKNOWN)
return unknown;
else
return yellow_exclamation;
}
std::string service_runner::healthmark()
{
HealthStatus status = is_healthy();
if (status == HealthStatus::HEALTHY)
return ":tick:";
else if (status == HealthStatus::UNHEALTHY)
return ":cross:";
else if (status == HealthStatus::UNKNOWN)
return ":question:";
else if (status == HealthStatus::NOTINSTALLED)
return ":warning:";
else
return ":error:";
}
std::vector<int> service_runner::get_ports()
{
std::vector<int> ports;