The little LEDs on the NanoPi blink when there is activity.
[citadel.git] / citadel / utils / setup.c
index 2099418bf765d1d3017c65576e4235a05532d537..a2839ca72d7a237dfa79d4d8f972d14d7a9ff941 100644 (file)
@@ -1,10 +1,9 @@
 // Citadel setup utility
 //
-// Copyright (c) 1987-2022 by the citadel.org team
+// Copyright (c) 1987-2024 by the citadel.org team
 //
 // This program is open source software.  Use, duplication, or disclosure
 // is subject to the terms of the GNU General Public License, version 3.
-// The program is distributed without any warranty, expressed or implied.
 
 #define SHOW_ME_VAPPEND_PRINTF
 #include <stdlib.h>
@@ -26,7 +25,8 @@
 #include <sys/un.h>
 #include <assert.h>
 #include <libcitadel.h>
-#include "../server/citadel.h"
+#include "../server/citadel_defs.h"
+#include "../server/server.h"
 #include "axdefs.h"
 #include "../server/sysdep.h"
 #include "../server/citadel_dirs.h"
@@ -62,8 +62,8 @@ typedef enum _SetupStep {
        eMaxQuestions = 12
 } eSetupStep;
 
-///"CREATE_XINETD_ENTRY";
-/* Environment variables, don't translate! */
+// "CREATE_XINETD_ENTRY";
+// Environment variables, don't translate!
 const char *EnvNames [eMaxQuestions] = {
         "HOME_DIRECTORY",
        "SYSADMIN_NAME",
@@ -178,7 +178,7 @@ void SetTitles(void) {
 " 2. External LDAP - RFC 2307 POSIX schema\n"
 " 3. External LDAP - MS Active Directory schema\n"
 "\n"
-"For help: http://www.citadel.org/doku.php/faq:installation:authmodes\n"
+"For help: http://www.citadel.org/authmodes.html\n"
 "\n"
 "ANSWER \"0\" UNLESS YOU COMPLETELY UNDERSTAND THIS OPTION.\n");
 
@@ -206,24 +206,20 @@ void SetTitles(void) {
 "If you entered a Bind DN in the previous question, you must now enter\n"
 "the password associated with that account.  Otherwise, you can leave this\n"
 "blank.\n");
+}
 
-#if 0
-// Debug loading of locales... Strace does a better job though.
-       printf("Message catalog directory: %s\n", bindtextdomain("citadel-setup", LOCALEDIR"/locale"));
-       printf("Text domain: %s\n", textdomain("citadel-setup"));
-       printf("Text domain Charset: %s\n", bind_textdomain_codeset("citadel-setup","UTF8"));
-       {
-               int i;
-               for (i = 0; i < eMaxQuestions; i++)
-                       printf("%s - %s\n", setup_titles[i], _(setup_titles[i]));
-               exit(0);
-       }
-#endif
+
+void cls(void) {
+       printf("\033[2J\033[H\033[44m\033[1m\033[K\n");
+       printf("  %s  \033[K\n", program_title);
+       printf("\033[K\n");
+       printf("\033[0m\n");
 }
 
 
 void title(const char *text) {
-       printf("\n\033[1m\033[32m<\033[33m%s\033[32m>\033[0m\n", text);
+       cls();
+       printf("\033[1m\033[32m<\033[33m%s\033[32m>\033[0m\n", text);
 }
 
 
@@ -253,7 +249,8 @@ int yesno(const char *question, int default_value) {
 void important_message(const char *title, const char *msgtext) {
        char buf[SIZ];
 
-       printf("\n%s\n%s\n\n", title, msgtext);
+       cls();
+       printf("%s\n%s\n\n", title, msgtext);
        printf("%s", _("Press return to continue..."));
        if (fgets(buf, sizeof buf, stdin)) {
                ;
@@ -285,6 +282,7 @@ void progress(char *text, long int curr, long int cmax) {
        long i = 0;
 
        if (curr == 0) {
+               cls();
                printf("%s\n", text);
                printf("\033[1m\033[33m[\033[32m............................................................................\033[33m]\033[0m\r");
        }
@@ -484,7 +482,7 @@ void check_xinetd_entry(void) {
        );
        fclose(fp);
 
-       // Now try to restart the service.  This will not have the intended effect on Solaris, but who uses Solaris anymore?
+       // Now try to restart the service.  (This only works on systemd; others will need to restart it manually.)
        rv = system("systemctl restart xinetd >/dev/null 2>&1");
        if (rv != 0) {
                rv = system("service xinetd restart >/dev/null 2>&1");
@@ -645,18 +643,21 @@ void edit_value(int curr) {
 
 // Messages that are no longer in use.
 // We keep them here so we don't lose the translations if we need them later.
-#if 0
-important_message(_("Setup finished"),
-_("Setup of the Citadel server is complete.\n"
-"If you will be using WebCit, please run its\n"
-"setup program now; otherwise, run './citadel'\n"
-"to log in.\n"));
-important_message(_("Setup failed"),
-_("Setup is finished, but the Citadel server failed to start.\n"
-"Go back and check your configuration.\n");
-important_message(_("Setup finished"),
-_("Setup is finished.  You may now start the server."));
-#endif
+void unused_messages(void) {
+       important_message(_("Setup finished"),
+               _("Setup of the Citadel server is complete.\n"
+               "If you will be using WebCit, please run its\n"
+               "setup program now; otherwise, run './citadel'\n"
+               "to log in.\n")
+       );
+       important_message(_("Setup failed"),
+               _("Setup is finished, but the Citadel server failed to start.\n"
+               "Go back and check your configuration.\n")
+       );
+       important_message(_("Setup finished"),
+               _("Setup is finished.  You may now start the server.")
+       );
+}
 
 
 int main(int argc, char *argv[]) {
@@ -670,7 +671,7 @@ int main(int argc, char *argv[]) {
        char *activity = NULL;
        
        // Keep a mild groove on
-       program_title = _("Citadel setup program");
+       program_title = _("Citadel Server setup");
 
        // set an invalid setup type
        setup_type = (-1);
@@ -730,9 +731,7 @@ int main(int argc, char *argv[]) {
        while (serv_gets(buf), strcmp(buf, "000")) {
                if (a == 5) {
                        if (atoi(buf) != REV_LEVEL) {
-                               display_error("%s\n",
-                               _("Your setup program and Citadel server are from different versions.")
-                               );
+                               display_error("%s\n", _("Your setup program and Citadel server are from different versions."));
                                exit(4);
                        }
                }
@@ -823,7 +822,7 @@ int main(int argc, char *argv[]) {
        long original_start_time = extract_long(&buf[4], 3);
 
        progress(activity, 1, 51);
-       serv_puts("DOWN 1");
+       serv_puts("DOWN");
        progress(activity, 2, 51);
        serv_gets(buf);
        if (buf[0] != '2') {