// This is a supervisor program that handles start/stop/restart of
// the various Citadel System components, when we are running in
-// a Docker container.
+// a container.
//
-// Copyright (c) 2021 by the citadel.org team
+// Copyright (c) 2021-2023 by the citadel.org team
//
// This program is open source software. Use, duplication, or disclosure
// is subject to the terms of the GNU General Public License, version 3.
// Call this instead of exit() just for common diagnostics etc.
void ctdlvisor_exit(int code) {
- printf("ctdlvisor: exit code %d\n", code);
+ fprintf(stderr, "ctdlvisor: exit code %d\n", code);
exit(code);
}
int main(int argc, char **argv) {
int a;
- int migrate_mode = 0;
+ int export_mode = 0;
+ int import_mode = 0;
int database_cleanup_mode = 0;
+ char bin[1024];
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, "cmdx:")) != EOF) switch(a) {
+ while ((a=getopt(argc, argv, "ceidx:")) != EOF) switch(a) {
// test this binary for compatibility and exit
case 'c':
- fprintf(stderr, "%s: binary compatibility confirmed\n", argv[0]);
+ fprintf(stderr, "%s: binary compatibility CONFIRMED! You CAN run Citadel in a container on this system.\n", argv[0]);
exit(0);
break;
- // run ctdlmigrate only
- case 'm':
- migrate_mode = 1;
+ // export your database
+ case 'e':
+ export_mode = 1;
+ break;
+
+ // import your database
+ case 'i':
+ import_mode = 1;
break;
// run database_cleanup.sh only
// any other parameter makes it crash and burn
default:
- fprintf(stderr, "%s: usage: %s [-c] [-m] [-d] [-x log_level]\n");
+ fprintf(stderr, "%s: usage: %s [-c] [-e] [-i] [-d] [-x log_level]\n", argv[0], argv[0]);
exit(1);
}
signal(SIGHUP, signal_handler);
- // "migrate mode" means we just start the server and then run ctdlmigrate interactively.
- if (migrate_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/ctdlmigrate -h %s", CTDL_DIR);
+ // "export mode" means we only run ctdldump
+ if (export_mode) {
+ sprintf(bin, "/usr/local/citadel/ctdldump -y -h %s", CTDL_DIR);
+ system(bin);
+ }
+
+ // "import mode" means we only run ctdlload
+ else if (import_mode) {
+ sprintf(bin, "/usr/local/citadel/ctdlload -y -h %s", CTDL_DIR);
system(bin);
- 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);