#define UI_TEXT 0 /* Default setup type -- text only */
+#define UI_DIALOG 2 /* Use the 'dialog' program */
#define UI_SILENT 3 /* Silent running, for use in scripts */
#define UI_NEWT 4 /* Use the "newt" window library */
strcpy(init_entry, "");
/* Determine the fully qualified path name of webserver */
- snprintf(looking_for, sizeof looking_for, "%s/webserver ", WEBCITDIR);
+ snprintf(looking_for, sizeof looking_for, "%s/webserver ", setup_directory);
/* Pound through /etc/inittab line by line. Set have_entry to 1 if
* an entry is found which we believe starts webserver.
newtComponent form = NULL;
newtComponent yesbutton = NULL;
newtComponent nobutton = NULL;
- int i = 0;
#endif
+ int i = 0;
int answer = 0;
char buf[SIZ];
} while ((answer < 0) || (answer > 1));
break;
+ case UI_DIALOG:
+ sprintf(buf, "exec %s --yesno '%s' 10 72",
+ getenv("CTDL_DIALOG"),
+ question);
+ i = system(buf);
+ if (i == 0) {
+ answer = 1;
+ }
+ else {
+ answer = 0;
+ }
+ break;
+
#ifdef HAVE_NEWT
case UI_NEWT:
newtCenteredWindow(76, 10, "Question");
int i;
#endif
char buf[SIZ];
+ char *dialog_result;
char setupmsg[SIZ];
+ FILE *fp;
strcpy(setupmsg, "");
if (strlen(buf) != 0)
strcpy(str, buf);
break;
+
+ case UI_DIALOG:
+ dialog_result = tmpnam(NULL);
+ sprintf(buf, "exec %s --backtitle '%s' --inputbox '%s' 19 72 '%s' 2>%s",
+ getenv("CTDL_DIALOG"),
+ "WebCit setup",
+ prompt,
+ str,
+ dialog_result);
+ system(buf);
+ fp = fopen(dialog_result, "r");
+ if (fp != NULL) {
+ fgets(str, sizeof buf, fp);
+ if (str[strlen(str)-1] == 10) {
+ str[strlen(str)-1] = 0;
+ }
+ fclose(fp);
+ unlink(dialog_result);
+ }
+ break;
+
#ifdef HAVE_NEWT
case UI_NEWT:
fgets(buf, sizeof buf, stdin);
break;
+ case UI_DIALOG:
+ sprintf(buf, "exec %s --backtitle '%s' --msgbox '%s' 19 72",
+ getenv("CTDL_DIALOG"),
+ title,
+ msgtext);
+ system(buf);
+ break;
+
#ifdef HAVE_NEWT
case UI_NEWT:
newtCenteredWindow(76, 10, title);
#endif
static long dots_printed = 0L;
long a = 0;
+ char buf[SIZ];
+ static FILE *fp = NULL;
switch (setup_type) {
}
break;
+ case UI_DIALOG:
+ if (curr == 0) {
+ sprintf(buf, "exec %s --gauge '%s' 7 72 0",
+ getenv("CTDL_DIALOG"),
+ text);
+ fp = popen(buf, "w");
+ if (fp != NULL) {
+ fprintf(fp, "0\n");
+ fflush(fp);
+ }
+ }
+ else if (curr == cmax) {
+ if (fp != NULL) {
+ fprintf(fp, "100\n");
+ pclose(fp);
+ fp = NULL;
+ }
+ }
+ else {
+ a = (curr * 100) / cmax;
+ if (fp != NULL) {
+ fprintf(fp, "%ld\n", a);
+ fflush(fp);
+ }
+ }
+ break;
+
#ifdef HAVE_NEWT
case UI_NEWT:
if (curr == 0) {
char looking_for[SIZ];
char question[SIZ];
char entryname[5];
- char listenport[128];
+ char http_port[128];
+#ifdef HAVE_OPENSSL
+ char https_port[128];
+#endif
char hostname[128];
char portname[128];
/* Determine the fully qualified path name of webserver */
- snprintf(looking_for, sizeof looking_for, "%s/webserver ", WEBCITDIR);
+ snprintf(looking_for, sizeof looking_for, "%s/webserver", setup_directory);
/* If there's already an entry, then we have nothing left to do. */
if (strlen(init_entry) > 0) {
"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);
+
+#ifdef HAVE_OPENSSL
+ snprintf(question, sizeof question,
+ "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) ) {
}
}
- /* Generate a unique entry name for /etc/inittab */
+ /* Generate unique entry names for /etc/inittab */
snprintf(entryname, sizeof entryname, "c0");
do {
++entryname[1];
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");
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,
- listenport, hostname, portname);
+ http_port, hostname, portname);
+#ifdef HAVE_OPENSSL
+ fprintf(infp, "s%s:2345:respawn:%s -p%s -s %s %s\n",
+ entryname, looking_for,
+ https_port, hostname, portname);
+#endif
fclose(infp);
strcpy(init_entry, entryname);
}
int discover_ui(void)
{
+ /* Use "dialog" if we have it */
+ if (getenv("CTDL_DIALOG") != NULL) {
+ return UI_DIALOG;
+ }
+
#ifdef HAVE_NEWT
newtInit();
newtCls();