summaryrefslogtreecommitdiff
path: root/src/run.c
blob: 1dcf6095a40cc7f3e216535314ce9c4fcecce322 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include "run.h"

#include "log.h"

#include <errno.h>
#include <string.h>
#include <unistd.h>


sk_run_error sk_run_init_manifest(
		const char *target_host, bool dry_run, struct sk_config *config) {
	/* check if the initial manifest file exists */
	const char *init_manifest = config->global.init_manifest;

	if (access(init_manifest, F_OK)) {
		sk_error("cannot find initial manifest (%s): %s",
		         init_manifest, strerror(errno));
		return SK_RUN_ERROR_GENERIC;
	}

	sk_error("%s: running manifest not yet implemented.", target_host);

	return SK_RUN_ERROR_GENERIC;
}

sk_run_error sk_run_start(
		const char *target_host, bool dry_run, struct sk_config *config) {
	sk_run_error rv = SK_RUN_OK;

	if (NULL == target_host) {
		sk_error("Target host missing");
		return (rv = SK_RUN_ERROR_GENERIC);
	}

	sk_info("%s: Starting configuration run", target_host);

	/* TODO: set up local cache paths */

	rv = sk_run_init_manifest(target_host, dry_run, config);

	/* TODO: cleanup */

	if (SK_RUN_OK != rv) {
		sk_error("failed to configure the following host: %s", target_host);
	}

	return rv;
}