+ /* Default port numbers */
+ sprintf(http_port, "2000");
+#ifdef HAVE_OPENSSL
+ sprintf(https_port, "443");
+#endif
+
+ /* This is a very hackish way of learning the port numbers used
+ * in a previous install, if we are upgrading: read them out of
+ * the existing init script.
+ */
+ fp = fopen("/etc/init.d/webcit", "r");
+ if (fp != NULL) {
+ while (fgets(buf, sizeof buf, fp) != NULL) {
+ if (strlen(buf) > 0) {
+ buf[strlen(buf)-1] = 0; /* strip trailing cr */
+ }
+ if (!strncasecmp(buf, "HTTP_PORT=", 10)) {
+ safestrncpy(http_port, &buf[10], sizeof http_port);
+ }
+#ifdef HAVE_OPENSSL
+ if (!strncasecmp(buf, "HTTPS_PORT=", 11)) {
+ safestrncpy(https_port, &buf[11], sizeof https_port);
+ }
+#endif
+ }
+ fclose(fp);
+ }
+
+ /* Now ask for the port numbers */