]> git.ipfire.org Git - collecty.git/commitdiff
daemon: main: Make the path configurable on command line
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 4 Jun 2026 14:52:06 +0000 (14:52 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 4 Jun 2026 14:52:06 +0000 (14:52 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/daemon/main.c

index 964d1b408283b0902997f2bb0d461b219e438b1b..09d1514129285f8eda9325d183e60c099c0dcf0b 100644 (file)
@@ -36,17 +36,22 @@ static const char* doc = "The IPFire Telemetry Daemon";
 
 enum {
        OPT_DEBUG  = 1,
-       OPT_SOURCE = 2,
-       OPT_USER   = 3,
+       OPT_PATH   = 2,
+       OPT_SOURCE = 3,
+       OPT_USER   = 4,
 };
 
 static struct argp_option options[] = {
-       { "debug", OPT_DEBUG, NULL, 0, "Run in debug mode", 0 },
+       { "debug",  OPT_DEBUG,  NULL,     0, "Run in debug mode", 0 },
+       { "path",   OPT_PATH,   "PATH",   0, "Store the databases in this path", 0 },
        { "source", OPT_SOURCE, "SOURCE", 0, "Only enable this source (for testing)", 0 },
        { "user",   OPT_USER,   "USER",   0, "Run as user", 0 },
        { NULL },
 };
 
+// The database path
+static const char* path = NULL;
+
 // Collect all sources that should be enabled
 static char** sources = NULL;
 
@@ -64,6 +69,10 @@ static error_t parse(int key, char* arg, struct argp_state* state) {
                        td_ctx_set_log_level(ctx, LOG_DEBUG);
                        break;
 
+               case OPT_PATH:
+                       path = arg;
+                       break;
+
                case OPT_SOURCE:
                        return td_strings_append(&sources, arg);
 
@@ -105,7 +114,7 @@ int main(int argc, char* argv[]) {
                goto ERROR;
 
        // Create a daemon
-       r = td_daemon_create(&daemon, ctx, NULL, sources);
+       r = td_daemon_create(&daemon, ctx, path, sources);
        if (r < 0) {
                ERROR(ctx, "Failed to initialize the daemon: %s\n", strerror(-r));
                goto ERROR;