dropshell release 2025.0518.1355
Some checks failed
Dropshell Test / Build_and_Test (push) Has been cancelled

This commit is contained in:
Your Name
2025-05-18 13:55:39 +12:00
parent 314a5fe96a
commit 2b446f80a3
12 changed files with 205 additions and 133 deletions

View File

@@ -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;
}