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

This commit is contained in:
Your Name
2025-05-14 23:47:23 +12:00
parent 2cc00244c6
commit 707e973130
3 changed files with 600 additions and 7 deletions

22
make_createagent.sh Normal file → Executable file
View File

@ -13,6 +13,8 @@ cat <<EOF > "$SCRIPT_DIR/src/utils/createagent.hpp"
#ifndef CREATEAGENT_HPP
#define CREATEAGENT_HPP
#include <string>
namespace dropshell {
int create_agent(const std::string &server_name);
}
@ -24,19 +26,25 @@ EOF
# heredoc to create the createagent.cpp file.
cat <<CPPEOF > "$SCRIPT_DIR/src/utils/createagent.cpp"
#include "createagent.hpp"
#include "utils.hpp"
#include "directories.hpp"
#include "execute.hpp"
#include "server_env_manager.hpp"
#include <vector>
#include <string>
#include <iostream>
namespace dropshell {
void load_agent_file_contents(std::vector<std::AgentFile> &agent_file_contents);
struct AgentFile {
std::string filename;
std::string content;
};
int remote_write_file(const SSH_INFO &ssh_info, AgentFile &file);
int load_agent_file_contents(std::vector<AgentFile> &agent_files);
int remote_write_file(const sSSHInfo &ssh_info, const AgentFile &file);
int create_agent(const std::string &server_name) {
// create the sh file on the remote server.
@ -48,7 +56,7 @@ namespace dropshell {
// create the agent directory.
std::string agent_dir = remotepath::agent(server_name);
remote_create_directory(server_env.get_SSH_INFO(), agent_dir);
execute_ssh_command(server_env.get_SSH_INFO(), sCommand("","mkdir -p " + agent_dir,{}), cMode::Silent);
std::vector<AgentFile> agent_files;
load_agent_file_contents(agent_files);
@ -62,10 +70,10 @@ namespace dropshell {
return 0;
}
int remote_write_file(const SSH_INFO &ssh_info, AgentFile &file)
int remote_write_file(const sSSHInfo &ssh_info, const AgentFile &file)
{
std::string generate_command = "cat <<'GENERATE_EOF' > " + file.filename + "\n" + file.content + "\nGENERATE_EOF\n"; // use heredoc to write the file.
return execute_ssh_command(ssh_info, sCommand(generate_command), cMode::Defaults);
return execute_ssh_command(ssh_info, sCommand("",generate_command,{}), cMode::Defaults);
}
// auto generated load_agent_file_contents function goes here, followed by closing } for namespace dropshell.