MAJRO CHANGES!@!!@#
This commit is contained in:
@@ -532,11 +532,22 @@ complete -F _dropshell_completions ds
|
||||
// now create the agent.
|
||||
// copy across from the local agent files.
|
||||
info << "Copying local agent files to remote server... " << std::flush;
|
||||
shared_commands::rsync_tree_to_remote(localpath::agent_remote(), agent_path, server, false, user.user);
|
||||
shared_commands::rsync_tree_to_remote(
|
||||
localpath::agent_remote(),
|
||||
agent_path,
|
||||
server, false, user.user);
|
||||
info << "done." << std::endl;
|
||||
|
||||
// run the agent installer. Can't use BB64 yet, as we're installing it on the remote server.
|
||||
|
||||
// copy server.json across.
|
||||
info << "Copying server.json to remote server... " <<std::flush;
|
||||
shared_commands::rsync_file_to_remote(
|
||||
localfile::server_json(server)),
|
||||
remotepath(server.get_server_name(),user.user).server_json(),
|
||||
server, false, user.user);
|
||||
info << "done." << std::endl;
|
||||
|
||||
|
||||
// run the agent installer. Can't use BB64 yet, as we're installing it on the remote server.
|
||||
bool okay = execute_ssh_command(server.get_SSH_INFO(user.user), sCommand(agent_path, "agent-install.sh",{}), cMode::Defaults | cMode::NoBB64, nullptr);
|
||||
if (!okay)
|
||||
{
|
||||
@@ -544,6 +555,7 @@ complete -F _dropshell_completions ds
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
info << "Installation on " << server.get_server_name() << " complete." << std::endl;
|
||||
}
|
||||
return 0;
|
||||
|
||||
@@ -71,6 +71,27 @@ namespace dropshell
|
||||
return execute_local_command("", rsync_cmd, {}, nullptr, (silent ? cMode::Silent : cMode::Defaults));
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// rsync_file_to_remote : SHARED COMMAND
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
bool rsync_file_to_remote(
|
||||
const std::string &local_path,
|
||||
const std::string &remote_path,
|
||||
const ServerConfig &server_env,
|
||||
bool silent,
|
||||
std::string user)
|
||||
{
|
||||
ASSERT(!local_path.empty() && !remote_path.empty(), "Local or remote path not specified. Can't rsync.");
|
||||
ASSERT(std::filesystem::is_block_file(local_path), "Local path is not a file. Can't rsync.");
|
||||
|
||||
std::string rsync_cmd = "rsync --mkpath -zpc -e 'ssh -p " + server_env.get_SSH_PORT() + "' " +
|
||||
quote(local_path) + " " +
|
||||
quote(user + "@" + server_env.get_SSH_HOST() + ":" +
|
||||
remote_path);
|
||||
return execute_local_command("", rsync_cmd, {}, nullptr, (silent ? cMode::Silent : cMode::Defaults));
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// get_arch : SHARED COMMAND
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -59,6 +59,13 @@ namespace dropshell
|
||||
bool silent,
|
||||
std::string user);
|
||||
|
||||
bool rsync_file_to_remote(
|
||||
const std::string &local_path,
|
||||
const std::string &remote_path,
|
||||
const ServerConfig &server_env,
|
||||
bool silent,
|
||||
std::string user);
|
||||
|
||||
std::string get_arch();
|
||||
|
||||
std::map<std::string, ServiceStatus> get_all_services_status(const ServerConfig & server_env);
|
||||
|
||||
@@ -32,12 +32,6 @@ namespace dropshell
|
||||
return (servicepath.empty() ? "" : (fs::path(servicepath) / filenames::service_env).string());
|
||||
}
|
||||
|
||||
std::string template_info_env(const std::string &server_name, const std::string &service_name)
|
||||
{
|
||||
std::string servicepath = localpath::service(server_name, service_name);
|
||||
return (servicepath.empty() ? "" : (fs::path(servicepath) / filenames::template_info_env).string());
|
||||
}
|
||||
|
||||
std::string template_example()
|
||||
{
|
||||
return localpath::agent_local() + "/template_example";
|
||||
@@ -146,6 +140,7 @@ namespace dropshell
|
||||
//------------------------------------------------------------------------------------------------
|
||||
// remote paths
|
||||
// DROPSHELL_DIR
|
||||
// |-- server.json
|
||||
// |-- backups
|
||||
// |-- temp_files
|
||||
// |-- agent
|
||||
@@ -157,9 +152,10 @@ namespace dropshell
|
||||
// |-- service.env (actual service config)
|
||||
// |-- template
|
||||
// |-- (script files)
|
||||
// |-- template_info.env
|
||||
// |-- config
|
||||
// |-- service.env (default service config)
|
||||
// |-- (other config files for specific server&service)
|
||||
// |-- (other template/example config files)
|
||||
|
||||
remotefile::remotefile(const std::string &server_name, const std::string &user) : mServer_name(server_name), mUser(user) {}
|
||||
|
||||
@@ -168,6 +164,11 @@ namespace dropshell
|
||||
return remotepath(mServer_name, mUser).service_config(service_name) + "/" + filenames::service_env;
|
||||
}
|
||||
|
||||
std::string remotefile::server_json()
|
||||
{
|
||||
return remotepath(mServer_name, mUser).DROPSHELL_DIR() + "/" + filenames::server_json;
|
||||
}
|
||||
|
||||
remotepath::remotepath(const std::string &server_name, const std::string &user) : mServer_name(server_name), mUser(user) {}
|
||||
|
||||
std::string remotepath::DROPSHELL_DIR() const
|
||||
|
||||
@@ -24,9 +24,9 @@ namespace dropshell {
|
||||
// | |-- <template_name>.json
|
||||
// | |-- <template_name>
|
||||
// | |-- (...script files...)
|
||||
// | |-- template_info.env
|
||||
// | |-- config
|
||||
// | |-- service.env
|
||||
// | |-- .template_info.env
|
||||
// | |-- (...other service config files...)
|
||||
|
||||
// backups_path
|
||||
@@ -39,11 +39,10 @@ namespace dropshell {
|
||||
// |-- services
|
||||
// |-- <service_name>
|
||||
// |-- service.env
|
||||
// |-- .template_info.env
|
||||
// |-- (...other config files for specific server&service...)
|
||||
|
||||
namespace filenames {
|
||||
static const std::string template_info_env = ".template_info.env";
|
||||
static const std::string template_info_env = "template_info.env";
|
||||
static const std::string service_env = "service.env";
|
||||
static const std::string readme = "README.txt";
|
||||
static const std::string server_json = "server.json";
|
||||
@@ -54,7 +53,6 @@ namespace dropshell {
|
||||
std::string dropshell_json();
|
||||
std::string server_json(const std::string &server_name);
|
||||
std::string service_env(const std::string &server_name, const std::string &service_name);
|
||||
std::string template_info_env(const std::string &server_name, const std::string &service_name);
|
||||
std::string template_example();
|
||||
std::string bb64();
|
||||
} // namespace localfile
|
||||
@@ -81,6 +79,7 @@ namespace dropshell {
|
||||
//------------------------------------------------------------------------------------------------
|
||||
// remote paths
|
||||
// DROPSHELL_DIR
|
||||
// |-- server.json
|
||||
// |-- backups
|
||||
// |-- temp_files
|
||||
// |-- agent
|
||||
@@ -90,18 +89,18 @@ namespace dropshell {
|
||||
// |-- service name
|
||||
// |-- config
|
||||
// |-- service.env (actual service config)
|
||||
// |-- .template_info.env
|
||||
// |-- template
|
||||
// |-- (script files)
|
||||
// |-- template_info.env
|
||||
// |-- config
|
||||
// |-- service.env (default service config)
|
||||
// |-- .template_info.env
|
||||
// |-- (other config files for specific server&service)
|
||||
// |-- (other template/example config files)
|
||||
|
||||
class remotefile {
|
||||
public:
|
||||
remotefile(const std::string &server_name, const std::string &user);
|
||||
std::string service_env(const std::string &service_name) const;
|
||||
std::string server_json();
|
||||
private:
|
||||
std::string mServer_name;
|
||||
std::string mUser;
|
||||
|
||||
Reference in New Issue
Block a user