}
-void install_client_link(void) { // FIXME this is all furkokt and needs to be rethought now that it's docker and not appimage
-
- FILE *fp;
- char path_to_link[PATH_MAX];
- snprintf(path_to_link, sizeof path_to_link, CTDL_DIR "citadel");
- fp = fopen(path_to_link, "w");
- if (!fp) {
- fprintf(stderr, "%s\n", strerror(errno));
- return;
- }
-
- fprintf(fp, "#!/bin/bash\n"
- "export APPDIR=%s\n"
- "export LD_LIBRARY_PATH=${APPDIR}/usr/bin:$LD_LIBRARY_PATH\n"
- "export PATH=${APPDIR}/usr/bin:$PATH\n"
- "exec citadel\n"
- ,
- getenv("APPDIR")
- );
-
- fchmod(fileno(fp), 0755);
- fclose(fp);
-}
-
-
int main(int argc, char **argv) {
int a;
int migrate_mode = 0;
+ int database_cleanup_mode = 0;
fprintf(stderr, "ctdlvisor: Welcome to the Citadel System running in a container.\n");
fprintf(stderr, "ctdlvisor: command line arguments: ");
symlink(CTDL_DIR "/keys", "/usr/local/webcit/keys");
/* parse command-line arguments */
- while ((a=getopt(argc, argv, "cm")) != EOF) switch(a) {
+ while ((a=getopt(argc, argv, "cmd")) != EOF) switch(a) {
// test this binary for compatibility and exit
case 'c':
migrate_mode = 1;
break;
+ // run database_cleanup.sh only
+ case 'd':
+ database_cleanup_mode = 1;
+ break;
+
// any other parameter makes it crash and burn
default:
fprintf(stderr, "usage\n");
kill(citserver_pid, SIGTERM);
}
+ // "database cleanup mode" means we just start the server and then run database_cleanup.sh interactively
+ else if (database_cleanup_mode) {
+ citserver_pid = start_citadel();
+ fprintf(stderr, "ctdlvisor: waiting a moment for citserver to initialize...\n");
+ sleep(5);
+ char bin[1024];
+ sprintf(bin, "/usr/local/citadel/database_cleanup.sh -h %s", CTDL_DIR);
+ system(bin);
+ kill(citserver_pid, SIGTERM);
+ }
+
// Otherwise, it's just a normal happy day in Citadel land.
else {
signal(SIGTERM, signal_handler);
webcit_pid = start_webcit(); // start WebCit HTTP
webcits_pid = start_webcits(); // start WebCit HTTPS
- install_client_link();
-
main_loop();
}