-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));
- ctdlvisor_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();
- ctdlvisor_exit(0);
-}
-
-
-void install_as_service(void) {
-
- // FIXME fail if some other citadel distribution is already there
- // FIXME fail if any server processes are running
- // FIXME interact with the user
- // FIXME get port numbers and data directory
- // FIXME create the data directory
- // FIXME move the appimage into its permanent location
-
- fprintf(stderr, "Installing as service\n");
-
- FILE *fp = fopen("/etc/systemd/system/ctdl.service", "w");
- fprintf(fp, "# This unit file starts all Citadel services via the AppImage distribution.\n"
- "[Unit]\n"
- "Description=Citadel\n"
- "After=network.target\n"
- "[Service]\n"
- "ExecStart=/root/citadel/appimage/Citadel-x86_64.AppImage run -h %s -s %s -s %s\n"
- "ExecStop=/bin/kill $MAINPID\n"
- "KillMode=process\n"
- "Restart=on-failure\n"
- "LimitCORE=infinity\n"
- "[Install]\n"
- "WantedBy=multi-user.target\n"
- ,
- data_directory, http_port, https_port
- );
- fclose(fp);
-
- fprintf(stderr, "systemd unit file is installed. Type 'systemctl enable ctdl' to have it start at boot.\n");
-}
-
-
-static char *usage =
- "\n"
- "ctdlvisor: usage: ctdlvisor [-h data_directory] [-p http_port] [-s https_port] command\n"
- " 'command' must be one of: run, install, remove, upgrade, test, help\n"
- "\n"
-;
-