#
# 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
# 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
# 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
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
$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."
}
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
char init_entry[SIZ];
int using_web_installer = 0;
+void contemplate_ldap(void);
+
char *setup_titles[] =
{
"Citadel Home Directory",
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 */
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;
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);
#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,
}
}
+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];
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) {
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);
+}