Workign on stuff

This commit is contained in:
John
2025-04-27 11:27:02 +12:00
parent e3e8e5f7d3
commit 8c21260e49
8 changed files with 450 additions and 100 deletions

View File

@ -50,14 +50,20 @@ bool service_runner::install() {
return false;
// Create service directory
std::string mkdir_cmd = "'mkdir -p " + quote(mRemote_service_path) + "'";
if (!m_server_env.execute_ssh_command(mkdir_cmd, "Failed to create service directory"))
std::string mkdir_cmd = "mkdir -p " + quote(mRemote_service_path);
if (!m_server_env.execute_ssh_command(mkdir_cmd))
{
std::cerr << "Failed to create service directory" << std::endl;
return false;
}
// Check if rsync is installed on remote host
std::string check_rsync_cmd = "'which rsync > /dev/null 2>&1'";
if (!m_server_env.execute_ssh_command(check_rsync_cmd, "rsync is not installed on the remote host"))
std::string check_rsync_cmd = "which rsync > /dev/null 2>&1";
if (!m_server_env.execute_ssh_command(check_rsync_cmd))
{
std::cerr << "rsync is not installed on the remote host" << std::endl;
return false;
}
// Copy template files
{
@ -67,7 +73,12 @@ bool service_runner::install() {
m_server_env.get_SSH_USER() + "@" + m_server_env.get_SSH_HOST() + ":" +
quote(mRemote_service_template_path+"/");
//std::cout << std::endl << rsync_cmd << std::endl << std::endl;
m_server_env.execute_local_command(rsync_cmd,"Failed to copy template files");
if (!m_server_env.execute_local_command(rsync_cmd))
{
std::cerr << "Failed to copy template files using rsync" << std::endl;
std::cerr << "Is rsync installed on the remote host?" << std::endl;
return false;
}
}
// Copy service files (including service.env)
@ -82,7 +93,11 @@ bool service_runner::install() {
quote(local_service_path + "/") + " "+
m_server_env.get_SSH_USER() + "@" + m_server_env.get_SSH_HOST() + ":" +
quote(mRemote_service_config_path + "/");
m_server_env.execute_local_command(rsync_cmd,"Failed to copy service files");
if (!m_server_env.execute_local_command(rsync_cmd))
{
std::cerr << "Failed to copy service files using rsync" << std::endl;
return false;
}
}
// Run install script
@ -124,7 +139,8 @@ bool service_runner::uninstall() {
// 4. Remove the service directory from the server
std::string rm_cmd = "'rm -rf " + quote(mRemote_service_path) + "'";
if (!m_server_env.execute_ssh_command(rm_cmd, "Failed to remove service directory")) {
if (!m_server_env.execute_ssh_command(rm_cmd)) {
std::cerr << "Failed to remove service directory" << std::endl;
return false;
}