This commit is contained in:
22
make_createagent.sh
Normal file → Executable file
22
make_createagent.sh
Normal file → Executable 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.
|
||||
|
Reference in New Issue
Block a user