c2d83a4400a36853d9e9e71f1f601471f64958a7
[citadel.git] / webcit / setup.c
1 /*
2  * $Id$
3  *
4  * WebCit setup utility
5  * 
6  * (This is basically just an install wizard.  It's not required.)
7  *
8  */
9
10 #include "sysdep.h"
11 #include "webcit.h"
12 #include "webserver.h"
13
14
15 #define UI_TEXT         0       /* Default setup type -- text only */
16 #define UI_DIALOG       2       /* Use the 'dialog' program */
17 #define UI_SILENT       3       /* Silent running, for use in scripts */
18
19 int setup_type;
20 char setup_directory[SIZ];
21 int using_web_installer = 0;
22 char suggested_url[SIZ];
23
24 /* some copies... */
25 int lprintf(int loglevel, const char *format, ...){return 0;}
26 void wc_printf(const char *format,...){}
27
28 void RegisterNS(const char *NSName, long len, 
29                 int nMinArgs, 
30                 int nMaxArgs, 
31                 WCHandlerFunc HandlerFunc,
32                 WCPreevalFunc PreEvalFunc,
33                 int ContextRequired){}
34 void RegisterHeaderHandler(const char *Name, long Len, Header_Evaluator F){}
35 pthread_key_t MyConKey;
36
37 #ifdef ENABLE_NLS
38
39 #ifdef HAVE_USELOCALE 
40 int localeoffset = 1;
41 #else
42 int localeoffset = 0;
43 #endif
44
45 #endif
46 /*
47  * Delete an entry from /etc/inittab
48  */
49 void delete_init_entry(char *which_entry)
50 {
51         char *inittab = NULL;
52         FILE *fp;
53         char buf[SIZ];
54         char entry[SIZ];
55         char levels[SIZ];
56         char state[SIZ];
57         char prog[SIZ];
58         int rv;
59
60         inittab = strdup("");
61         if (inittab == NULL) return;
62
63         fp = fopen("/etc/inittab", "r");
64         if (fp == NULL) return;
65
66         while(fgets(buf, sizeof buf, fp) != NULL) {
67
68                 if (num_tokens(buf, ':') == 4) {
69                         extract_token(entry, buf, 0, ':', sizeof entry);
70                         extract_token(levels, buf, 1, ':', sizeof levels);
71                         extract_token(state, buf, 2, ':', sizeof state);
72                         extract_token(prog, buf, 3, ':', sizeof prog); /* includes 0x0a LF */
73
74                         if (!strcmp(entry, which_entry)) {
75                                 strcpy(state, "off");   /* disable it */
76                         }
77                 }
78
79                 inittab = realloc(inittab, strlen(inittab) + strlen(buf) + 2);
80                 if (inittab == NULL) {
81                         fclose(fp);
82                         return;
83                 }
84                 
85                 strcat(inittab, buf);
86         }
87         fclose(fp);
88         fp = fopen("/etc/inittab", "w");
89         if (fp != NULL) {
90                 rv = fwrite(inittab, strlen(inittab), 1, fp);
91                 fclose(fp);
92                 kill(1, SIGHUP);        /* Tell init to re-read /etc/inittab */
93         }
94         free(inittab);
95 }
96
97
98
99
100 /* 
101  * Remove any /etc/inittab entries for webcit, because we don't
102  * start it that way anymore.
103  */
104 void delete_the_old_way(void) {
105         FILE *infp;
106         char buf[1024];
107         char looking_for[1024];
108         int have_entry = 0;
109         char entry[1024];
110         char prog[1024];
111         char init_entry[1024];
112
113
114         strcpy(init_entry, "");
115
116         /* Determine the fully qualified path name of webcit */
117         snprintf(looking_for, sizeof looking_for, "%s/webcit ", setup_directory);
118
119         /* Pound through /etc/inittab line by line.  Set have_entry to 1 if
120          * an entry is found which we believe starts webcit.
121          */
122         infp = fopen("/etc/inittab", "r");
123         if (infp == NULL) {
124                 return;
125         } else {
126                 while (fgets(buf, sizeof buf, infp) != NULL) {
127                         buf[strlen(buf) - 1] = 0;
128                         extract_token(entry, buf, 0, ':', sizeof entry);
129                         extract_token(prog, buf, 3, ':', sizeof prog);
130                         if (!strncasecmp(prog, looking_for,
131                            strlen(looking_for))) {
132                                 ++have_entry;
133                                 strcpy(init_entry, entry);
134                         }
135                 }
136                 fclose(infp);
137         }
138
139         /* Bail out if there's nothing to do. */
140         if (!have_entry) return;
141
142         delete_init_entry(init_entry);
143 }
144
145
146
147 void cleanup(int exitcode)
148 {
149         exit(exitcode);
150 }
151
152
153
154 void title(char *text)
155 {
156         if (setup_type == UI_TEXT) {
157                 printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n<%s>\n", text);
158         }
159 }
160
161
162
163
164 int yesno(char *question, int default_value)
165 {
166         int i = 0;
167         int answer = 0;
168         char buf[SIZ] = "";
169
170         switch (setup_type) {
171
172         case UI_TEXT:
173                 do {
174                         printf("%s\nYes/No [%s] --> ",
175                                 question,
176                                 ( default_value ? "Yes" : "No" )
177                         );
178                         if (fgets(buf, sizeof buf, stdin))
179                         {
180                                 answer = tolower(buf[0]);
181                                 if ((buf[0]==0) || (buf[0]==13) || (buf[0]==10))
182                                         answer = default_value;
183                                 else if (answer == 'y')
184                                         answer = 1;
185                                 else if (answer == 'n')
186                                         answer = 0;
187                         }
188
189                 } while ((answer < 0) || (answer > 1));
190                 break;
191
192         case UI_DIALOG:
193                 sprintf(buf, "exec %s %s --yesno '%s' 15 75",
194                         getenv("CTDL_DIALOG"),
195                         ( default_value ? "" : "--defaultno" ),
196                         question);
197                 i = system(buf);
198                 if (i == 0) {
199                         answer = 1;
200                 }
201                 else {
202                         answer = 0;
203                 }
204                 break;
205
206         }
207         return (answer);
208 }
209
210
211
212
213 void set_value(char *prompt, char str[])
214 {
215         char buf[SIZ] = "";
216         char dialog_result[PATH_MAX];
217         char setupmsg[SIZ];
218         FILE *fp;
219         int rv;
220
221         strcpy(setupmsg, "");
222
223         switch (setup_type) {
224         case UI_TEXT:
225                 title("WebCit setup");
226                 printf("\n%s\n", prompt);
227                 printf("This is currently set to:\n%s\n", str);
228                 printf("Enter new value or press return to leave unchanged:\n");
229                 if (fgets(buf, sizeof buf, stdin)) {
230                         buf[strlen(buf) - 1] = 0;
231                 }
232                 if (strlen(buf) != 0)
233                         strcpy(str, buf);
234                 break;
235         case UI_DIALOG:
236                 CtdlMakeTempFileName(dialog_result, sizeof dialog_result);
237                 sprintf(buf, "exec %s --inputbox '%s' 19 72 '%s' 2>%s",
238                         getenv("CTDL_DIALOG"),
239                         prompt,
240                         str,
241                         dialog_result);
242                 rv = system(buf);
243                 fp = fopen(dialog_result, "r");
244                 if (fp != NULL) {
245                         if (fgets(str, sizeof buf, fp)){
246                                 if (str[strlen(str)-1] == 10) {
247                                         str[strlen(str)-1] = 0;
248                                 }
249                         }
250                         fclose(fp);
251                         unlink(dialog_result);
252                 }
253                 break;
254
255         }
256 }
257
258
259 extern const char *AvailLang[];
260 int GetLocalePrefs(void)
261 {
262         int nLocales;
263         StrBuf *Buf;
264         char buf[SIZ];
265         char dialog_result[PATH_MAX];
266         FILE *fp;
267         int i = 0;
268         int offs = 0;
269         int rv;
270
271
272         nLocales = 0; 
273         while (!IsEmptyStr(AvailLang[nLocales]))
274                 nLocales++;
275
276         Buf = NewStrBuf();
277
278         StrBufAppendBufPlain(Buf, HKEY("Select the locale webcit should use : \n"), 0);
279 #ifdef HAVE_USELOCALE 
280         StrBufAppendBufPlain(Buf, HKEY(" 0 Let the user select it at the login prompt (default)\n"), 0);
281         offs ++;
282 #endif
283         for (i = 0; i < nLocales; i++) {
284                 StrBufAppendPrintf(Buf, " %ld: %s\n", i + offs, AvailLang[i]);
285
286         }
287
288         switch (setup_type) {
289         case UI_TEXT:
290                 title("WebCit setup");
291                 printf("\n%s\n", ChrPtr(Buf));
292                 printf("This is currently set to:\n%ld\n", 0L);
293                 printf("Enter new value or press return to leave unchanged:\n");
294                 if (fgets(buf, sizeof buf, stdin))
295                         return atoi(buf);
296                 break;
297
298         case UI_DIALOG:
299                 CtdlMakeTempFileName(dialog_result, sizeof dialog_result);
300                 sprintf(buf, "exec %s --inputbox '%s' 19 72 '%ld' 2>%s",
301                         getenv("CTDL_DIALOG"),
302                         ChrPtr(Buf),
303                         0L,
304                         dialog_result);
305                 rv = system(buf);
306                 fp = fopen(dialog_result, "r");
307                 if (fp != NULL) {
308                         char *str = &buf[0];
309                         if (fgets(str, sizeof buf, fp)){
310                                 if (str[strlen(str)-1] == 10) {
311                                         str[strlen(str)-1] = 0;
312                                 }
313                         }
314                         fclose(fp);
315                         unlink(dialog_result);
316                         return atoi(buf);
317                 }
318                 break;
319
320         }
321         return 0;
322 }
323
324 void important_message(char *title, char *msgtext)
325 {
326         char buf[SIZ];
327         int rv;
328
329         switch (setup_type) {
330
331         case UI_TEXT:
332                 printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
333                 printf("       %s \n\n%s\n\n", title, msgtext);
334                 printf("Press return to continue...");
335                 if (fgets(buf, sizeof buf, stdin));
336                 break;
337
338         case UI_DIALOG:
339                 sprintf(buf, "exec %s --msgbox '%s' 19 72",
340                         getenv("CTDL_DIALOG"),
341                         msgtext);
342                 rv = system(buf);
343                 break;
344         }
345 }
346
347
348 void display_error(char *error_message)
349 {
350         important_message("Error", error_message);
351 }
352
353 void progress(char *text, long int curr, long int cmax)
354 {
355         static long dots_printed = 0L;
356         long a = 0;
357         char buf[SIZ];
358         static FILE *fp = NULL;
359
360         switch (setup_type) {
361
362         case UI_TEXT:
363                 if (curr == 0) {
364                         printf("%s\n", text);
365                         printf("..........................");
366                         printf("..........................");
367                         printf("..........................\r");
368                         fflush(stdout);
369                         dots_printed = 0;
370                 } else if (curr == cmax) {
371                         printf("\r%79s\n", "");
372                 } else {
373                         a = (curr * 100) / cmax;
374                         a = a * 78;
375                         a = a / 100;
376                         while (dots_printed < a) {
377                                 printf("*");
378                                 ++dots_printed;
379                                 fflush(stdout);
380                         }
381                 }
382                 break;
383
384         case UI_DIALOG:
385                 if (curr == 0) {
386                         sprintf(buf, "exec %s --gauge '%s' 7 72 0",
387                                 getenv("CTDL_DIALOG"),
388                                 text);
389                         fp = popen(buf, "w");
390                         if (fp != NULL) {
391                                 fprintf(fp, "0\n");
392                                 fflush(fp);
393                         }
394                 } 
395                 else if (curr == cmax) {
396                         if (fp != NULL) {
397                                 fprintf(fp, "100\n");
398                                 pclose(fp);
399                                 fp = NULL;
400                         }
401                 }
402                 else {
403                         a = (curr * 100) / cmax;
404                         if (fp != NULL) {
405                                 fprintf(fp, "%ld\n", a);
406                                 fflush(fp);
407                         }
408                 }
409                 break;
410         }
411 }
412
413
414
415
416 /*
417  * install_init_scripts()  -- Create and deploy SysV init scripts.
418  *
419  */
420 void install_init_scripts(void)
421 {
422 #ifdef ENABLE_NLS
423         int localechoice;
424 #endif
425         char question[1024];
426         char buf[256];
427         char http_port[128];
428 #ifdef HAVE_OPENSSL
429         char https_port[128];
430 #endif
431         char hostname[128];
432         char portname[128];
433         char command[SIZ];
434         struct utsname my_utsname;
435         struct stat etcinitd;
436         FILE *fp;
437         char *initfile = "/etc/init.d/webcit";
438         int rv;
439
440         fp = fopen(initfile, "r");
441         if (fp != NULL) {
442                 if (yesno("WebCit already appears to be configured to start at boot.\n"
443                           "Would you like to keep your boot configuration as is?\n", 1) == 1) {
444                         return;
445                 }
446                 fclose(fp);
447                 
448         }
449
450         /* Otherwise, prompt the user to create an entry. */
451         snprintf(question, sizeof question,
452                  "Would you like to automatically start WebCit at boot?"
453                 );
454         if (yesno(question, 1) == 0)
455                 return;
456
457
458 #ifdef ENABLE_NLS
459
460         localechoice = GetLocalePrefs();
461
462 #endif
463         /* Defaults */
464         sprintf(http_port, "2000");
465 #ifdef HAVE_OPENSSL
466         sprintf(https_port, "443");
467 #endif
468         sprintf(hostname, "uds");
469         sprintf(portname, "/usr/local/citadel");
470
471         /* This is a very hackish way of learning the port numbers used
472          * in a previous install, if we are upgrading: read them out of
473          * the existing init script.
474          */
475         if ((stat("/etc/init.d/", &etcinitd) == -1) && 
476             (errno == ENOENT))
477         {
478                 if ((stat("/etc/rc.d/init.d/", &etcinitd) == -1) &&
479                     (errno == ENOENT))
480                         initfile = WEBCITDIR"/webcit.init";
481                 else
482                         initfile = "/etc/rc.d/init.d/webcit";
483         }
484
485         fp = fopen(initfile, "r");
486         if (fp != NULL) {
487                 while (fgets(buf, sizeof buf, fp) != NULL) {
488                         if (strlen(buf) > 0) {
489                                 buf[strlen(buf)-1] = 0; /* strip trailing cr */
490                         }
491                         if (!strncasecmp(buf, "HTTP_PORT=", 10)) {
492                                 safestrncpy(http_port, &buf[10], sizeof http_port);
493                         }
494 #ifdef HAVE_OPENSSL
495                         if (!strncasecmp(buf, "HTTPS_PORT=", 11)) {
496                                 safestrncpy(https_port, &buf[11], sizeof https_port);
497                         }
498 #endif
499                         if (!strncasecmp(buf, "CTDL_HOSTNAME=", 14)) {
500                                 safestrncpy(hostname, &buf[14], sizeof hostname);
501                         }
502                         if (!strncasecmp(buf, "CTDL_PORTNAME=", 14)) {
503                                 safestrncpy(portname, &buf[14], sizeof portname);
504                         }
505                 }
506                 fclose(fp);
507         }
508
509         /* Now ask for the port numbers */
510         snprintf(question, sizeof question,
511                  "On which port do you want WebCit to listen for HTTP "
512                  "requests?\n\nYou can use the standard port (80) if you are "
513                  "not running another\nweb server (such as Apache), otherwise "
514                  "select another port.");
515         set_value(question, http_port);
516         uname(&my_utsname);
517         sprintf(suggested_url, "http://%s:%s/", my_utsname.nodename, http_port);
518
519 #ifdef HAVE_OPENSSL
520         snprintf(question, sizeof question,
521                  "On which port do you want WebCit to listen for HTTPS "
522                  "requests?\n\nYou can use the standard port (443) if you are "
523                  "not running another\nweb server (such as Apache), otherwise "
524                  "select another port.");
525         set_value(question, https_port);
526 #endif
527
528         /* Find out where Citadel is. */
529         if ( (using_web_installer) && (getenv("CITADEL") != NULL) ) {
530                 strcpy(hostname, "uds");
531                 strcpy(portname, getenv("CITADEL"));
532         }
533         else {
534                 snprintf(question, sizeof question,
535                          "Is the Citadel service running on the same host as WebCit?");
536                 if (yesno(question, ((!strcasecmp(hostname, "uds")) ? 1 : 0))) {
537                         strcpy(hostname, "uds");
538                         if (atoi(portname) != 0) strcpy(portname, "/usr/local/citadel");
539                         set_value("In what directory is Citadel installed?", portname);
540                 }
541                 else {
542                         if (!strcasecmp(hostname, "uds")) strcpy(hostname, "127.0.0.1");
543                         if (atoi(portname) == 0) strcpy(portname, "504");
544                         set_value("Enter the host name or IP address of your "
545                                   "Citadel server.", hostname);
546                         set_value("Enter the port number on which Citadel is "
547                                   "running (usually 504)", portname);
548                 }
549         }
550
551
552         fp = fopen(initfile, "w");
553
554         fprintf(fp,     "#!/bin/sh\n"
555                 "\n"
556                 "# uncomment this to create coredumps as described in\n"
557                 "# http://www.citadel.org/doku.php/faq:mastering_your_os:gdb#how.do.i.make.my.system.produce.core-files\n"
558                 "# ulimit -c unlimited\n"
559                         "WEBCIT_DIR=%s\n", setup_directory);
560         fprintf(fp,     "HTTP_PORT=%s\n", http_port);
561 #ifdef HAVE_OPENSSL
562         fprintf(fp,     "HTTPS_PORT=%s\n", https_port);
563 #endif
564         fprintf(fp,     "CTDL_HOSTNAME=%s\n", hostname);
565         fprintf(fp,     "CTDL_PORTNAME=%s\n", portname);
566
567 #ifdef ENABLE_NLS
568         
569         if (localechoice == 0) {
570 #ifdef HAVE_USELOCALE 
571                 fprintf(fp, "unset LANG\n");
572 #else
573                 fprintf(fp, "export WEBCIT_LANG=c\n");
574 #endif
575         }
576         else {
577                 fprintf(fp, "export WEBCIT_LANG=%s\n", AvailLang[localechoice - localeoffset]);
578
579         }
580 #else
581         fprintf(fp,     "# your system doesn't support locales\n");
582 #endif
583         fprintf(fp,     "\n"
584                         "\n"
585                         "case \"$1\" in\n"
586                         "\n"
587                         "start)         echo -n \"Starting WebCit... \"\n"
588                         "               if   $WEBCIT_DIR/webcit "
589                                                         "-D/var/run/webcit.pid "
590                                                         "-p$HTTP_PORT $CTDL_HOSTNAME $CTDL_PORTNAME\n"
591                         "               then\n"
592                         "                       echo \"ok\"\n"
593                         "               else\n"
594                         "                       echo \"failed\"\n"
595                         "               fi\n");
596 #ifdef HAVE_OPENSSL
597         fprintf(fp,     "               echo -n \"Starting WebCit SSL... \"\n"
598                         "               if  $WEBCIT_DIR/webcit "
599                                                         "-D/var/run/webcit-ssl.pid "
600                                                         "-s -p$HTTPS_PORT $CTDL_HOSTNAME $CTDL_PORTNAME\n"
601                         "               then\n"
602                         "                       echo \"ok\"\n"
603                         "               else\n"
604                         "                       echo \"failed\"\n"
605                         "               fi\n");
606 #endif
607         fprintf(fp,     "               ;;\n"
608                         "stop)          echo -n \"Stopping WebCit... \"\n"
609                         "               if kill `cat /var/run/webcit.pid 2>/dev/null` 2>/dev/null\n"
610                         "               then\n"
611                         "                       echo \"ok\"\n"
612                         "               else\n"
613                         "                       echo \"failed\"\n"
614                         "               fi\n"
615                         "               rm -f /var/run/webcit.pid 2>/dev/null\n");
616 #ifdef HAVE_OPENSSL
617         fprintf(fp,     "               echo -n \"Stopping WebCit SSL... \"\n"
618                         "               if kill `cat /var/run/webcit-ssl.pid 2>/dev/null` 2>/dev/null\n"
619                         "               then\n"
620                         "                       echo \"ok\"\n"
621                         "               else\n"
622                         "                       echo \"failed\"\n"
623                         "               fi\n"
624                         "               rm -f /var/run/webcit-ssl.pid 2>/dev/null\n");
625 #endif
626         fprintf(fp,     "               ;;\n"
627                         "restart)       $0 stop\n"
628                         "               $0 start\n"
629                         "               ;;\n"
630                         "*)             echo \"Usage: $0 {start|stop|restart}\"\n"
631                         "               exit 1\n"
632                         "               ;;\n"
633                         "esac\n"
634         );
635
636         fclose(fp);
637         chmod(initfile, 0755);
638
639         /* Set up the run levels. */
640         rv = system("/bin/rm -f /etc/rc?.d/[SK]??webcit 2>/dev/null");
641         snprintf(command, sizeof(command), "for x in 2 3 4 5 ; do [ -d /etc/rc$x.d ] && ln -s %s /etc/rc$x.d/S84webcit ; done 2>/dev/null", initfile);
642         rv = system(command);
643         snprintf(command, sizeof(command), "for x in 0 6 S; do [ -d /etc/rc$x.d ] && ln -s %s /etc/rc$x.d/K15webcit ; done 2>/dev/null", initfile);
644         rv = system(command);
645
646 }
647
648
649
650
651 /*
652  * Figure out what type of user interface we're going to use
653  */
654 int discover_ui(void)
655 {
656
657         /* Use "dialog" if we have it */
658         if (getenv("CTDL_DIALOG") != NULL) {
659                 return UI_DIALOG;
660         }
661                 
662         return UI_TEXT;
663 }
664
665
666
667
668
669 int main(int argc, char *argv[])
670 {
671         int a;
672         char aaa[256];
673         int info_only = 0;
674         int rv;
675
676         strcpy(suggested_url, "http://<your_host_name>:<port>/");
677
678         /* set an invalid setup type */
679         setup_type = (-1);
680
681         /* Check to see if we're running the web installer */
682         if (getenv("CITADEL_INSTALLER") != NULL) {
683                 using_web_installer = 1;
684         }
685
686         /* parse command line args */
687         for (a = 0; a < argc; ++a) {
688                 if (!strncmp(argv[a], "-u", 2)) {
689                         strcpy(aaa, argv[a]);
690                         strcpy(aaa, &aaa[2]);
691                         setup_type = atoi(aaa);
692                 }
693                 if (!strcmp(argv[a], "-i")) {
694                         info_only = 1;
695                 }
696                 if (!strcmp(argv[a], "-q")) {
697                         setup_type = UI_SILENT;
698                 }
699         }
700
701
702         /* If a setup type was not specified, try to determine automatically
703          * the best one to use out of all available types.
704          */
705         if (setup_type < 0) {
706                 setup_type = discover_ui();
707         }
708         if (info_only == 1) {
709                 important_message("WebCit Setup", "Welcome to WebCit setup");
710                 cleanup(0);
711         }
712
713         /* Get started in a valid setup directory. */
714         strcpy(setup_directory, WEBCITDIR);
715         if ( (using_web_installer) && (getenv("WEBCIT") != NULL) ) {
716                 strcpy(setup_directory, getenv("WEBCIT"));
717         }
718         else {
719                 set_value("In what directory is WebCit installed?",
720                         setup_directory);
721         }
722         if (chdir(setup_directory) != 0) {
723                 important_message("WebCit Setup",
724                           "The directory you specified does not exist.");
725                 cleanup(errno);
726         }
727
728         /*
729          * We used to start WebCit by putting it directly into /etc/inittab.
730          * Since some systems are moving away from init, we can't do this anymore.
731          */
732         progress("Removing obsolete /etc/inittab entries...", 0, 1);
733         delete_the_old_way();
734         progress("Removing obsolete /etc/inittab entries...", 1, 1);
735
736         /* Now begin. */
737         switch (setup_type) {
738
739         case UI_TEXT:
740                 printf("\n\n\n"
741                         "               *** WebCit setup program ***\n\n");
742                 break;
743
744         }
745
746         /* 
747          * If we're running on SysV, install init scripts.
748          */
749         if (!access("/var/run", W_OK)) {
750                 install_init_scripts();
751
752                 if (!access("/etc/init.d/webcit", X_OK)) {
753                         rv = system("/etc/init.d/webcit stop");
754                         rv = system("/etc/init.d/webcit start");
755                 }
756
757                 sprintf(aaa,
758                         "Setup is finished.  You may now log in.\n"
759                         "Point your web browser at %s\n", suggested_url
760                 );
761                 important_message("Setup finished", aaa);
762         }
763
764         else {
765                 important_message("Setup finished",
766                         "Setup is finished.  You may now start the server.");
767         }
768
769         cleanup(0);
770         return 0;
771 }