#
# 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
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
+# the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# 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
+# curl 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
+# root privileges. Feel free to inspect the script to make sure we didn't
# do anything stupid...
#
# We have provided you the source code according to the terms of the respective
# not to keep the source code around. You can always download it again later.
#
# We install the following versions in this release:
-# Package Version Status
-# Citadel 6.24 Latest
-# WebCit 5.22 Latest
-# libical 0.24.RC4 Latest
-# Berkeley DB 4.1.25 + 2 patches Stable
-# OpenLDAP 2.1.30 stable-20040329 Stable
+# Package Status
+# Citadel Latest
+# WebCit Latest
+# libical Latest
+# Berkeley DB Stable
+# libSieve Stable
###############################################################################
# This is the general stuff we're going to do, in order:
#
# 1. Gather information about the target system
-# A. Do we use the native packaging system or build our own copy of Citadel?
-# B. If we build our own, are its prerequisites present and usable?
# 2. Present the installation steps (from 1 above) to the user
# 3. Present any pre-install customizations to the user
# 4. Do the installation
# NB: When binary packages are installed, these settings are ignored!
SUPPORT=/usr/local/ctdlsupport
CITADEL=/usr/local/citadel
-BUILD=/tmp/citadel-build.$$
-export SUPPORT CITADEL
+WEBCIT=/usr/local/webcit
+WORKDIR=/tmp
+BUILD=$WORKDIR/citadel-build.$$
+LOG=$WORKDIR/citadel-install-log.txt
+export SUPPORT CITADEL WEBCIT
-# Change the number of jobs to one plus the number of CPUs for best
-# performance when compiling software.
-MAKEOPTS="-j2"
+MAKEOPTS=""
# End user customization area
# We're now exporting a bunch of environment variables, and here's a list:
# CITADEL_INSTALLER Set to "web" to indicate this script
# CITADEL Directory where Citadel is installed
+# WEBCIT Directory where WebCit is installed
# SUPPORT Directory where support programs are installed
-# LDAP_CONFIG Location of the slapd.conf file
# DISTRO_MAJOR Linux distribution name, if applicable
# DISTRO_MINOR Linux distribution name, if applicable
# DISTRO_VERSION Linux distribution version (major digit) if applicable
# MAKE Make program being used
# CFLAGS C compiler flags
# LDFLAGS Linker flags
+# IS_UPGRADE Set to "yes" if upgrading an existing Citadel
+# CTDL_DIALOG Where (if at all) the "dialog" program may be found
# Let Citadel setup recognize the Citadel installer
CITADEL_INSTALLER=web
export CITADEL_INSTALLER
-DOWNLOAD_SITE=http://my.citadel.org/download
+DOWNLOAD_SITE=http://easyinstall.citadel.org
# Original source code packages.
-CITADEL_SOURCE=citadel-6.24.tar.gz
-WEBCIT_SOURCE=webcit-5.22.tar.gz
-DB_SOURCE=db-4.1.25.tar.gz
-DB_PATCHES=db-4.1.25.patches
-ICAL_SOURCE=libical-0.24.RC4.tar.gz
-LDAP_SOURCE=openldap-stable-20040329.tgz
-
-# Binary RPM package names.
-# DB and LDAP are assumed to come with the distro
-CITADEL_RPM=citadel-client-6.23-1.i386.rpm
-CITDATA_RPM=citadel-data-6.23-1.i386.rpm
-CITSERVER_RPM=citadel-server-6.23-1.i386.rpm
-WEBCIT_RPM=webcit-5.22-1.i386.rpm
-ICAL_RPM=libical-0.24.RC4-1.i386.rpm
-
-# Source RPMs used for this build.
-# These are for your reference only; the script doesn't use them.
-CITADEL_SRC_RPM=$DOWNLOAD_SITE/SRPMS/citadel-6.23-1.src.rpm
-WEBCIT_SRC_RPM=$DOWNLOAD_SITE/SRPMS/webcit-5.22-1.src.rpm
-ICAL_SRC_RPM=$DOWNLOAD_SITE/SRPMS/libical-0.24.RC4-1.src.rpm
+DB_SOURCE=db-4.3.29.NC.tar.gz
+# DB_PATCHES=db-x.x.x.patches
+ICAL_SOURCE=libical-0.26-6.aurore.tar.gz
+LIBSIEVE_SOURCE=libsieve-2.2.3.tar.gz
+CITADEL_SOURCE=citadel-easyinstall.tar.gz
+WEBCIT_SOURCE=webcit-easyinstall.tar.gz
SETUP="Citadel Easy Install"
-LOG=$BUILD/log.txt
-CFLAGS="${CFLAGS} -I${SUPPORT}/include"
-CPPFLAGS="${CFLAGS}"
-LDFLAGS="-l${SUPPORT}/lib -Wl,--rpath -Wl,${SUPPORT}/lib"
-export CFLAGS CPPFLAGS LDFLAGS
##### BEGIN Functions #####
+die () {
+ echo Easy Install is aborting.
+ echo Please report this problem to the Citadel developers.
+ echo Log file: $LOG
+ rm -fr $BUILD
+ exit 1
+}
+
+
+download_this () {
+ WGET=`which wget 2>/dev/null`
+ CURL=`which curl 2>/dev/null`
+ if [ -n "${WGET}" -a -x "${WGET}" ]; then
+ $WGET $DOWNLOAD_SITE/$FILENAME >/dev/null 2>>$LOG || die
+ else
+ if [ -n "${CURL}" -a -x "${CURL}" ]; then
+ $CURL $DOWNLOAD_SITE/$FILENAME >$FILENAME 2>>$LOG || die
+ else
+ echo Unable to find a wget or curl command.
+ echo Easy Install cannot continue.
+ die;
+ fi
+ fi
+}
+
+
+
determine_distribution () {
# First look for Red Hat in general
if [ -x /bin/rpm ]; then
# TODO: check for Debian
}
-find_libical () {
- for path in $SUPPORT /usr/local/ctdlsupport /usr/local /usr
- do
- if [ -x $path/lib/libical.so.0.0.0 -a -f $path/include/ical.h ]
- then
- # Verify correct version
- if grep "define ICAL_VERSION" $path/include/ical.h | grep "0.24" >/dev/null
- then
- OK_ICAL=$path
- return
- else
- echo "Warning: Wrong libical version found"
- fi
- fi
- done
-}
-
-find_openldap () {
- for path in $SUPPORT /usr/local/ctdlsupport /usr/local /usr
- do
- if [ -x $path/libexec/slapd -o -x $path/lib/openldap/slapd -o -x $path/sbin/slapd ]
- then
- if [ -f $path/lib/libldap.so.2 -a -f $path/include/ldap.h ]
- then
- OK_LDAP=$path
- return
- fi
- fi
- done
-}
-
-find_berkeley_db () {
- for path in $SUPPORT /usr/local/ctdlsupport /usr/local/BerkeleyDB.4.1.25 /usr
- do
- if [ -x $path/lib/libdb-4.1.so -a -f $path/include/db.h ]
- then
- OK_DB=$path
+install_ical () {
+ cd $BUILD 2>&1 >>$LOG || die
+ FILENAME=libical-easyinstall.sum ; download_this
+ SUM=`cat libical-easyinstall.sum`
+ SUMFILE=$SUPPORT/etc/libical-easyinstall.sum
+ if [ -r $SUMFILE ] ; then
+ OLDSUM=`cat $SUMFILE`
+ if [ $SUM = $OLDSUM ] ; then
+ echo "* libical does not need updating."
return
fi
- done
-}
-
-show_prerequisites_to_install () {
- if [ -z "$OK_ICAL" ]
- then
- echo "* libical"
- fi
- if [ -z "$OK_DB" ]
- then
- echo "* Berkeley DB"
- fi
- if [ -z "$OK_LDAP" ]
- then
- echo "* OpenLDAP"
- fi
-}
-
-download_prerequisite_sources () {
- if [ -z "$OK_ICAL" ]
- then
- echo "* Downloading libical..."
- wget -c $DOWNLOAD_SITE/$ICAL_SOURCE 2>&1 >>$LOG || die
- fi
- if [ -z "$OK_DB" ]
- then
- echo "* Downloading Berkeley DB..."
- wget -c $DOWNLOAD_SITE/$DB_SOURCE 2>&1 >>$LOG || die
- wget -c $DOWNLOAD_SITE/$DB_PATCHES 2>&1 >>$LOG || die
fi
- if [ -z "$OK_LDAP" ]
- then
- echo "* Downloading OpenLDAP..."
- wget -c $DOWNLOAD_SITE/$LDAP_SOURCE 2>&1 >>$LOG || die
- fi
-}
-
-download_sources () {
- echo "* Downloading Citadel..."
- wget -c $DOWNLOAD_SITE/$CITADEL_SOURCE 2>&1 >>$LOG || die
- echo "* Downloading WebCit..."
- wget -c $DOWNLOAD_SITE/$WEBCIT_SOURCE 2>&1 >>$LOG || die
-}
-
-install_ical () {
+ echo "* Downloading libical..."
+ FILENAME=$ICAL_SOURCE ; download_this
echo "* Installing libical..."
- cd $BUILD 2>&1 >>$LOG || die
- ( gzip -dc $ICAL_SOURCE | tar -xvf - ) 2>&1 >>$LOG || die
- cd $BUILD/libical-0.24 2>&1 >>$LOG || die
+ ( gzip -dc $ICAL_SOURCE | tar -xf - ) 2>&1 >>$LOG || die
+ cd $BUILD/libical-0.26 2>&1 >>$LOG || die
./configure --prefix=$SUPPORT 2>&1 >>$LOG || die
$MAKE $MAKEOPTS 2>&1 >>$LOG || die
$MAKE install 2>&1 >>$LOG || die
echo " Complete."
+ echo $SUM >$SUMFILE
+ rm -f $CITADEL/citadel-easyinstall.sum 2>/dev/null
+ rm -f $WEBCIT/webcit-easyinstall.sum 2>/dev/null
}
-install_db () {
- echo "* Installing Berkeley DB..."
+install_libsieve () {
cd $BUILD 2>&1 >>$LOG || die
- ( gzip -dc $DB_SOURCE | tar -xvf - ) 2>&1 >>$LOG || die
- cd $BUILD/db-4.1.25 2>&1 >>$LOG || die
- patch -p0 < ../$DB_PATCHES 2>&1 >>$LOG || die
- cd $BUILD/db-4.1.25/build_unix 2>&1 >>$LOG || die
- ../dist/configure --prefix=$SUPPORT --disable-compat185 --disable-cxx --disable-debug --disable-dump185 --disable-java --disable-rpc --disable-tcl --disable-test --without-rpm 2>&1 >>$LOG || die
+ FILENAME=libsieve-easyinstall.sum ; download_this
+ SUM=`cat libsieve-easyinstall.sum`
+ SUMFILE=$SUPPORT/etc/libsieve-easyinstall.sum
+ if [ -r $SUMFILE ] ; then
+ OLDSUM=`cat $SUMFILE`
+ if [ $SUM = $OLDSUM ] ; then
+ echo "* libsieve does not need updating."
+ return
+ fi
+ fi
+ echo "* Downloading libsieve..."
+ FILENAME=$LIBSIEVE_SOURCE ; download_this
+ echo "* Installing libsieve..."
+ ( gzip -dc $LIBSIEVE_SOURCE | tar -xf - ) 2>&1 >>$LOG || die
+ cd $BUILD/libsieve-2.2.3/src 2>&1 >>$LOG || die
+ ./configure --prefix=$SUPPORT 2>&1 >>$LOG || die
$MAKE $MAKEOPTS 2>&1 >>$LOG || die
$MAKE install 2>&1 >>$LOG || die
echo " Complete."
+ echo $SUM >$SUMFILE
+ rm -f $CITADEL/citadel-easyinstall.sum 2>/dev/null
}
-install_ldap () {
- echo "* Installing OpenLDAP..."
+install_db () {
cd $BUILD 2>&1 >>$LOG || die
- ( gzip -dc $LDAP_SOURCE | tar -xvf - ) 2>&1 >>$LOG || die
- cd $BUILD/openldap-2.1.29 2>&1 >>$LOG || die
- ./configure --prefix=$SUPPORT --enable-crypt --enable-lmpasswd 2>&1 >>$LOG || die
+ FILENAME=db-easyinstall.sum ; download_this
+ SUM=`cat db-easyinstall.sum`
+ SUMFILE=$SUPPORT/etc/db-easyinstall.sum
+ if [ -r $SUMFILE ] ; then
+ OLDSUM=`cat $SUMFILE`
+ if [ $SUM = $OLDSUM ] ; then
+ echo "* Berkeley DB does not need updating."
+ return
+ fi
+ fi
+ echo "* Downloading Berkeley DB..."
+ FILENAME=$DB_SOURCE ; download_this
+ echo "* Installing Berkeley DB..."
+ ( gzip -dc $DB_SOURCE | tar -xf - ) 2>&1 >>$LOG || die
+ cd $BUILD/db-4.3.29.NC 2>&1 >>$LOG || die
+ #patch -p0 < ../$DB_PATCHES 2>&1 >>$LOG || die
+ cd $BUILD/db-4.3.29.NC/build_unix 2>&1 >>$LOG || die
+ ../dist/configure --prefix=$SUPPORT --disable-compat185 --disable-cxx --disable-debug --disable-dump185 --disable-java --disable-rpc --disable-tcl --disable-test --without-rpm 2>&1 >>$LOG || die
$MAKE $MAKEOPTS 2>&1 >>$LOG || die
- LDAP_CONFIG=$SUPPORT/etc/openldap/slapd.conf
- export LDAP_CONFIG
$MAKE install 2>&1 >>$LOG || die
echo " Complete."
+ echo $SUM >$SUMFILE
+ rm -f $CITADEL/citadel-easyinstall.sum 2>/dev/null
}
install_prerequisites () {
+
+ # Create the support directories if they don't already exist
+
+ mkdir $SUPPORT 2>/dev/null
+ mkdir $SUPPORT/bin 2>/dev/null
+ mkdir $SUPPORT/sbin 2>/dev/null
+ mkdir $SUPPORT/lib 2>/dev/null
+ mkdir $SUPPORT/libexec 2>/dev/null
+ mkdir $SUPPORT/include 2>/dev/null
+ mkdir $SUPPORT/etc 2>/dev/null
+
+ # Now have phun!
+
if [ -z "$OK_ICAL" ]
then
install_ical
fi
- if [ -z "$OK_DB" ]
+ if [ -z "$OK_LIBSIEVE" ]
then
- install_db
+ install_libsieve
fi
- if [ -z "$OK_LDAP" ]
+ if [ -z "$OK_DB" ]
then
- install_ldap
+ install_db
fi
}
install_sources () {
- echo "* Installing Citadel..."
cd $BUILD 2>&1 >>$LOG || die
- ( gzip -dc $CITADEL_SOURCE | tar -xvf - ) 2>&1 >>$LOG || die
- cd $BUILD/citadel 2>&1 >>$LOG || die
- if [ -z "$OK_DB" ]
- then
- ./configure --prefix=$CITADEL --with-db=$SUPPORT --with-pam --enable-autologin --with-ldap --with-libical --disable-threaded-client 2>&1 >>$LOG || die
- else
- ./configure --prefix=$CITADEL --with-db=$OK_DB --with-pam --enable-autologin --with-ldap --with-libical --disable-threaded-client 2>&1 >>$LOG || die
- fi
- $MAKE $MAKEOPTS 2>&1 >>$LOG || die
if [ -f $CITADEL/citadel.config ]
then
- $MAKE upgrade 2>&1 >>$LOG || die
- $CITADEL/setup -q
+ IS_UPGRADE=yes
+ echo "* Upgrading your existing Citadel installation."
else
- $MAKE install 2>&1 >>$LOG || die
- useradd -c Citadel -s /bin/false -r -d $CITADEL citadel 2>&1 >>$LOG || die
- $CITADEL/setup
+ IS_UPGRADE=no
+ fi
+
+ CFLAGS="-I${SUPPORT}/include"
+ CPPFLAGS="${CFLAGS}"
+ LDFLAGS="-L${SUPPORT}/lib -Wl,--rpath -Wl,${SUPPORT}/lib"
+ export CFLAGS CPPFLAGS LDFLAGS
+
+ DO_INSTALL_CITADEL=yes
+ FILENAME=citadel-easyinstall.sum ; download_this
+ SUM=`cat citadel-easyinstall.sum`
+ SUMFILE=$CITADEL/citadel-easyinstall.sum
+ if [ -r $SUMFILE ] ; then
+ OLDSUM=`cat $SUMFILE`
+ if [ $SUM = $OLDSUM ] ; then
+ echo "* Citadel does not need updating."
+ DO_INSTALL_CITADEL=no
+ fi
+ fi
+
+ if [ $DO_INSTALL_CITADEL = yes ] ; then
+ echo "* Downloading Citadel..."
+ FILENAME=$CITADEL_SOURCE ; download_this
+ echo "* Installing Citadel..."
+ cd $BUILD 2>&1 >>$LOG || die
+ ( gzip -dc $CITADEL_SOURCE | tar -xf - ) 2>&1 >>$LOG || die
+ cd $BUILD/citadel 2>&1 >>$LOG || die
+ if [ -z "$OK_DB" ]
+ then
+ ./configure --prefix=$CITADEL --with-db=$SUPPORT --with-pam --with-libical --disable-threaded-client 2>&1 >>$LOG || die
+ else
+ ./configure --prefix=$CITADEL --with-db=$OK_DB --with-pam --with-libical --disable-threaded-client 2>&1 >>$LOG || die
+ fi
+ $MAKE $MAKEOPTS 2>&1 >>$LOG || die
+ if [ $IS_UPGRADE = yes ]
+ then
+ echo "* Performing Citadel upgrade..."
+ $MAKE upgrade 2>&1 >>$LOG || die
+ else
+ echo "* Performing Citadel install..."
+ $MAKE install 2>&1 >>$LOG || die
+ useradd -c "Citadel service account" -d $CITADEL -s $CITADEL/citadel citadel 2>&1 >>$LOG
+ fi
+ echo $SUM >$SUMFILE
fi
- echo "* Installing WebCit..."
cd $BUILD 2>&1 >>$LOG || die
- ( gzip -dc $WEBCIT_SOURCE | tar -xvf - ) 2>&1 >>$LOG || die
- cd $BUILD/webcit 2>&1 >>$LOG || die
- ./configure --prefix=$CITADEL --with-libical 2>&1 >>$LOG || die
- $MAKE $MAKEOPTS 2>&1 >>$LOG || die
- $MAKE install 2>&1 >>$LOG || die
- echo " Complete."
+ DO_INSTALL_WEBCIT=yes
+ FILENAME=webcit-easyinstall.sum ; download_this
+ SUM=`cat webcit-easyinstall.sum`
+ SUMFILE=$WEBCIT/webcit-easyinstall.sum
+ if [ -r $SUMFILE ] ; then
+ OLDSUM=`cat $SUMFILE`
+ if [ $SUM = $OLDSUM ] ; then
+ echo "* WebCit does not need updating."
+ DO_INSTALL_WEBCIT=no
+ fi
+ fi
+
+ if [ $DO_INSTALL_WEBCIT = yes ] ; then
+ echo "* Downloading WebCit..."
+ FILENAME=$WEBCIT_SOURCE ; download_this
+ echo "* Installing WebCit..."
+ cd $BUILD 2>&1 >>$LOG || die
+ ( gzip -dc $WEBCIT_SOURCE | tar -xf - ) 2>&1 >>$LOG || die
+ cd $BUILD/webcit 2>&1 >>$LOG || die
+ ./configure --prefix=$WEBCIT --with-libical 2>&1 >>$LOG || die
+ $MAKE $MAKEOPTS 2>&1 >>$LOG || die
+ $MAKE install 2>&1 >>$LOG || die
+ echo " Complete."
+ echo $SUM >$SUMFILE
+ fi
+}
+
+
+do_config () {
+ echo "* Configuring your system ..."
+
+ if [ x$IS_UPGRADE == xyes ] ; then
+ echo Upgrading your existing Citadel installation.
+ $CITADEL/setup </dev/tty || die
+ else
+ echo This is a new Citadel installation.
+ $CITADEL/setup </dev/tty || die
+ fi
+
+ $WEBCIT/setup </dev/tty || die
}
+
+
##### END Functions #####
##### BEGIN main #####
# 1. Gather information about the target system
+# Non-GNU make does not work.
+# This probably ought to be fixed, but for now we will simply require GNU make.
+
+MAKE=xx
+if gmake -v 2>&1 | grep -i GNU ; then
+ MAKE=`which gmake`
+else
+ if make -v 2>&1 | grep -i GNU ; then
+ MAKE=`which make`
+ fi
+fi
+
+if [ $MAKE == xx ] ; then
+ echo
+ echo 'Easy Install requires GNU Make (gmake), which was not found.'
+ echo 'Please install gmake and try again.'
+ echo
+ exit 1
+fi
+
+export MAKE
+
+clear
+
os=`uname`
+
+echo MAKE is $MAKE
+export MAKE
+
# 1A. Do we use the native packaging system or build our own copy of Citadel?
if [ "$os" = "Linux" ]; then
elif [ "$os" = "FreeBSD" ]; then
# TODO: We detect FreeBSD but the port is still out of date...
DISTRO_MAJOR=FreeBSD
+elif [ "$os" = "Darwin" ]; then
+ # TODO: Deal with Apple weirdness
+ DISTRO_MAJOR=Darwin
fi
-# 1B. If we build our own, are its prerequisites present and usable?
-if [ -z "$prepackaged" ]; then
- find_libical
- find_openldap
- find_berkeley_db
-fi
+rm -rf $BUILD
+mkdir -p $BUILD
+cd $BUILD
+
+
# 2. Present the installation steps (from 1 above) to the user
+clear
+if dialog 2>&1 </dev/tty | grep gauge >/dev/null 2>&1 ; then
+ CTDL_DIALOG=`which dialog`
+ export CTDL_DIALOG
+elif cdialog 2>&1 </dev/tty | grep gauge >/dev/null 2>&1 ; then
+ CTDL_DIALOG=`which cdialog`
+ export CTDL_DIALOG
+fi
+clear
echo "$SETUP will perform the following actions:"
echo ""
+echo "Installation:"
+echo "* Download/install supporting libraries (if needed)"
+echo "* Download/install Citadel (if needed)"
+echo "* Download/install WebCit (if needed)"
+echo ""
echo "Configuration:"
echo "* Configure Citadel"
echo "* Configure WebCit"
echo ""
-echo "Installation:"
-
-if [ "$prepackaged" ]; then
- show_packages_to_install
-else
- show_prerequisites_to_install
- echo "* Install Citadel"
- echo "* Install WebCit"
-fi
-
-echo ""
-echo -n "Perform the above installation steps now? (yes) "
+echo -n "Perform the above installation steps now? "
+read yesno </dev/tty
-read junk
-if [ "`echo $junk | cut -c 1 | tr N n`" = "n" ]; then
+if [ "`echo $yesno | cut -c 1 | tr N n`" = "n" ]; then
exit 2
fi
-rm -rf $BUILD
-mkdir -p $BUILD
-cd $BUILD
-
echo ""
echo "Command output will not be sent to the terminal."
echo "To view progress, see the $LOG file."
# 4C. If we build our own, compile and install prerequisites then Citadel
- download_prerequisite_sources
- download_sources
-
install_prerequisites
install_sources
fi
# 5. Do post-installation setup
-
+ rm -fr $BUILD
+ do_config
##### END main #####