summaryrefslogtreecommitdiff
path: root/src/run.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/run.c')
-rw-r--r--src/run.c58
1 files changed, 52 insertions, 6 deletions
diff --git a/src/run.c b/src/run.c
index 3589467..eef9874 100644
--- a/src/run.c
+++ b/src/run.c
@@ -2,6 +2,8 @@
#include "log.h"
+#include "rcopy.h"
+
#include "util/array.h"
#include "util/fs.h"
@@ -249,6 +251,8 @@ sk_run_error sk_run_install_type_cmds(const char *local_hostdir) {
}
}
+ (void)closedir(dirp);
+
return SK_RUN_OK;
}
@@ -284,18 +288,60 @@ sk_run_error sk_run_setup_object_marker_file(
sk_run_error sk_run_exec_global_explorers(
const char *target_host, bool dry_run, const char *local_hostdir,
struct sk_config *config) {
- char explorers_dir[PATH_MAX+1];
+ char local_explorers_dir[PATH_MAX+1], remote_explorers_dir[PATH_MAX+1];
+
+ if (PATH_MAX < pathjoin_r(
+ local_explorers_dir, PATH_MAX+1,
+ local_hostdir, "conf", "explorer")) {
+ sk_error("local global explorers path is longer than PATH_MAX");
+ return SK_RUN_GENERIC_ERROR;
+ }
+
if (PATH_MAX < pathjoin_r(
- explorers_dir, PATH_MAX+1,
- local_hostdir, "explorer")) {
- sk_error("global explorers path is longer than PATH_MAX");
+ remote_explorers_dir, PATH_MAX+1,
+ config->global.remote_out_path, "conf", "explorer")) {
+ sk_error("remote global explorers path is longer than PATH_MAX");
return SK_RUN_GENERIC_ERROR;
}
sk_debug("Running global explorers");
+ sk_trace("local explorers dir = %s", local_explorers_dir);
- /* transfer global exploers to target */
- /* TODO */
+ /* transfer global explorers to target */
+ DIR *dirp = opendir(local_explorers_dir);
+ if (NULL == dirp) {
+ sk_error("cannot open directory (%s): %s",
+ local_explorers_dir, strerror(errno));
+ return SK_RUN_GENERIC_ERROR;
+ }
+
+ struct dirent *dp;
+ while (NULL != (dp = readdir(dirp))) {
+ if (!strcmp(dp->d_name, ".") || !strcmp(dp->d_name, "..")) {
+ continue;
+ }
+
+ char explorer_src[PATH_MAX+1], explorer_dst[PATH_MAX+1];
+ if (PATH_MAX < pathjoin_r(
+ explorer_src, PATH_MAX+1,
+ local_explorers_dir, dp->d_name)) {
+ sk_error("explorer path too long: %s/%s",
+ local_explorers_dir, dp->d_name);
+ continue;
+ }
+ if (PATH_MAX < pathjoin_r(
+ explorer_dst, PATH_MAX+1,
+ remote_explorers_dir, dp->d_name)) {
+ sk_error("explorer destination too long: %s/%s",
+ remote_explorers_dir, dp->d_name);
+ continue;
+ }
+
+ sk_trace("copying explorer %s to %s:%s",
+ explorer_src, target_host, explorer_dst);
+ sk_rcopy_file(explorer_src, target_host, explorer_dst);
+ }
+ (void)closedir(dirp);
/* execute global explorers */
/* TODO: implement multiple jobs */