]> code.citadel.org Git - citadel.git/blobdiff - webcit/setup.c
* Cleaned up a couple of FIXME's sitting around in the code
[citadel.git] / webcit / setup.c
index 2bb76df2b1f2754b8b7ae07a42d40b1378d55ec5..4478728c6f1021120d31db98cb0f21c4ed33dfdd 100644 (file)
@@ -37,6 +37,7 @@
 int setup_type;
 char setup_directory[SIZ];
 char init_entry[SIZ];
+int using_web_installer = 0;
 
 
 /*
@@ -385,7 +386,8 @@ void check_inittab_entry(void)
        char looking_for[SIZ];
        char question[SIZ];
        char entryname[5];
-       char listenport[128];
+       char http_port[128];
+       char https_port[128];
        char hostname[128];
        char portname[128];
 
@@ -410,27 +412,43 @@ void check_inittab_entry(void)
                "requests?\n\nYou can use the standard port (80) if you are "
                "not running another\nweb server (such as Apache), otherwise "
                "select another port.");
-       sprintf(listenport, "2000");
-       set_value(question, listenport);
+       sprintf(http_port, "2000");
+       set_value(question, http_port);
 
-       /* Find out where Citadel is. */
+#ifdef HAVE_OPENSSL
        snprintf(question, sizeof question,
-               "Is the Citadel service running on the same host as WebCit?");
-       if (yesno(question)) {
-               sprintf(hostname, "uds");
-               sprintf(portname, "/usr/local/citadel");
-               set_value("In what directory is Citadel installed?", portname);
+               "On which port do you want WebCit to listen for HTTPS "
+               "requests?\n\nYou can use the standard port (443) if you are "
+               "not running another\nweb server (such as Apache), otherwise "
+               "select another port.");
+       sprintf(https_port, "443");
+       set_value(question, https_port);
+#endif
+
+       /* Find out where Citadel is. */
+       if ( (using_web_installer) && (getenv("CITADEL") != NULL) ) {
+               strcpy(hostname, "uds");
+               strcpy(portname, getenv("CITADEL"));
        }
        else {
-               sprintf(hostname, "127.0.0.1");
-               sprintf(portname, "504");
-               set_value("Enter the host name or IP address of your "
-                       "Citadel server.", hostname);
-               set_value("Enter the port number on which Citadel is "
-                       "running (usually 504)", portname);
+               snprintf(question, sizeof question,
+                       "Is the Citadel service running on the same host as WebCit?");
+               if (yesno(question)) {
+                       sprintf(hostname, "uds");
+                       sprintf(portname, "/usr/local/citadel");
+                       set_value("In what directory is Citadel installed?", portname);
+               }
+               else {
+                       sprintf(hostname, "127.0.0.1");
+                       sprintf(portname, "504");
+                       set_value("Enter the host name or IP address of your "
+                               "Citadel server.", hostname);
+                       set_value("Enter the port number on which Citadel is "
+                               "running (usually 504)", portname);
+               }
        }
 
-       /* Generate a unique entry name for /etc/inittab */
+       /* Generate unique entry names for /etc/inittab */
        snprintf(entryname, sizeof entryname, "c0");
        do {
                ++entryname[1];
@@ -446,6 +464,7 @@ void check_inittab_entry(void)
                snprintf(buf, sizeof buf,
                     "grep %s: /etc/inittab >/dev/null 2>&1", entryname);
        } while (system(buf) == 0);
+       
 
        /* Now write it out to /etc/inittab */
        infp = fopen("/etc/inittab", "a");
@@ -453,9 +472,14 @@ void check_inittab_entry(void)
                display_error(strerror(errno));
        } else {
                fprintf(infp, "# Start the WebCit server...\n");
-               fprintf(infp, "%s:2345:respawn:%s -p%s %s %s\n",
+               fprintf(infp, "h%s:2345:respawn:%s -p%s %s %s\n",
+                       entryname, looking_for,
+                       http_port, hostname, portname);
+#ifdef HAVE_OPENSSL
+               fprintf(infp, "s%s:2345:respawn:%s -p%s -s %s %s\n",
                        entryname, looking_for,
-                       listenport, hostname, portname);
+                       https_port, hostname, portname);
+#endif
                fclose(infp);
                strcpy(init_entry, entryname);
        }
@@ -492,6 +516,11 @@ int main(int argc, char *argv[])
        /* set an invalid setup type */
        setup_type = (-1);
 
+       /* Check to see if we're running the web installer */
+       if (getenv("CITADEL_INSTALLER") != NULL) {
+               using_web_installer = 1;
+       }
+
        /* parse command line args */
        for (a = 0; a < argc; ++a) {
                if (!strncmp(argv[a], "-u", 2)) {
@@ -521,8 +550,13 @@ int main(int argc, char *argv[])
 
        /* Get started in a valid setup directory. */
        strcpy(setup_directory, WEBCITDIR);
-       set_value("In what directory is WebCit installed?",
-               setup_directory);
+       if ( (using_web_installer) && (getenv("WEBCIT") != NULL) ) {
+               strcpy(setup_directory, getenv("WEBCIT"));
+       }
+       else {
+               set_value("In what directory is WebCit installed?",
+                       setup_directory);
+       }
        if (chdir(setup_directory) != 0) {
                important_message("WebCit Setup",
                          "The directory you specified does not exist.");