...
Some checks failed
Dropshell Test / Build_and_Test (push) Has been cancelled

This commit is contained in:
Your Name
2025-05-17 11:12:33 +12:00
parent 93e563948f
commit 985153377f
4 changed files with 37 additions and 27 deletions

View File

@ -261,25 +261,24 @@ namespace dropshell
std::filesystem::create_directories(p);
}
// download bb64.
// 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))
std::cout << "Downloaded bb64 to " << localpath::agent() << std::endl;
std::cout << "Downloaded local bb64 to " << localpath::agent() << std::endl;
else
std::cerr << "Failed to download bb64 to " << localpath::agent() << std::endl;
std::cerr << "Failed to download local bb64 to " << localpath::agent() << std::endl;
}
else
{
std::cout << "Updating bb64..." << std::endl;
std::cout << "Updating local bb64..." << std::endl;
system((localpath::agent() + "bb64 -u").c_str()); // update.
}
std::cout << "Creating local agent files..." << std::endl;
recreate_agent::recreate_tree(localpath::agent());
std::cout << "Creating local files to copy to remote agents..." << std::endl;
recreate_agent::recreate_tree(localpath::files_for_remote_agent());
return 0;
}
@ -320,25 +319,35 @@ namespace dropshell
return 1;
}
// first install bb64.
std::cout << "Installing bb64 on " << server << std::endl
<< std::flush;
// now create the agent.
// copy across from the local agent files.
rsync_tree_to_remote(localpath::files_for_remote_agent(), agent_path, server_env, false);
// 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;
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;
//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;
else
std::cout << "Downloaded bb64 to " << agent_path << " on remote server." << std::endl;
// now create the agent.
// copy across from the local agent files.
#pragma message("TODO: copy across from the local agent files.")
// just test all is ok
std::string output;
bool okay = execute_ssh_command(server_env.get_SSH_INFO(), sCommand(agent_path, "bb64 -i QkI2NCBpcyBjb3JyZWN0bHkgaW5zdGFsbGVk", {}), cMode::CaptureOutput, &output);
if (!okay)
{
std::cerr << "Failed to install bb64 on " << server << std::endl;
return 1;
}
return 0; // NOTIMPL
std::cout << output << std::endl;
return 0;
}
// ------------------------------------------------------------------------------------------------