summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDennis Camera <skonfig@dtnr.ch>2022-08-21 11:17:18 +0200
committerDennis Camera <skonfig@dtnr.ch>2022-08-21 11:17:18 +0200
commit580b957769a5ee4ab7522e474f3996c03426a286 (patch)
treeec47b026592db5b4cc90b405de198d412da417a3 /src
parent32cf6255bfaa36d8e7b1f94e58a6044eba628577 (diff)
downloadskonfig-c-580b957769a5ee4ab7522e474f3996c03426a286.tar.gz
skonfig-c-580b957769a5ee4ab7522e474f3996c03426a286.zip
[src/run.c] Add more structure functions
Diffstat (limited to 'src')
-rw-r--r--src/run.c67
1 files changed, 63 insertions, 4 deletions
diff --git a/src/run.c b/src/run.c
index 2f9f12c..3589467 100644
--- a/src/run.c
+++ b/src/run.c
@@ -17,7 +17,7 @@
#include <time.h>
/* as per mktemp(3p) the last 6 characters of object_marker_tmpl must be Xs */
-static char *object_marker_tmpl = ".skonfig-XXXXXX";
+static const char object_marker_tmpl[] = ".skonfig-XXXXXX";
double tv_diff(struct timespec *start, struct timespec *end) {
@@ -103,6 +103,13 @@ sk_run_error sk_run_prepare_local_hostdir(const char *local_hostdir) {
return SK_RUN_GENERIC_ERROR;
}
+sk_run_error sk_run_prepare_remote_workdir(
+ const char *target_host, bool dry_run, struct sk_config *config) {
+ /* TODO */
+
+ return SK_RUN_OK;
+}
+
sk_run_error sk_run_link_local_hostdir(
const char *local_hostdir, struct sk_config *config) {
static const char *conf_subdirs_linked[] = {
@@ -274,8 +281,32 @@ sk_run_error sk_run_setup_object_marker_file(
return SK_RUN_OK;
}
-sk_run_error sk_run_init_manifest(
- const char *target_host, bool dry_run, struct sk_config *config) {
+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];
+ if (PATH_MAX < pathjoin_r(
+ explorers_dir, PATH_MAX+1,
+ local_hostdir, "explorer")) {
+ sk_error("global explorers path is longer than PATH_MAX");
+ return SK_RUN_GENERIC_ERROR;
+ }
+
+ sk_debug("Running global explorers");
+
+ /* transfer global exploers to target */
+ /* TODO */
+
+ /* execute global explorers */
+ /* TODO: implement multiple jobs */
+ /* TODO */
+
+ return SK_RUN_OK;
+}
+
+sk_run_error sk_run_exec_init_manifest(
+ const char *target_host, bool dry_run, const char *local_hostdir,
+ struct sk_config *config) {
/* check if the initial manifest file exists */
const char *init_manifest = config->global.init_manifest;
@@ -290,6 +321,14 @@ sk_run_error sk_run_init_manifest(
return SK_RUN_GENERIC_ERROR;
}
+sk_run_error sk_run_cleanup(/* ??? */) {
+ sk_debug("Running cleanup commands");
+
+ /* TODO */
+
+ return SK_RUN_OK;
+}
+
sk_run_error sk_run_host(
const char *target_host, bool dry_run, const char *local_hostdir,
struct sk_config *config) {
@@ -319,7 +358,7 @@ sk_run_error sk_run_host(
if (SK_RUN_OK != rv) goto ret;
/* generate and store object marker file */
- char object_marker[strlen(object_marker_tmpl)+1];
+ char object_marker[sizeof(object_marker_tmpl)/sizeof(char)];
#if HAVE_MKTEMP
strcpy(object_marker, object_marker_tmpl);
mktemp(object_marker);
@@ -335,6 +374,26 @@ sk_run_error sk_run_host(
rv = sk_run_setup_object_marker_file(local_hostdir, object_marker);
if (SK_RUN_OK != rv) goto ret;
+ /* create remote files directories */
+ rv = sk_run_prepare_remote_workdir(target_host, dry_run, config);
+ if (SK_RUN_OK != rv) goto ret;
+
+ /* execute global explorers */
+ rv = sk_run_exec_global_explorers(
+ target_host, dry_run, local_hostdir, config);
+ if (SK_RUN_OK != rv) goto ret;
+
+ /* execute initial manifest */
+ rv = sk_run_exec_init_manifest(
+ target_host, dry_run, local_hostdir, config);
+ if (SK_RUN_OK != rv) goto ret;
+
+ /* iterate */
+ /* TODO */
+
+ /* clean up */
+ rv = sk_run_cleanup();
+ if (SK_RUN_OK != rv) goto ret;
ret:
if (SK_RUN_OK == rv) {