summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main.c')
-rw-r--r--main.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/main.c b/main.c
index 8e3dbd2..862f30d 100644
--- a/main.c
+++ b/main.c
@@ -16,6 +16,7 @@ int usage(void)
16 printf("Commands:\n"); 16 printf("Commands:\n");
17 printf("\n"); 17 printf("\n");
18 printf("init [{basedir}] Initializes the database\n"); 18 printf("init [{basedir}] Initializes the database\n");
19 printf("upgrade {basedir} Upgrade to a new version\n");
19 printf("adduser {basedir} [{uid}] Adds a new user\n"); 20 printf("adduser {basedir} [{uid}] Adds a new user\n");
20 printf("httpd {basedir} Starts the HTTPD daemon\n"); 21 printf("httpd {basedir} Starts the HTTPD daemon\n");
21 printf("purge {basedir} Purges old data\n"); 22 printf("purge {basedir} Purges old data\n");
@@ -76,6 +77,19 @@ int main(int argc, char *argv[])
76 return initdb(basedir); 77 return initdb(basedir);
77 } 78 }
78 79
80 if (strcmp(cmd, "upgrade") == 0) {
81 int ret;
82
83 /* database upgrade */
84 if ((basedir = GET_ARGV()) == NULL)
85 return usage();
86
87 if ((ret = srv_open(basedir, 1)) == 1)
88 srv_log(xs_dup("OK"));
89
90 return ret;
91 }
92
79 if (strcmp(cmd, "markdown") == 0) { 93 if (strcmp(cmd, "markdown") == 0) {
80 /* undocumented, for testing only */ 94 /* undocumented, for testing only */
81 xs *c = xs_readall(stdin); 95 xs *c = xs_readall(stdin);
@@ -88,7 +102,7 @@ int main(int argc, char *argv[])
88 if ((basedir = GET_ARGV()) == NULL) 102 if ((basedir = GET_ARGV()) == NULL)
89 return usage(); 103 return usage();
90 104
91 if (!srv_open(basedir)) { 105 if (!srv_open(basedir, 0)) {
92 srv_log(xs_fmt("error opening database at %s", basedir)); 106 srv_log(xs_fmt("error opening database at %s", basedir));
93 return 1; 107 return 1;
94 } 108 }