diff options
| author | 2025-01-20 10:40:43 +0100 | |
|---|---|---|
| committer | 2025-01-20 10:40:43 +0100 | |
| commit | 5b21c9546b40cc0c52d5f39273747c551926984c (patch) | |
| tree | 3ac7d56be097edc2d2b39489d36e6daf5dd15270 | |
| parent | Updated documentation. (diff) | |
| download | snac2-5b21c9546b40cc0c52d5f39273747c551926984c.tar.gz snac2-5b21c9546b40cc0c52d5f39273747c551926984c.tar.xz snac2-5b21c9546b40cc0c52d5f39273747c551926984c.zip | |
Added support for the SNAC_BASEDIR environment variable.
If it's set, the basedir argument in command-line commands must not be given.
| -rw-r--r-- | main.c | 29 |
1 files changed, 14 insertions, 15 deletions
| @@ -96,19 +96,6 @@ int main(int argc, char *argv[]) | |||
| 96 | return snac_init(basedir); | 96 | return snac_init(basedir); |
| 97 | } | 97 | } |
| 98 | 98 | ||
| 99 | if (strcmp(cmd, "upgrade") == 0) { /** **/ | ||
| 100 | int ret; | ||
| 101 | |||
| 102 | /* upgrade */ | ||
| 103 | if ((basedir = GET_ARGV()) == NULL) | ||
| 104 | return usage(); | ||
| 105 | |||
| 106 | if ((ret = srv_open(basedir, 1)) == 1) | ||
| 107 | srv_log(xs_dup("OK")); | ||
| 108 | |||
| 109 | return ret; | ||
| 110 | } | ||
| 111 | |||
| 112 | if (strcmp(cmd, "markdown") == 0) { /** **/ | 99 | if (strcmp(cmd, "markdown") == 0) { /** **/ |
| 113 | /* undocumented, for testing only */ | 100 | /* undocumented, for testing only */ |
| 114 | xs *c = xs_readall(stdin); | 101 | xs *c = xs_readall(stdin); |
| @@ -118,8 +105,20 @@ int main(int argc, char *argv[]) | |||
| 118 | return 0; | 105 | return 0; |
| 119 | } | 106 | } |
| 120 | 107 | ||
| 121 | if ((basedir = GET_ARGV()) == NULL) | 108 | if ((basedir = getenv("SNAC_BASEDIR")) == NULL) { |
| 122 | return usage(); | 109 | if ((basedir = GET_ARGV()) == NULL) |
| 110 | return usage(); | ||
| 111 | } | ||
| 112 | |||
| 113 | if (strcmp(cmd, "upgrade") == 0) { /** **/ | ||
| 114 | int ret; | ||
| 115 | |||
| 116 | /* upgrade */ | ||
| 117 | if ((ret = srv_open(basedir, 1)) == 1) | ||
| 118 | srv_log(xs_dup("OK")); | ||
| 119 | |||
| 120 | return ret; | ||
| 121 | } | ||
| 123 | 122 | ||
| 124 | if (!srv_open(basedir, 0)) { | 123 | if (!srv_open(basedir, 0)) { |
| 125 | srv_log(xs_fmt("error opening data storage at %s", basedir)); | 124 | srv_log(xs_fmt("error opening data storage at %s", basedir)); |