dropshell release 2025.0519.0021
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:
@ -5,7 +5,8 @@
|
||||
#include "templates.hpp"
|
||||
#include "shared_commands.hpp"
|
||||
#include "utils/hash.hpp"
|
||||
#include "autogen/_agent.hpp"
|
||||
#include "autogen/_agent-local.hpp"
|
||||
#include "autogen/_agent-remote.hpp"
|
||||
#include "services.hpp"
|
||||
#include "utils/output.hpp"
|
||||
|
||||
@ -248,24 +249,15 @@ namespace dropshell
|
||||
std::filesystem::create_directories(p);
|
||||
}
|
||||
|
||||
// download bb64 for the host architecture.
|
||||
if (!std::filesystem::exists(localpath::agent() + "bb64"))
|
||||
{
|
||||
std::string cmd = "cd " + localpath::agent() + " && curl -fsSL -o bb64 https://gitea.jde.nz/public/bb64/releases/download/latest/bb64.amd64 && chmod a+x bb64";
|
||||
int ret = system(cmd.c_str());
|
||||
if (EXITSTATUSCHECK(ret))
|
||||
info << "Downloaded local bb64 to " << localpath::agent() << std::endl;
|
||||
else
|
||||
error << "Failed to download local bb64 to " << localpath::agent() << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
info << "Updating local bb64..." << std::endl;
|
||||
system((localpath::agent() + "bb64 -u").c_str()); // update.
|
||||
}
|
||||
// create the agent-local directory.
|
||||
recreate_agent_local::recreate_tree(localpath::agent());
|
||||
|
||||
// run the local agent installer.
|
||||
execute_local_command(localpath::agent(), "agent-install.sh",{}, nullptr, cMode::Defaults | cMode::NoBB64);
|
||||
|
||||
// create the agent-remote directory.
|
||||
info << "Creating local files to copy to remote agents..." << std::endl;
|
||||
recreate_agent::recreate_tree(localpath::files_for_remote_agent());
|
||||
recreate_agent_remote::recreate_tree(localpath::files_for_remote_agent());
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -295,23 +287,9 @@ namespace dropshell
|
||||
shared_commands::rsync_tree_to_remote(localpath::files_for_remote_agent(), agent_path, server_env, false);
|
||||
info << "done." << std::endl;
|
||||
|
||||
// add in bb64. We can't use execute_remote_command() here, as that relies on bb64 which we're installing!
|
||||
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 +
|
||||
" 'mkdir -p " + quote(agent_path) + " && curl -fsSL \"https://gitea.jde.nz/public/bb64/releases/download/latest/install.sh\" | bash -s -- " +
|
||||
quote(agent_path) + " " + quote("$(id -u " + server_env.get_SSH_USER() + "):$(id -g " + server_env.get_SSH_USER() + ")") + "'";
|
||||
|
||||
// std::cout << "Executing: " << remote_cmd << std::endl;
|
||||
if (!execute_local_command("", remote_cmd, {}, nullptr, cMode::Silent))
|
||||
error << "Failed to download bb64 to " << agent_path << " on remote server." << std::endl;
|
||||
else
|
||||
debug << "Downloaded bb64 to " << agent_path << " on remote server." << std::endl;
|
||||
|
||||
// run the self-test.
|
||||
bool okay = execute_ssh_command(server_env.get_SSH_INFO(), sCommand(agent_path, "./selftest.sh", {}), cMode::Defaults, nullptr);
|
||||
// run the agent installer. Can't use BB64 yet, as we're installing it on the remote server.
|
||||
|
||||
bool okay = execute_ssh_command(server_env.get_SSH_INFO(), sCommand(agent_path, "agent-install.sh",{}), cMode::Defaults | cMode::NoBB64, nullptr);
|
||||
if (!okay)
|
||||
{
|
||||
error << "ERROR: Failed to install remote agent on " << server << std::endl;
|
||||
|
@ -127,6 +127,16 @@ namespace dropshell
|
||||
|
||||
ASSERT(backup_details.has_value() && backup_details->is_valid(), "Invalid backup file.");
|
||||
|
||||
debug << "Backup details: " << std::endl;
|
||||
debug << " Backup filename: " << backup_details->get_filename() << std::endl;
|
||||
debug << " Backup template: " << backup_details->get_template_name() << std::endl;
|
||||
debug << " Backup taken from server: " << backup_details->get_server() << std::endl;
|
||||
debug << " Backup taken from service: " << backup_details->get_service() << std::endl;
|
||||
debug << " " << std::endl;
|
||||
debug << "Restoring to:" << std::endl;
|
||||
debug << " Server: " << server << std::endl;
|
||||
debug << " Service: " << service << std::endl;
|
||||
|
||||
std::string local_backups_dir = gConfig().get_local_backup_path();
|
||||
if (local_backups_dir.empty() || !std::filesystem::exists(local_backups_dir))
|
||||
{
|
||||
@ -143,14 +153,11 @@ namespace dropshell
|
||||
if (backup_details->get_template_name() != service_info.template_name)
|
||||
{
|
||||
error << "Error: Backup template does not match service template. Can't restore." << std::endl;
|
||||
debug << "Backup template: " << backup_details->get_template_name() << std::endl;
|
||||
debug << "Service template: " << service_info.template_name << std::endl;
|
||||
debug << "Backup file: " << local_backup_file_path << std::endl;
|
||||
info << "Backup template: " << backup_details->get_template_name() << std::endl;
|
||||
info << "Service template: " << service_info.template_name << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
info << "Restoring " << backup_details->get_datetime() << " backup of " << backup_details->get_service() << " taken from " << backup_details->get_server() << ", onto " << server << "/" << service << std::endl;
|
||||
info << std::endl;
|
||||
warning << "*** ALL DATA FOR " << server << "/" << service << " WILL BE OVERWRITTEN! ***" << std::endl;
|
||||
|
||||
// run the restore script
|
||||
@ -160,9 +167,9 @@ namespace dropshell
|
||||
info << "1) Backing up old service... " << std::endl;
|
||||
if (!shared_commands::backupdata_service(server, service))
|
||||
{
|
||||
error << "Error: Backup failed, restore aborted." << std::endl;
|
||||
error << "You can try using dropshell install " << server << " " << service << " to install the service afresh." << std::endl;
|
||||
error << "Otherwise, stop the service, create and initialise a new one, then restore to that." << std::endl;
|
||||
error << "Backup failed, restore aborted." << std::endl;
|
||||
info << "You can try using dropshell install " << server << " " << service << " to install the service afresh." << std::endl;
|
||||
info << "Otherwise, stop the service, create and initialise a new one, then restore to that." << std::endl;
|
||||
return 1;
|
||||
}
|
||||
info << "Backup complete." << std::endl;
|
||||
|
@ -121,7 +121,7 @@ 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 | cMode::Silent,
|
||||
cMode::Silent,
|
||||
&output))
|
||||
return status;
|
||||
|
||||
|
Reference in New Issue
Block a user