mirror of
https://github.com/owntracks/recorder.git
synced 2026-08-27 16:57:21 +00:00
[NEW]: option --variables prints list of actual settings
This commit is contained in:
@@ -295,6 +295,9 @@ The following configuration variables can be used to tweak settings. Defaults ar
|
||||
| `OTR_CAPATH` | Y | | Directory of c_rehashed PEM certificates
|
||||
| `OTR_CERTFILE` | Y | | Path to PEM-encoded client certificate for MQTT
|
||||
| `OTR_KEYFILE` | Y | | Path to PEM-encoded client key for MQTT
|
||||
| `OTR_IDENTITY` | Y | | MQTT identity for PSK
|
||||
| `OTR_PSK` | Y | | MQTT PSK
|
||||
| `OTR_SERVERLABEL` | Y | `OwnTracks` | server label for Web
|
||||
| `OTR_LMDBSIZE` | Y | `104857600000` | size of the LMDB database. If less than 10485760 (10 MB) it will be set to 10485760.
|
||||
|
||||
|
||||
|
||||
@@ -189,6 +189,8 @@ void get_defaults(char *filename, struct udata *ud)
|
||||
ud->cafile = c_str(cf, "OTR_CAFILE", NULL);
|
||||
ud->certfile = c_str(cf, "OTR_CERTFILE", NULL);
|
||||
ud->keyfile = c_str(cf, "OTR_KEYFILE", NULL);
|
||||
ud->identity = c_str(cf, "OTR_IDENTITY", ud->identity);
|
||||
ud->psk = c_str(cf, "OTR_PSK", ud->psk);
|
||||
|
||||
ud->port = c_int(cf, "OTR_PORT", 1883);
|
||||
ud->qos = c_int(cf, "OTR_QOS", ud->qos);
|
||||
@@ -223,6 +225,7 @@ void get_defaults(char *filename, struct udata *ud)
|
||||
ud->http_host = c_str(cf, "OTR_HTTPHOST", NULL);
|
||||
ud->http_logdir = c_str(cf, "OTR_HTTPLOGDIR", NULL);
|
||||
ud->browser_apikey = c_str(cf, "OTR_BROWSERAPIKEY", NULL);
|
||||
ud->viewsdir = c_str(cf, "OTR_VIEWSDIR", ud->viewsdir);
|
||||
|
||||
ud->http_port = c_int(cf, "OTR_HTTPPORT", ud->http_port);
|
||||
|
||||
@@ -234,8 +237,64 @@ void get_defaults(char *filename, struct udata *ud)
|
||||
#if WITH_LUA
|
||||
ud->luascript = c_str(cf, "OTR_LUASCRIPT", NULL);
|
||||
#endif
|
||||
ud->label = c_str(cf, "OTR_SERVERLABEL", ud->label);
|
||||
|
||||
if (cf) {
|
||||
config_destroy(cf);
|
||||
}
|
||||
}
|
||||
|
||||
static void d_int(char *property, int ival)
|
||||
{
|
||||
printf("%-25s %d\n", property, ival);
|
||||
}
|
||||
|
||||
static void d_str(char *property, char *val)
|
||||
{
|
||||
printf("%-25s %s\n", property, val ? val : "<null>");
|
||||
}
|
||||
|
||||
static void d_bool(char *property, bool tf)
|
||||
{
|
||||
printf("%-25s %s\n", property, tf ? "true" : "false");
|
||||
}
|
||||
|
||||
void display_variables(struct udata *ud)
|
||||
{
|
||||
d_str("OTR_STORAGEDIR", STORAGEDIR);
|
||||
#if WITH_MQTT
|
||||
// char *pubprefix; /* If not NULL (default), republish modified payload to <pubprefix>/topic */
|
||||
|
||||
d_str("OTR_HOST", ud->hostname);
|
||||
d_int("OTR_PORT", ud->port);
|
||||
d_str("OTR_USER", ud->username);
|
||||
d_str("OTR_PASS", ud->password);
|
||||
d_int("OTR_QOS", ud->qos);
|
||||
d_str("OTR_CLIENTID", ud->clientid);
|
||||
d_str("OTR_CAFILE", ud->cafile);
|
||||
d_str("OTR_CAPATH", ud->capath);
|
||||
d_str("OTR_CERTFILE", ud->certfile);
|
||||
d_str("OTR_KEYFILE", ud->keyfile);
|
||||
d_str("OTR_IDENTITY", ud->identity);
|
||||
d_str("OTR_PSK", ud->psk);
|
||||
#endif
|
||||
d_bool("skip _demo", ud->skipdemo);
|
||||
d_bool("perform reverse geo", ud->revgeo);
|
||||
d_str("OTR_GEOKEY", ud->geokey);
|
||||
d_bool("do not write .rec", ud->norec);
|
||||
|
||||
#ifdef WITH_HTTP
|
||||
d_str("OTR_HTTPHOST", ud->http_host);
|
||||
d_int("OTR_HTTPPORT", ud->http_port);
|
||||
d_str("OTR_HTTPLOGDIR", ud->http_logdir);
|
||||
d_str("OTR_BROWSERAPIKEY", ud->browser_apikey);
|
||||
d_str("OTR_VIEWSDIR", ud->viewsdir);
|
||||
# ifdef WITH_SHARES
|
||||
d_str("OTR_HTTPPREFIX", ud->http_prefix);
|
||||
# endif /* SHARES */
|
||||
#endif
|
||||
#ifdef WITH_LUA
|
||||
d_str("OTR_LUASCRIPT", ud->luascript);
|
||||
#endif
|
||||
d_str("OTR_SERVERLABEL", ud->label);
|
||||
}
|
||||
|
||||
@@ -18,5 +18,6 @@ char *bindump(char *buf, long buflen);
|
||||
void monitorhook(struct udata *userdata, time_t now, char *topic);
|
||||
char *monitor_get();
|
||||
void get_defaults(char *filename, struct udata *userdata);
|
||||
void display_variables(struct udata *userdata);
|
||||
|
||||
#endif
|
||||
|
||||
+12
-11
@@ -1403,17 +1403,8 @@ void usage(char *prog)
|
||||
printf(" --norec don't maintain REC files\n");
|
||||
printf(" --geokey optional reverse-geo API key\n");
|
||||
printf(" --debug additional debugging\n");
|
||||
printf(" --variables -V show settings and exit\n");
|
||||
printf("\n");
|
||||
printf("Options override these environment variables:\n");
|
||||
printf(" $OTR_STORAGEDIR\n");
|
||||
printf(" $OTR_BROWSERAPIKEY\n");
|
||||
#ifdef WITH_MQTT
|
||||
printf(" $OTR_HOST MQTT hostname\n");
|
||||
printf(" $OTR_PORT MQTT port\n");
|
||||
printf(" $OTR_USER\n");
|
||||
printf(" $OTR_PASS\n");
|
||||
printf(" $OTR_CAFILE PEM CA certificate chain\n");
|
||||
#endif
|
||||
|
||||
exit(1);
|
||||
}
|
||||
@@ -1440,6 +1431,7 @@ int main(int argc, char **argv)
|
||||
int loop_timeout = 1000;
|
||||
#endif
|
||||
int ch, initialize = FALSE;
|
||||
bool show_variables = false;
|
||||
static struct udata udata, *ud = &udata;
|
||||
#ifdef WITH_HTTP
|
||||
char *doc_root = DOCROOT;
|
||||
@@ -1552,11 +1544,12 @@ int main(int argc, char **argv)
|
||||
{ "browser-apikey", required_argument, 0, 15},
|
||||
{ "viewsdir", required_argument, 0, 16},
|
||||
#endif
|
||||
{ "variables", no_argument, 0, 'V'},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
int optindex = 0;
|
||||
|
||||
ch = getopt_long(argc, argv, "hDGRi:P:q:S:H:p:A:", long_options, &optindex);
|
||||
ch = getopt_long(argc, argv, "hDGRi:P:q:S:H:p:A:V", long_options, &optindex);
|
||||
if (ch == -1)
|
||||
break;
|
||||
|
||||
@@ -1660,6 +1653,9 @@ int main(int argc, char **argv)
|
||||
case 'S':
|
||||
strcpy(STORAGEDIR, optarg);
|
||||
break;
|
||||
case 'V':
|
||||
show_variables = true;
|
||||
break;
|
||||
case 'h':
|
||||
usage(progname);
|
||||
exit(0);
|
||||
@@ -1669,6 +1665,11 @@ int main(int argc, char **argv)
|
||||
|
||||
}
|
||||
|
||||
if (show_variables) {
|
||||
display_variables(ud);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* If requested to, attempt to create ghash storage and
|
||||
* initialize (non-destructively -- just open for write)
|
||||
|
||||
Reference in New Issue
Block a user