* newinstall.sh: updated with some new goodies
authorArt Cancro <ajc@citadel.org>
Thu, 26 Aug 2004 04:13:56 +0000 (04:13 +0000)
committerArt Cancro <ajc@citadel.org>
Thu, 26 Aug 2004 04:13:56 +0000 (04:13 +0000)
* setup.c: when run from Easy Install, offer to set up LDAP.  (Not finished.)

citadel/ChangeLog
citadel/newinstall.sh
citadel/setup.c

index 8dba8ff97547c38e5ecba475e408292ef04a5545..77238c74f4c0d583bda4a7822a17b761b134e011 100644 (file)
@@ -1,4 +1,8 @@
  $Log$
+ Revision 624.7  2004/08/26 04:13:55  ajc
+ * newinstall.sh: updated with some new goodies
+ * setup.c: when run from Easy Install, offer to set up LDAP.  (Not finished.)
+
  Revision 624.6  2004/08/23 21:41:26  error
  * html.c: Try to something sane with lists
 
@@ -5990,3 +5994,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import
+
index 7e4e49b5971f1472dfe9e2ad94103803fe942a3d..66f3b3529bbe92912d9e088204d326853e3676f1 100644 (file)
@@ -3,6 +3,7 @@
 #
 #   Automatic script to install Citadel on a target system.
 #   Copyright (C) 2004 Michael Hampton <error@citadel.org>
+#   Copyright (C) 2004 Art Cancro <ajc@uncensored.citadel.org>
 #
 #   This program is free software; you can redistribute it and/or modify
 #   it under the terms of the GNU General Public License as published by
@@ -23,7 +24,7 @@
 # If you're seeing this in your browser, it's probably not what you want.
 # You can either save it to disk and run it, or do it the easy way:
 #
-# wget -q -O - http://my.citadel.org/install | sh
+# wget -q -O - http://easyinstall.citadel.org/install | sh
 #
 # Note that this script installs software on your system and so it requires
 # root privileges.  Feel free to inspect the script to make sure I didn't
@@ -84,6 +85,7 @@ MAKEOPTS="-j2"
 # WEBCIT               Directory where WebCit is installed
 # SUPPORT              Directory where support programs are installed
 # LDAP_CONFIG          Location of the slapd.conf file
+# SLAPD_BINARY         Location of the slapd binary
 # DISTRO_MAJOR         Linux distribution name, if applicable
 # DISTRO_MINOR         Linux distribution name, if applicable
 # DISTRO_VERSION       Linux distribution version (major digit) if applicable
@@ -97,7 +99,7 @@ MAKEOPTS="-j2"
 CITADEL_INSTALLER=web
 export CITADEL_INSTALLER
 
-DOWNLOAD_SITE=http://my.citadel.org/download
+DOWNLOAD_SITE=http://easyinstall.citadel.org
 
 # Original source code packages.
 DB_SOURCE=db-4.1.25.tar.gz
@@ -203,6 +205,8 @@ install_ldap () {
        $MAKE $MAKEOPTS 2>&1 >>$LOG || die
        LDAP_CONFIG=$SUPPORT/etc/openldap/slapd.conf
        export LDAP_CONFIG
+       SLAPD_BINARY=$SUPPORT/libexec/slapd
+       export SLAPD_BINARY
        $MAKE install 2>&1 >>$LOG || die
        echo "  Complete."
 }
@@ -332,7 +336,7 @@ fi
 echo ""
 echo -n "Perform the above installation steps now? (yes) "
 
-read junk
+read junk </dev/tty
 if [ "`echo $junk | cut -c 1 | tr N n`" = "n" ]; then
        exit 2
 fi
index 3488f065c2673fdf9fc37c528b5239774607d542..77af6c6d6e7f04bfa4f57f88d3aaf7e0d9f762cd 100644 (file)
@@ -46,6 +46,8 @@ char setup_directory[SIZ];
 char init_entry[SIZ];
 int using_web_installer = 0;
 
+void contemplate_ldap(void);
+
 char *setup_titles[] =
 {
        "Citadel Home Directory",
@@ -426,7 +428,7 @@ void check_inittab_entry(void)
        FILE *infp;
        char buf[SIZ];
        char looking_for[SIZ];
-       char question[128];
+       char question[SIZ];
        char entryname[5];
 
        /* Determine the fully qualified path name of citserver */
@@ -605,12 +607,7 @@ int test_server(void) {
        return(-1);
 }
 
-
-
-
-
-
-void set_str_val(int msgpos, char str[])
+void strprompt(char *prompt_title, char *prompt_text, char *str)
 {
 #ifdef HAVE_NEWT
        newtComponent form;
@@ -624,8 +621,8 @@ void set_str_val(int msgpos, char str[])
 
        switch (setup_type) {
        case UI_TEXT:
-               title(setup_titles[msgpos]);
-               printf("\n%s\n", setup_text[msgpos]);
+               title(prompt_title);
+               printf("\n%s\n", prompt_text);
                printf("This is currently set to:\n%s\n", str);
                printf("Enter new value or press return to leave unchanged:\n");
                fgets(buf, sizeof buf, stdin);
@@ -636,10 +633,10 @@ void set_str_val(int msgpos, char str[])
 #ifdef HAVE_NEWT
        case UI_NEWT:
 
-               newtCenteredWindow(76, 10, setup_titles[msgpos]);
+               newtCenteredWindow(76, 10, prompt_title);
                form = newtForm(NULL, NULL, 0);
-               for (i=0; i<num_tokens(setup_text[msgpos], '\n'); ++i) {
-                       extract_token(buf, setup_text[msgpos], i, '\n');
+               for (i=0; i<num_tokens(prompt_text, '\n'); ++i) {
+                       extract_token(buf, prompt_text, i, '\n');
                        newtFormAddComponent(form, newtLabel(1, 1+i, buf));
                }
                newtFormAddComponent(form, newtEntry(1, 8, str, 74, &result,
@@ -654,6 +651,12 @@ void set_str_val(int msgpos, char str[])
        }
 }
 
+void set_str_val(int msgpos, char *str) {
+       strprompt(setup_titles[msgpos], setup_text[msgpos], str);
+}
+
+
+
 void set_int_val(int msgpos, int *ip)
 {
        char buf[16];
@@ -1078,6 +1081,9 @@ NEW_INST:
        chmod("citadel.config", S_IRUSR | S_IWUSR);
        progress("Setting file permissions", 4, 4);
 
+       /* Contemplate the possibility of auto-configuring OpenLDAP */
+       contemplate_ldap();
+
        /* See if we can start the Citadel service. */
        if (strlen(init_entry) > 0) {
                for (a=0; a<=3; ++a) {
@@ -1104,3 +1110,57 @@ NEW_INST:
        cleanup(0);
        return 0;
 }
+
+
+/*
+ * If we're in the middle of an Easy Install, we might just be able to
+ * auto-configure a standalone OpenLDAP server.
+ */
+void contemplate_ldap(void) {
+       char question[SIZ];
+       char base_dn[SIZ];
+       FILE *fp;
+
+       /* If conditions are not ideal, give up on this idea. */
+       if (using_web_installer == 0) return;
+       if (getenv("LDAP_CONFIG") == NULL) return;
+       if (getenv("SLAPD_BINARY") == NULL) return;
+
+       /* Otherwise, prompt the user to create an entry. */
+       snprintf(question, sizeof question,
+               "\n"
+               "Do you want this computer configured to start a standalone\n"
+               "LDAP service automatically?  (If you answer yes, a custom\n"
+               "slapd.conf will be written, and an /etc/inittab entry\n"
+               "pointing to %s will be added.)\n"
+               "\n",
+               getenv("SLAPD_BINARY")
+       );
+       if (yesno(question) == 0)
+               return;
+
+       strcpy(base_dn, "dc=example,dc=com");
+       strprompt("Base DN",
+               "\n"
+               "Please enter the Base DN for your directory.  This will\n"
+               "generally be something based on the primary DNS domain in\n"
+               "which you receive mail, but it doesn't have to be.  Your\n"
+               "LDAP tree will be built using this Distinguished Name.\n"
+               "\n",
+               base_dn
+       );
+
+       fp = fopen(getenv("LDAP_CONFIG"), "w");
+       if (fp == NULL) {
+               sprintf(question, "\nCannot create %s:\n%s\n\n"
+                               "Citadel will still function, but you will "
+                               "not have an LDAP service.\n\n",
+                               getenv("LDAP_CONFIG"),
+                               strerror(errno)
+               );
+               important_message("Error", question);
+               return;
+       }
+       fprintf(fp, "FIXME\n");
+       fclose(fp);
+}