This commit is contained in:
@@ -55,13 +55,14 @@ namespace dropshell
|
||||
const std::string &local_path,
|
||||
const std::string &remote_path,
|
||||
const server_config &server_env,
|
||||
bool silent)
|
||||
bool silent,
|
||||
std::string user)
|
||||
{
|
||||
ASSERT(!local_path.empty() && !remote_path.empty(), "Local or remote path not specified. Can't rsync.");
|
||||
|
||||
std::string rsync_cmd = "rsync --delete --mkpath -zrpc -e 'ssh -p " + server_env.get_SSH_PORT() + "' " +
|
||||
quote(local_path + "/") + " " +
|
||||
quote(server_env.get_SSH_UNPRIVILEGED_USER() + "@" + server_env.get_SSH_HOST() + ":" +
|
||||
quote(user + "@" + server_env.get_SSH_HOST() + ":" +
|
||||
remote_path + "/");
|
||||
return execute_local_command("", rsync_cmd, {}, nullptr, (silent ? cMode::Silent : cMode::Defaults));
|
||||
}
|
||||
@@ -222,7 +223,7 @@ namespace dropshell
|
||||
return HealthStatus::ERROR;
|
||||
}
|
||||
|
||||
std::string user = env.get_user_for_service(server, service);
|
||||
std::string user = env.get_user_for_service(service);
|
||||
|
||||
if (!env.check_remote_dir_exists(remotepath(server,user).service(service), user))
|
||||
{
|
||||
@@ -308,7 +309,7 @@ namespace dropshell
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// scp_file_to_remote : SHARED COMMAND
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
bool scp_file_to_remote(const server_config &server_env, const std::string &local_path, const std::string &remote_path, bool silent)
|
||||
bool scp_file_to_remote(const server_config &server_env, const std::string &local_path, const std::string &remote_path, bool silent, std::string user)
|
||||
{
|
||||
if (!server_env.is_valid())
|
||||
{
|
||||
@@ -316,14 +317,14 @@ namespace dropshell
|
||||
return false;
|
||||
}
|
||||
ASSERT(!remote_path.empty() && !local_path.empty(), "Remote or local path not specified. Can't scp.");
|
||||
std::string scp_cmd = "scp -P " + server_env.get_SSH_PORT() + " " + quote(local_path) + " " + server_env.get_SSH_UNPRIVILEGED_USER() + "@" + server_env.get_SSH_HOST() + ":" + quote(remote_path) + (silent ? " > /dev/null 2>&1" : "");
|
||||
std::string scp_cmd = "scp -P " + server_env.get_SSH_PORT() + " " + quote(local_path) + " " + user + "@" + server_env.get_SSH_HOST() + ":" + quote(remote_path) + (silent ? " > /dev/null 2>&1" : "");
|
||||
return execute_local_command("", scp_cmd, {}, nullptr, (silent ? cMode::Silent : cMode::Defaults));
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// scp_file_from_remote : SHARED COMMAND
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
bool scp_file_from_remote(const server_config &server_env, const std::string &remote_path, const std::string &local_path, bool silent)
|
||||
bool scp_file_from_remote(const server_config &server_env, const std::string &remote_path, const std::string &local_path, bool silent, std::string user)
|
||||
{
|
||||
if (!server_env.is_valid())
|
||||
{
|
||||
@@ -331,7 +332,7 @@ namespace dropshell
|
||||
return false;
|
||||
}
|
||||
ASSERT(!remote_path.empty() && !local_path.empty(), "Remote or local path not specified. Can't scp.");
|
||||
std::string scp_cmd = "scp -P " + server_env.get_SSH_PORT() + " " + server_env.get_SSH_UNPRIVILEGED_USER() + "@" + server_env.get_SSH_HOST() + ":" + quote(remote_path) + " " + quote(local_path) + (silent ? " > /dev/null 2>&1" : "");
|
||||
std::string scp_cmd = "scp -P " + server_env.get_SSH_PORT() + " " + user + "@" + server_env.get_SSH_HOST() + ":" + quote(remote_path) + " " + quote(local_path) + (silent ? " > /dev/null 2>&1" : "");
|
||||
return execute_local_command("", scp_cmd, {}, nullptr, (silent ? cMode::Silent : cMode::Defaults));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user