dropshell release 2025.0518.1355
Some checks failed
Dropshell Test / Build_and_Test (push) Has been cancelled
Some checks failed
Dropshell Test / Build_and_Test (push) Has been cancelled
This commit is contained in:
@ -7,6 +7,7 @@
|
||||
#include "utils/hash.hpp"
|
||||
#include "autogen/_agent.hpp"
|
||||
#include "services.hpp"
|
||||
#include "utils/output.hpp"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <cstring>
|
||||
@ -100,7 +101,7 @@ namespace dropshell
|
||||
}
|
||||
|
||||
// Copy template files
|
||||
std::cout << "Copying: [LOCAL] " << tinfo.local_template_path() << std::endl
|
||||
debug << "Copying: [LOCAL] " << tinfo.local_template_path() << std::endl
|
||||
<< std::string(8, ' ') << "[REMOTE] " << remotepath::service_template(server, service) << "/" << std::endl;
|
||||
if (!shared_commands::rsync_tree_to_remote(tinfo.local_template_path().string(), remotepath::service_template(server, service),
|
||||
server_env, silent))
|
||||
@ -110,7 +111,7 @@ namespace dropshell
|
||||
}
|
||||
|
||||
// Copy service files
|
||||
std::cout << "Copying: [LOCAL] " << localpath::service(server, service) << std::endl
|
||||
debug << "Copying: [LOCAL] " << localpath::service(server, service) << std::endl
|
||||
<< std::string(8, ' ') << "[REMOTE] " << remotepath::service_config(server, service) << std::endl;
|
||||
if (!shared_commands::rsync_tree_to_remote(localpath::service(server, service), remotepath::service_config(server, service),
|
||||
server_env, silent))
|
||||
@ -121,12 +122,12 @@ namespace dropshell
|
||||
|
||||
// Run install script
|
||||
{
|
||||
std::cout << "Running " << service_info.template_name << " install script on " << server << "..." << std::endl;
|
||||
info << "Running " << service_info.template_name << " install script on " << server << "..." << std::endl;
|
||||
server_env.run_remote_template_command(service, "install", {}, silent, {});
|
||||
}
|
||||
|
||||
// print health tick
|
||||
std::cout << "Health: " << shared_commands::healthtick(server, service) << std::endl;
|
||||
info << "Health: " << shared_commands::healthtick(server, service) << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -281,30 +282,30 @@ namespace dropshell
|
||||
int install_server(const std::string &server)
|
||||
{
|
||||
// install the dropshell agent on the given server.
|
||||
std::cout << "Installing dropshell agent on " << server << std::endl;
|
||||
maketitle("Installing dropshell agent on " + server, sColour::INFO);
|
||||
|
||||
std::string agent_path = remotepath::agent(server);
|
||||
if (agent_path.empty())
|
||||
{
|
||||
std::cerr << "Failed to get agent path for " << server << std::endl;
|
||||
error << "Failed to get agent path for " << server << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
server_env_manager server_env(server);
|
||||
if (!server_env.is_valid())
|
||||
{
|
||||
std::cerr << "Invalid server environment for " << server << std::endl;
|
||||
error << "Invalid server environment for " << server << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
// now create the agent.
|
||||
// copy across from the local agent files.
|
||||
std::cout << "Copying local agent files to remote server... " << std::flush;
|
||||
info << "Copying local agent files to remote server... " << std::flush;
|
||||
shared_commands::rsync_tree_to_remote(localpath::files_for_remote_agent(), agent_path, server_env, false);
|
||||
std::cout << "done." << std::endl;
|
||||
info << "done." << std::endl;
|
||||
|
||||
// add in bb64. We can't use execute_remote_command() here, as that relies on bb64 which we're installing!
|
||||
std::cout << "Installing bb64 on " << server << "..." << std::endl << std::flush;
|
||||
info << "Installing bb64 on " << server << "..." << std::endl << std::flush;
|
||||
|
||||
std::string remote_cmd =
|
||||
"ssh -p " + server_env.get_SSH_INFO().port + " " + server_env.get_SSH_INFO().user + "@" + server_env.get_SSH_INFO().host +
|
||||
@ -313,23 +314,19 @@ namespace dropshell
|
||||
|
||||
//std::cout << "Executing: " << remote_cmd << std::endl;
|
||||
if (!execute_local_command("", remote_cmd, {}, nullptr, cMode::Silent))
|
||||
std::cerr << "Failed to download bb64 to " << agent_path << " on remote server." << std::endl;
|
||||
error << "Failed to download bb64 to " << agent_path << " on remote server." << std::endl;
|
||||
else
|
||||
std::cout << "Downloaded bb64 to " << agent_path << " on remote server." << std::endl;
|
||||
|
||||
// just test all is ok
|
||||
debug << "Downloaded bb64 to " << agent_path << " on remote server." << std::endl;
|
||||
|
||||
// run the self-test.
|
||||
std::string output;
|
||||
bool okay = execute_ssh_command(server_env.get_SSH_INFO(), sCommand(agent_path, "./selftest.sh", {}), cMode::Defaults, &output);
|
||||
bool okay = execute_ssh_command(server_env.get_SSH_INFO(), sCommand(agent_path, "./selftest.sh", {}), cMode::Defaults, nullptr);
|
||||
if (!okay)
|
||||
{
|
||||
std::cerr << "ERROR: Failed to install remote agent on " << server << std::endl;
|
||||
std::cerr << "ERROR: Output: " << output << std::endl;
|
||||
error << "ERROR: Failed to install remote agent on " << server << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::cout << output << std::endl;
|
||||
info << "Installation on " << server << " complete." << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -345,7 +342,7 @@ namespace dropshell
|
||||
|
||||
if (!gConfig().is_config_set())
|
||||
{
|
||||
std::cerr << "Error: Dropshell is not configured. Please run 'dropshell edit' to configure it." << std::endl;
|
||||
error << "Dropshell is not configured. Please run 'dropshell edit' to configure it." << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ int list_handler(const CommandContext& ctx) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::cout << "List handler called with " << ctx.args.size() << " args\n";
|
||||
debug << "List handler called with " << ctx.args.size() << " args\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -74,16 +74,16 @@ void list_servers() {
|
||||
auto servers = get_configured_servers();
|
||||
|
||||
if (servers.empty()) {
|
||||
std::cout << "No servers found" << std::endl;
|
||||
std::cout << "Please run 'dropshell edit' to set up dropshell." << std::endl;
|
||||
std::cout << "Then run 'dropshell create-server' to create a server." << std::endl;
|
||||
error << "No servers found" << std::endl;
|
||||
info << "Please run 'dropshell edit' to set up dropshell." << std::endl;
|
||||
info << "Then run 'dropshell create-server' to create a server." << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
tableprint tp("All DropShell Servers");
|
||||
tp.add_row({"Name", "User", "Address", "Health", "Ports"});
|
||||
|
||||
std::cout << "Checking "<<servers.size() << " servers: " << std::flush;
|
||||
info << "Checking "<<servers.size() << " servers: " << std::flush;
|
||||
int checked = 0;
|
||||
|
||||
transwarp::parallel exec{servers.size()};
|
||||
@ -103,10 +103,10 @@ void list_servers() {
|
||||
tp.add_row({server.name, server.ssh_user, server.ssh_host, serviceticks, ports_used_str});
|
||||
++checked;
|
||||
// print out a tick character for each server checked.
|
||||
std::cout << checked << " ✓ " << std::flush;
|
||||
info << checked << " ✓ " << std::flush;
|
||||
});
|
||||
task->wait();
|
||||
std::cout << std::endl << std::endl;
|
||||
info << std::endl << std::endl;
|
||||
tp.print();
|
||||
}
|
||||
|
||||
@ -116,7 +116,7 @@ void list_servers() {
|
||||
void show_server_details(const std::string& server_name) {
|
||||
server_env_manager env(server_name);
|
||||
if (!env.is_valid()) {
|
||||
std::cerr << "Error: Invalid server environment file: " << server_name << std::endl;
|
||||
error << "Error: Invalid server environment file: " << server_name << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -126,14 +126,14 @@ void show_server_details(const std::string& server_name) {
|
||||
std::string ssh_user = env.get_SSH_USER();
|
||||
std::string ssh_port = env.get_SSH_PORT();
|
||||
if (!ssh_address.empty()) {
|
||||
std::cout << std::endl << "Server Status:" << std::endl;
|
||||
std::cout << std::string(40, '-') << std::endl;
|
||||
info << std::endl << "Server Status:" << std::endl;
|
||||
info << std::string(40, '-') << std::endl;
|
||||
|
||||
// Try to connect to the server
|
||||
std::string cmd = "ssh -o ConnectTimeout=5 " + ssh_user + "@" + ssh_address + " -p " + ssh_port + " 'echo connected' 2>/dev/null";
|
||||
int result = system(cmd.c_str());
|
||||
if (result == 0) {
|
||||
std::cout << "Status: Online" << std::endl;
|
||||
info << "Status: Online" << std::endl;
|
||||
|
||||
// // Get uptime if possible
|
||||
// cmd = "ssh " + ssh_address + " 'uptime' 2>/dev/null";
|
||||
@ -142,10 +142,10 @@ void show_server_details(const std::string& server_name) {
|
||||
// std::cout << "Error: Failed to get uptime" << std::endl;
|
||||
// }
|
||||
} else {
|
||||
std::cout << "Status: Offline" << std::endl;
|
||||
warning << "Status: Offline" << std::endl;
|
||||
}
|
||||
}
|
||||
std::cout << std::endl;
|
||||
info << std::endl;
|
||||
|
||||
//---------------------
|
||||
{
|
||||
|
@ -119,7 +119,11 @@ namespace dropshell
|
||||
}
|
||||
|
||||
std::string output;
|
||||
if (!execute_ssh_command(env.get_SSH_INFO(), sCommand(remotepath::agent(server_name), "./_allservicesstatus.sh", {{"HOST_NAME", server_name}, {"SERVER", server_name}, {"AGENT_PATH", remotepath::agent(server_name)}}), cMode::CaptureOutput, &output))
|
||||
if (!execute_ssh_command(env.get_SSH_INFO(), sCommand(remotepath::agent(server_name),
|
||||
"./_allservicesstatus.sh",
|
||||
{{"HOST_NAME", server_name}, {"SERVER", server_name}, {"AGENT_PATH", remotepath::agent(server_name)}}),
|
||||
cMode::CaptureOutput | cMode::Silent,
|
||||
&output))
|
||||
return status;
|
||||
|
||||
std::stringstream ss(output);
|
||||
|
Reference in New Issue
Block a user