Compare commits

...

3 Commits

Author SHA1 Message Date
d0152c3ec7 dropshell release 2025.0518.1150
Some checks failed
Dropshell Test / Build_and_Test (push) Has been cancelled
2025-05-18 11:50:23 +12:00
ebb101e381 dropshell release 2025.0518.1145
Some checks failed
Dropshell Test / Build_and_Test (push) Has been cancelled
2025-05-18 11:45:37 +12:00
dc2f694ebe .
Some checks failed
Dropshell Test / Build_and_Test (push) Has been cancelled
2025-05-17 23:12:43 +12:00
6 changed files with 91 additions and 8 deletions

View File

@ -63,7 +63,7 @@ void show_command(const std::string& cmd) {
} }
std::cout << " "; std::cout << " ";
print_left_aligned(cmd_info->help_usage, 30); print_left_aligned(cmd_info->help_usage, 32);
std::cout << cmd_info->help_description << std::endl; std::cout << cmd_info->help_description << std::endl;
} }

View File

@ -35,8 +35,8 @@ namespace dropshell
false, // requires_install false, // requires_install
0, // min_args (after command) 0, // min_args (after command)
2, // max_args (after command) 2, // max_args (after command)
"install SERVER [SERVICE|all]", "install [SERVER] [SERVICE|all]",
"Install/reinstall service(s). Safe/non-destructive way to update.", "Install/reinstall host, remote servers, or service(s). Safe/non-destructive way to update.",
// heredoc // heredoc
R"( R"(
Install components on a server. This is safe to re-run (non-destructive) and used to update Install components on a server. This is safe to re-run (non-destructive) and used to update

View File

@ -7,6 +7,7 @@
#include "tableprint.hpp" #include "tableprint.hpp"
#include "transwarp.hpp" #include "transwarp.hpp"
#include "server_env_manager.hpp" #include "server_env_manager.hpp"
#include "services.hpp"
#include <unistd.h> #include <unistd.h>
#include <cstring> #include <cstring>
@ -161,7 +162,7 @@ void show_server_details(const std::string& server_name) {
// list services, and run healthcheck on each // list services, and run healthcheck on each
{ {
tableprint tp("Services: " + server_name, false); tableprint tp("Services: " + server_name, false);
tp.add_row({"Status", "Service", "Ports"}); tp.add_row({"Status", "Service", "Template","Ports"});
std::map<std::string, shared_commands::ServiceStatus> status = shared_commands::get_all_services_status(server_name); std::map<std::string, shared_commands::ServiceStatus> status = shared_commands::get_all_services_status(server_name);
@ -175,7 +176,7 @@ void show_server_details(const std::string& server_name) {
for (const auto& port : service_status.ports) for (const auto& port : service_status.ports)
ports_str += std::to_string(port) + " "; ports_str += std::to_string(port) + " ";
tp.add_row({healthy, service_name, ports_str}); tp.add_row({healthy, service_name, get_service_info(server_name,service_name).template_name, ports_str});
} // end of for (const auto& service : services) } // end of for (const auto& service : services)
tp.print(); tp.print();
} // end of list services } // end of list services

View File

@ -10,8 +10,6 @@
#include "utils/assert.hpp" #include "utils/assert.hpp"
#pragma message ("TODO: Fix issues with Nuke below.")
namespace dropshell { namespace dropshell {
int nuke_handler(const CommandContext& ctx); int nuke_handler(const CommandContext& ctx);
@ -67,11 +65,14 @@ int nuke_one(std::string server, std::string service)
// otherwise just uninstall. // otherwise just uninstall.
if (gTemplateManager().template_command_exists(service_info.template_name, "nuke")) if (gTemplateManager().template_command_exists(service_info.template_name, "nuke"))
{ {
std::cout << "Running nuke script for " << service << " on " << server << std::endl;
if (!server_env.run_remote_template_command(service, "nuke", {}, false, {})) if (!server_env.run_remote_template_command(service, "nuke", {}, false, {}))
std::cerr << "Warning: Failed to run nuke script: " << service << std::endl; std::cerr << "Warning: Failed to run nuke script: " << service << std::endl;
} }
else else
{ {
std::cout << "No nuke script found for " << service << " on " << server << std::endl;
std::cout << "Running uninstall script instead and will clean directories." << std::endl;
if (!server_env.run_remote_template_command(service, "uninstall", {}, false, {})) if (!server_env.run_remote_template_command(service, "uninstall", {}, false, {}))
std::cerr << "Warning: Failed to uninstall service: " << service << std::endl; std::cerr << "Warning: Failed to uninstall service: " << service << std::endl;
} }

View File

@ -0,0 +1,81 @@
#include "command_registry.hpp"
#include "config.hpp"
#include "utils/utils.hpp"
#include "utils/directories.hpp"
#include "shared_commands.hpp"
#include "server_env_manager.hpp"
#include "services.hpp"
#include "servers.hpp"
namespace dropshell
{
int ssh_handler(const CommandContext &ctx);
static std::vector<std::string> ssh_name_list = {"ssh"};
// Static registration
struct SSHCommandRegister
{
SSHCommandRegister()
{
CommandRegistry::instance().register_command({ssh_name_list,
ssh_handler,
shared_commands::std_autocomplete,
false, // hidden
true, // requires_config
true, // requires_install
1, // min_args (after command)
2, // max_args (after command)
"ssh SERVER",
"SSH into a server, or into a docker container for a service.",
R"(
ssh SERVER SERVICE SSH into a docker container for a service.
ssh SERVER SSH into a server.
)"});
}
} ssh_command_register;
bool ssh_into_server(const std::string &server)
{
server_env_manager server_env(server);
if (!server_env.is_valid())
{
std::cerr << "Error: Server " << server << " is not valid" << std::endl;
return false;
}
execute_ssh_command(server_env.get_SSH_INFO(), sCommand(remotepath::DROPSHELL_DIR(server), "ls --color && bash", {}), cMode::Interactive);
return true;
}
bool ssh_into_service(const std::string &server, const std::string &service)
{
return true;
}
int ssh_handler(const CommandContext &ctx)
{
if (ctx.args.size() < 1)
{
std::cerr << "Error: Server name is required" << std::endl;
return 1;
}
std::string server = safearg(ctx.args, 0);
if (ctx.args.size() < 2)
{
// ssh into the server
return ssh_into_server(server) ? 0 : 1;
}
std::string service = safearg(ctx.args, 1);
// ssh into the specific service.
return ssh_into_service(server, service) ? 0 : 1;
}
} // namespace dropshell

View File

@ -204,7 +204,7 @@ bool server_env_manager::run_remote_template_command(const std::string &service_
if (scommand->get_command_to_run().empty()) if (scommand->get_command_to_run().empty())
return false; return false;
cMode mode = (command=="ssh") ? (cMode::Interactive) : cMode::Silent; cMode mode = (command=="ssh") ? (cMode::Interactive) : (silent ? cMode::Silent : cMode::Defaults);
return execute_ssh_command(get_SSH_INFO(), scommand.value(), mode); return execute_ssh_command(get_SSH_INFO(), scommand.value(), mode);
} }