- /* Try to stop Citadel if we can */
- if (!access("/etc/init.d/citadel", X_OK)) {
- rv = system("/etc/init.d/citadel stop");
- }
-
- /* Make sure Citadel is not running. */
- if (test_server(setup_directory, relhome, enable_home) == 0) {
- important_message("Citadel Setup",
- "The Citadel service is still running.\n"
- "Please stop the service manually and run "
- "setup again.");
- cleanup(1);
- }
-
- /* Now begin. */
- switch (setup_type) {
-
- case UI_TEXT:
- printf("\n\n\n"
- " *** Citadel setup program ***\n\n");
- break;
-
- }
-
- /*
- * What we're going to try to do here is append a whole bunch of
- * nulls to the citadel.config file, so we can keep the old config
- * values if they exist, but if the file is missing or from an
- * earlier version with a shorter config structure, when setup tries
- * to read the old config parameters, they'll all come up zero.
- * The length of the config file will be set to what it's supposed
- * to be when we rewrite it, because we replace the old file with a
- * completely new copy.
- */
- if ((a = open(file_citadel_config, O_WRONLY | O_CREAT | O_APPEND,
- S_IRUSR | S_IWUSR)) == -1) {
- display_error("setup: cannot append citadel.config");
- cleanup(errno);
- }
- fp = fdopen(a, "ab");
- if (fp == NULL) {
- display_error("setup: cannot append citadel.config");
- cleanup(errno);
- }
- for (a = 0; a < sizeof(struct config); ++a) {
- putc(0, fp);
- }
- fclose(fp);
-
- /* now we re-open it, and read the old or blank configuration */
- fp = fopen(file_citadel_config, "rb");
- if (fp == NULL) {
- display_error("setup: cannot open citadel.config");
- cleanup(errno);
- }
- rv = fread((char *) &config, sizeof(struct config), 1, fp);
- fclose(fp);
-