commit 5b21c95
default
·
2025-01-20 09:40:43 +0000 UTC
parent e56e30f
Added support for the SNAC_BASEDIR environment variable. If it's set, the basedir argument in command-line commands must not be given.
1 files changed,
+14,
-15
M
main.c
M
main.c
+14,
-15
1@@ -96,19 +96,6 @@ int main(int argc, char *argv[])
2 return snac_init(basedir);
3 }
4
5- if (strcmp(cmd, "upgrade") == 0) { /** **/
6- int ret;
7-
8- /* upgrade */
9- if ((basedir = GET_ARGV()) == NULL)
10- return usage();
11-
12- if ((ret = srv_open(basedir, 1)) == 1)
13- srv_log(xs_dup("OK"));
14-
15- return ret;
16- }
17-
18 if (strcmp(cmd, "markdown") == 0) { /** **/
19 /* undocumented, for testing only */
20 xs *c = xs_readall(stdin);
21@@ -118,8 +105,20 @@ int main(int argc, char *argv[])
22 return 0;
23 }
24
25- if ((basedir = GET_ARGV()) == NULL)
26- return usage();
27+ if ((basedir = getenv("SNAC_BASEDIR")) == NULL) {
28+ if ((basedir = GET_ARGV()) == NULL)
29+ return usage();
30+ }
31+
32+ if (strcmp(cmd, "upgrade") == 0) { /** **/
33+ int ret;
34+
35+ /* upgrade */
36+ if ((ret = srv_open(basedir, 1)) == 1)
37+ srv_log(xs_dup("OK"));
38+
39+ return ret;
40+ }
41
42 if (!srv_open(basedir, 0)) {
43 srv_log(xs_fmt("error opening data storage at %s", basedir));