aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authordefault <nobody@localhost>2025-01-20 10:40:43 +0100
committerdefault <nobody@localhost>2025-01-20 10:40:43 +0100
commit5b21c9546b40cc0c52d5f39273747c551926984c (patch)
tree3ac7d56be097edc2d2b39489d36e6daf5dd15270 /main.c
parente56e30f0c64f12ea12413aaf4229975543e1bdbf (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.c29
1 files changed, 14 insertions, 15 deletions
diff --git a/main.c b/main.c
index 5678af4..db26252 100644
--- a/main.c
+++ b/main.c
@@ -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));