-static char *usage =
- "ctdlvisor: usage: ctdlvisor [-h data_directory] [-p http_port] [-s https_port] command\n"
- " 'command' must be one of:\n"
- " run - start Citadel services in the foreground without detaching\n"
- " install - deploy systemd unit files for automatic startup at boot\n"
- " upgrade - check for new version of the software\n"
- " test - check this appimage for compatibility with your system\n"
-;
-
-int main(int argc, char **argv) {
- int c;
-
- while ((c = getopt (argc, argv, "h:p:s:")) != -1) switch(c) {
- case 'h':
- data_directory = optarg;
- break;
- case 'p':
- http_port = optarg;
- break;
- case 's':
- https_port = optarg;
- break;
- default:
- fprintf(stderr, "%s", usage);
- exit(1);
- }
-
-
- if (argc != optind+1) {
- fprintf(stderr, "%s", usage);
- exit(1);
- }
-
- if (!strcasecmp(argv[optind], "run")) {
- run_in_foreground();
- }
- else if (!strcasecmp(argv[optind], "install")) {
- fprintf(stderr, "oops, this is not implemented yet\n");
- }
- else if (!strcasecmp(argv[optind], "upgrade")) {
- fprintf(stderr, "oops, this is not implemented yet\n");
- }
- else if (!strcasecmp(argv[optind], "test")) {
- fprintf(stderr, "oops, this is not implemented yet\n");
- }
- else {
- fprintf(stderr, "%s", usage);
- exit(1);
- }
-
- exit(0);
-}
-
-
-void run_in_foreground(void) {
- fprintf(stderr, "ctdlvisor: Welcome to the Citadel System, brought to you using AppImage.\n");
- fprintf(stderr, "ctdlvisor: LD_LIBRARY_PATH = %s\n", getenv("LD_LIBRARY_PATH"));
- fprintf(stderr, "ctdlvisor: PATH = %s\n", getenv("PATH"));
- fprintf(stderr, "ctdlvisor: APPDIR = %s\n", getenv("APPDIR"));
- fprintf(stderr, "ctdlvisor: data directory = %s\n", data_directory);
- fprintf(stderr, "ctdlvisor: HTTP port = %s\n", http_port);
- fprintf(stderr, "ctdlvisor: HTTPS port = %s\n", https_port);
-
- if (access(data_directory, R_OK|W_OK|X_OK)) {
- fprintf(stderr, "ctdlvisor: %s: %s\n", data_directory, strerror(errno));
- exit(errno);
- }
-
- signal(SIGTERM, signal_handler);
- signal(SIGHUP, signal_handler);
- signal(SIGINT, signal_handler);
- signal(SIGQUIT, signal_handler);
-
- citserver_pid = start_citadel();
- webcit_pid = start_webcit();
- webcits_pid = start_webcits();
-
- main_loop();
- exit(0);
-}
-
-