diff options
| author | default <nobody@localhost> | 2025-01-20 10:40:43 +0100 |
|---|---|---|
| committer | default <nobody@localhost> | 2025-01-20 10:40:43 +0100 |
| commit | 5b21c9546b40cc0c52d5f39273747c551926984c (patch) | |
| tree | 3ac7d56be097edc2d2b39489d36e6daf5dd15270 /main.c | |
| parent | e56e30f0c64f12ea12413aaf4229975543e1bdbf (diff) | |
Added support for the SNAC_BASEDIR environment variable.
If it's set, the basedir argument in command-line commands must not be given.
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 29 |
1 files changed, 14 insertions, 15 deletions
@@ -96,19 +96,6 @@ int main(int argc, char *argv[]) return snac_init(basedir); } - if (strcmp(cmd, "upgrade") == 0) { /** **/ - int ret; - - /* upgrade */ - if ((basedir = GET_ARGV()) == NULL) - return usage(); - - if ((ret = srv_open(basedir, 1)) == 1) - srv_log(xs_dup("OK")); - - return ret; - } - if (strcmp(cmd, "markdown") == 0) { /** **/ /* undocumented, for testing only */ xs *c = xs_readall(stdin); @@ -118,8 +105,20 @@ int main(int argc, char *argv[]) return 0; } - if ((basedir = GET_ARGV()) == NULL) - return usage(); + if ((basedir = getenv("SNAC_BASEDIR")) == NULL) { + if ((basedir = GET_ARGV()) == NULL) + return usage(); + } + + if (strcmp(cmd, "upgrade") == 0) { /** **/ + int ret; + + /* upgrade */ + if ((ret = srv_open(basedir, 1)) == 1) + srv_log(xs_dup("OK")); + + return ret; + } if (!srv_open(basedir, 0)) { srv_log(xs_fmt("error opening data storage at %s", basedir)); |