calendar.o calendar_tools.o calendar_view.o event.o \
availability.o iconbar.o crypto.o inetconf.o notes.o \
groupdav_main.o groupdav_get.o groupdav_propfind.o \
- groupdav_delete.o groupdav_put.o http_datestring.o \
+ groupdav_delete.o groupdav_put.o http_datestring.o setup_wizard.o \
$(LIBOBJS)
$(CC) webserver.o context_loop.o tools.o cookie_conversion.o \
webcit.o auth.o tcp_sockets.o mainmenu.o serv_func.o who.o listsub.o \
summary.o calendar.o calendar_tools.o calendar_view.o event.o \
availability.o ical_dezonify.o iconbar.o crypto.o inetconf.o notes.o \
groupdav_main.o groupdav_get.o groupdav_propfind.o groupdav_delete.o \
- groupdav_put.o http_datestring.o \
+ groupdav_put.o http_datestring.o setup_wizard.o \
$(LIBOBJS) $(LIBS) $(LDFLAGS) -o webserver
.c.o:
void do_welcome(void)
{
- char startpage[SIZ];
+ char buf[SIZ];
+ FILE *fp;
+ int i;
+
+ /*
+ * See if we have to run the first-time setup wizard
+ */
+ if (!setup_wizard) {
+ sprintf(wizard_filename, "setupwiz.%s.%s", ctdlhost, ctdlport);
+ for (i=0; i<strlen(wizard_filename); ++i) {
+ if ( (wizard_filename[i]==' ')
+ || (wizard_filename[i] == '/')
+ ) {
+ wizard_filename[i] = '_';
+ }
+ }
+
+ fp = fopen(wizard_filename, "r");
+ if (fp != NULL) {
+ fgets(buf, sizeof buf, fp);
+ buf[strlen(buf)-1] = 0;
+ fclose(fp);
+ if (atoi(buf) != serv_info.serv_rev_level) {
+ setup_wizard = 1; /* already run */
+ }
+ }
+ }
- get_preference("startpage", startpage);
- if (strlen(startpage)==0) {
- strcpy(startpage, "/dotskip&room=_BASEROOM_");
- set_preference("startpage", startpage);
+ if (!setup_wizard) {
+ http_redirect("/setup_wizard");
}
- http_redirect(startpage);
+ /*
+ * Go to the user's preferred start page
+ */
+ get_preference("startpage", buf);
+ if (strlen(buf)==0) {
+ strcpy(buf, "/dotskip&room=_BASEROOM_");
+ set_preference("startpage", buf);
+ }
+ http_redirect(buf);
}
--- /dev/null
+/*
+ * $Id$
+ *
+ * First-time setup wizard
+ */
+
+#include <ctype.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <limits.h>
+#include <netinet/in.h>
+#include <netdb.h>
+#include <string.h>
+#include <pwd.h>
+#include <errno.h>
+#include <stdarg.h>
+#include <pthread.h>
+#include <signal.h>
+#include "webcit.h"
+
+
+
+/*
+ */
+void do_setup_wizard(void)
+{
+
+ output_headers(1, 1, 2, 0, 1, 0, 0);
+
+ wprintf("<div id=\"banner\">\n");
+ wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>");
+ wprintf("<IMG SRC=\"/static/users-icon.gif\" ALT=\" \" ALIGN=MIDDLE>");
+ wprintf("<SPAN CLASS=\"titlebar\"> First time setup");
+ wprintf("</SPAN></TD><TD ALIGN=RIGHT>");
+ offer_start_page();
+ wprintf("</TD></TR></TABLE>\n");
+ wprintf("</div>\n"
+ "<div id=\"content\">\n");
+
+ wprintf("<div id=\"fix_scrollbar_bug\">");
+
+ wprintf("wow");
+
+ wprintf("</div>\n"
+ "<div align=center>"
+ "Click on a name to read user info. Click on "
+ "<IMG ALIGN=MIDDLE SRC=\"/static/page.gif\" ALT=\"(p)\" "
+ "BORDER=0> to send "
+ "a page (instant message) to that user.</div>\n");
+ wDumpContent(1);
+}
+
+
display_inetconf();
} else if (!strcasecmp(action, "save_inetconf")) {
save_inetconf();
+ } else if (!strcasecmp(action, "setup_wizard")) {
+ do_setup_wizard();
} else if (!strcasecmp(action, "diagnostics")) {
output_headers(1, 1, 1, 0, 0, 0, 0);
extern char *ctdlhost, *ctdlport;
extern char *server_cookie;
extern int is_https;
-
+extern int setup_wizard;
+extern char wizard_filename[PATH_MAX];
+void do_setup_wizard(void);
void stuff_to_cookie(char *cookie, int session,
char *user, char *pass, char *room);
char *ctdlhost = DEFAULT_HOST;
char *ctdlport = DEFAULT_PORT;
+int setup_wizard = 0;
+char wizard_filename[PATH_MAX];
/*
* This is a generic function to set up a master socket for listening on