execute_ssh_command is not returning the correct return code.
Some checks failed
Dropshell Test / Build_and_Test (push) Failing after 22s

This commit is contained in:
Your Name
2025-05-11 21:33:49 +12:00
parent a27dd7638f
commit df03f5ef91
4 changed files with 47 additions and 30 deletions

View File

@ -54,9 +54,9 @@ int nuke_handler(const CommandContext &ctx)
service_info = get_service_info(server, service);
if (!SIvalid(service_info))
std::cerr << "Warning: Invalid service: " << service << std::endl;
else
if (!uninstall_service(server, service, false))
std::cerr << "Warning: Failed to uninstall service: " << service << std::endl;
if (!uninstall_service(server, service, false))
std::cerr << "Warning: Failed to uninstall service: " << service << std::endl;
// run the nuke script on the remote server if it exists.
if (gTemplateManager().template_command_exists(service_info.template_name, "nuke"))
@ -64,16 +64,6 @@ int nuke_handler(const CommandContext &ctx)
if (!server_env.run_remote_template_command(service, "nuke", {}, false, {}))
std::cerr << "Warning: Failed to run nuke script: " << service << std::endl;
}
// remove the remote service directory, running in a docker container as root.
std::string rm_cmd = "docker run --rm -v " + quote(remotepath::service(server, service)) + ":/service alpine rm -rf /service";
if (!execute_ssh_command(server_env.get_SSH_INFO(), sCommand(rm_cmd), cMode::Silent))
{
std::cerr << "Warning: Failed to remove remote service directory" << std::endl;
std::cerr << "You may need to log in and delete it manually." << std::endl;
std::cerr << " ssh " << server << std::endl;
std::cerr << " rm -rf " << remotepath::service(server, service) << std::endl;
}
}
else
std::cerr << "Warning: Invalid server: " << server << std::endl;

View File

@ -1,6 +1,9 @@
#include "command_registry.hpp"
#include "directories.hpp"
#include "shared_commands.hpp"
#include "templates.hpp"
#include <libassert/assert.hpp>
namespace dropshell
{
@ -80,29 +83,24 @@ namespace dropshell
// 3. Run uninstall script if it exists
std::string uninstall_script = remotepath::service_template(server, service) + "/uninstall.sh";
bool script_exists = server_env.check_remote_file_exists(uninstall_script);
if (gTemplateManager().template_command_exists(service, "uninstall"))
if (server_env.check_remote_file_exists(uninstall_script))
if (!server_env.run_remote_template_command(service, "uninstall", {}, silent, {}))
if (!silent)
std::cerr << "Warning: Uninstall script failed, but continuing with directory removal" << std::endl;
if (script_exists)
// 4. Remove the service directory from the server, running in a docker container as root.
if (server_env.remove_remote_dir(remotepath::service(server, service), silent))
{
if (!server_env.run_remote_template_command(service, "uninstall", {}, silent, {}))
if (!silent)
std::cerr << "Warning: Uninstall script failed, but continuing with directory removal" << std::endl;
}
else
ASSERT(!server_env.check_remote_dir_exists(remotepath::service(server, service)), "Service directory still found on server after uninstall");
if (!silent)
std::cerr << "Warning: No uninstall script found, continuing with direcotry removal." << std::endl;
// 4. Remove the service directory from the server
std::string rm_cmd = "rm -rf " + quote(remotepath::service(server, service));
if (!execute_ssh_command(server_env.get_SSH_INFO(), sCommand(rm_cmd), cMode::Silent))
{
if (!silent)
std::cerr << "Failed to remove service directory" << std::endl;
return false;
std::cout << "Removed remote service directory " << remotepath::service(server, service) << std::endl;
}
else if (!silent)
std::cerr << "Warning: Failed to remove remote service directory" << std::endl;
if (!silent)
std::cout << "Service " << service << " successfully uninstalled from " << server << std::endl;
std::cout << "Completed service " << service << " uninstall on " << server << std::endl;
return true;
}