4 # Automatic script to install Citadel on a target system.
5 # Copyright (C) 2004 Michael Hampton <error@citadel.org>
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 # Reading this script? Here's some helpful hints:
23 # If you're seeing this in your browser, it's probably not what you want.
24 # You can either save it to disk and run it, or do it the easy way:
26 # wget -q -O - http://my.citadel.org/install | sh
28 # Note that this script installs software on your system and so it requires
29 # root privileges. Feel free to inspect the script to make sure I didn't
30 # do anything stupid...
32 # We have provided you the source code according to the terms of the respective
33 # software licenses included in the source code packages, even if you choose
34 # not to keep the source code around. You can always download it again later.
36 # We install the following versions in this release:
37 # Package Version Status
40 # libical 0.24.RC4 Latest
41 # Berkeley DB 4.1.25 + 2 patches Stable
42 # OpenLDAP 2.1.30 stable-20040329 Stable
45 ###############################################################################
47 # This is the general stuff we're going to do, in order:
49 # 1. Gather information about the target system
50 # A. Do we use the native packaging system or build our own copy of Citadel?
51 # B. If we build our own, are its prerequisites present and usable?
52 # 2. Present the installation steps (from 1 above) to the user
53 # 3. Present any pre-install customizations to the user
54 # 4. Do the installation
55 # A. Download any source code files or binary packages required
56 # B. For native packaging, call the native packaging system to install
57 # C. If we build our own, compile and install prerequisites then Citadel
58 # 5. Do post-installation setup
62 ###############################################################################
65 # Begin user customization area
67 # These two directories specify where Citadel and its private support
68 # libraries will be installed. This keeps them safely tucked away from
69 # the rest of your system. The defaults should be fine for most people.
70 # NB: When binary packages are installed, these settings are ignored!
71 SUPPORT=/usr/local/ctdlsupport
72 CITADEL=/usr/local/citadel
73 BUILD=/tmp/citadel-build.$$
74 export SUPPORT CITADEL
76 # Change the number of jobs to one plus the number of CPUs for best
77 # performance when compiling software.
80 # End user customization area
82 # We're now exporting a bunch of environment variables, and here's a list:
83 # CITADEL_INSTALLER Set to "web" to indicate this script
84 # CITADEL Directory where Citadel is installed
85 # SUPPORT Directory where support programs are installed
86 # LDAP_CONFIG Location of the slapd.conf file
87 # DISTRO_MAJOR Linux distribution name, if applicable
88 # DISTRO_MINOR Linux distribution name, if applicable
89 # DISTRO_VERSION Linux distribution version (major digit) if applicable
90 # CC C compiler being used
91 # MAKE Make program being used
92 # CFLAGS C compiler flags
93 # LDFLAGS Linker flags
95 # Let Citadel setup recognize the Citadel installer
97 export CITADEL_INSTALLER
99 DOWNLOAD_SITE=http://my.citadel.org/download
101 # Original source code packages.
102 CITADEL_SOURCE=citadel-6.24.tar.gz
103 WEBCIT_SOURCE=webcit-5.22.tar.gz
104 DB_SOURCE=db-4.1.25.tar.gz
105 DB_PATCHES=db-4.1.25.patches
106 ICAL_SOURCE=libical-0.24.RC4.tar.gz
107 LDAP_SOURCE=openldap-stable-20040329.tgz
109 # Binary RPM package names.
110 # DB and LDAP are assumed to come with the distro
111 CITADEL_RPM=citadel-client-6.23-1.i386.rpm
112 CITDATA_RPM=citadel-data-6.23-1.i386.rpm
113 CITSERVER_RPM=citadel-server-6.23-1.i386.rpm
114 WEBCIT_RPM=webcit-5.22-1.i386.rpm
115 ICAL_RPM=libical-0.24.RC4-1.i386.rpm
117 # Source RPMs used for this build.
118 # These are for your reference only; the script doesn't use them.
119 CITADEL_SRC_RPM=$DOWNLOAD_SITE/SRPMS/citadel-6.23-1.src.rpm
120 WEBCIT_SRC_RPM=$DOWNLOAD_SITE/SRPMS/webcit-5.22-1.src.rpm
121 ICAL_SRC_RPM=$DOWNLOAD_SITE/SRPMS/libical-0.24.RC4-1.src.rpm
123 SETUP="Citadel Easy Install"
126 CFLAGS="${CFLAGS} -I${SUPPORT}/include"
128 LDFLAGS="-l${SUPPORT}/lib -Wl,--rpath -Wl,${SUPPORT}/lib"
129 export CFLAGS CPPFLAGS LDFLAGS
131 ##### BEGIN Functions #####
134 echo Easy Install is aborting.
135 echo Please report this problem to the Citadel developers.
141 determine_distribution () {
142 # First look for Red Hat in general
143 if [ -x /bin/rpm ]; then
144 RELEASE_FILE=/dev/null
145 if /bin/rpm -q redhat-release >/dev/null 2>&1; then
147 RELEASE_FILE=/etc/redhat-release
149 if /bin/rpm -q whitebox-release >/dev/null 2>&1; then
150 DISTRO_MAJOR=WhiteBox
151 RELEASE_FILE=/etc/whitebox-release
153 if /bin/rpm -q fedora-release >/dev/null 2>&1; then
156 RELEASE_FILE=/etc/fedora-release
158 # Then look for specific version
159 ( cat $RELEASE_FILE | grep Enterprise ) >/dev/null 2>&1 && \
160 DISTRO_MINOR=Enterprise
161 DISTRO_VERSION=`tr -cd "[^0-9.]" < $RELEASE_FILE | cut -c 1`
165 if [ -f /etc/gentoo-release ]; then
170 # TODO: check for Debian
174 for path in $SUPPORT /usr/local/ctdlsupport /usr/local /usr
176 if [ -x $path/lib/libical.so.0.0.0 -a -f $path/include/ical.h ]
178 # Verify correct version
179 if grep "define ICAL_VERSION" $path/include/ical.h | grep "0.24" >/dev/null
184 echo "Warning: Wrong libical version found"
191 for path in $SUPPORT /usr/local/ctdlsupport /usr/local /usr
193 if [ -x $path/libexec/slapd -o -x $path/lib/openldap/slapd -o -x $path/sbin/slapd ]
195 if [ -f $path/lib/libldap.so.2 -a -f $path/include/ldap.h ]
204 find_berkeley_db () {
205 for path in $SUPPORT /usr/local/ctdlsupport /usr/local/BerkeleyDB.4.1.25 /usr
207 if [ -x $path/lib/libdb-4.1.so -a -f $path/include/db.h ]
215 show_prerequisites_to_install () {
230 download_prerequisite_sources () {
233 echo "* Downloading libical..."
234 wget -c $DOWNLOAD_SITE/$ICAL_SOURCE 2>&1 >>$LOG || die
238 echo "* Downloading Berkeley DB..."
239 wget -c $DOWNLOAD_SITE/$DB_SOURCE 2>&1 >>$LOG || die
240 #wget -c $DOWNLOAD_SITE/$DB_PATCHES 2>&1 >>$LOG || die
244 echo "* Downloading OpenLDAP..."
245 wget -c $DOWNLOAD_SITE/$LDAP_SOURCE 2>&1 >>$LOG || die
249 download_sources () {
250 echo "* Downloading Citadel..."
251 wget -c $DOWNLOAD_SITE/$CITADEL_SOURCE 2>&1 >>$LOG || die
252 echo "* Downloading WebCit..."
253 wget -c $DOWNLOAD_SITE/$WEBCIT_SOURCE 2>&1 >>$LOG || die
257 echo "* Installing libical..."
258 cd $BUILD 2>&1 >>$LOG || die
259 ( gzip -dc $ICAL_SOURCE | tar -xvf - ) 2>&1 >>$LOG || die
260 cd $BUILD/libical-0.24 2>&1 >>$LOG || die
261 ./configure --prefix=$SUPPORT 2>&1 >>$LOG || die
262 $MAKE $MAKEOPTS 2>&1 >>$LOG || die
263 $MAKE install 2>&1 >>$LOG || die
268 echo "* Installing Berkeley DB..."
269 cd $BUILD 2>&1 >>$LOG || die
270 ( gzip -dc $DB_SOURCE | tar -xvf - ) 2>&1 >>$LOG || die
271 cd $BUILD/db-4.1.25 2>&1 >>$LOG || die
272 #patch -p0 < ../$DB_PATCHES 2>&1 >>$LOG || die
273 cd $BUILD/db-4.1.25/build_unix 2>&1 >>$LOG || die
274 ../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
275 $MAKE $MAKEOPTS 2>&1 >>$LOG || die
276 $MAKE install 2>&1 >>$LOG || die
281 echo "* Installing OpenLDAP..."
282 cd $BUILD 2>&1 >>$LOG || die
283 ( gzip -dc $LDAP_SOURCE | tar -xvf - ) 2>&1 >>$LOG || die
284 cd $BUILD/openldap-2.1.29 2>&1 >>$LOG || die
285 ./configure --prefix=$SUPPORT --enable-crypt --enable-lmpasswd 2>&1 >>$LOG || die
286 $MAKE $MAKEOPTS 2>&1 >>$LOG || die
287 LDAP_CONFIG=$SUPPORT/etc/openldap/slapd.conf
289 $MAKE install 2>&1 >>$LOG || die
293 install_prerequisites () {
309 echo "* Installing Citadel..."
310 cd $BUILD 2>&1 >>$LOG || die
311 ( gzip -dc $CITADEL_SOURCE | tar -xvf - ) 2>&1 >>$LOG || die
312 cd $BUILD/citadel 2>&1 >>$LOG || die
315 ./configure --prefix=$CITADEL --with-db=$SUPPORT --with-pam --enable-autologin --with-ldap --with-libical --disable-threaded-client 2>&1 >>$LOG || die
317 ./configure --prefix=$CITADEL --with-db=$OK_DB --with-pam --enable-autologin --with-ldap --with-libical --disable-threaded-client 2>&1 >>$LOG || die
319 $MAKE $MAKEOPTS 2>&1 >>$LOG || die
320 if [ -f $CITADEL/citadel.config ]
322 $MAKE upgrade 2>&1 >>$LOG || die
325 $MAKE install 2>&1 >>$LOG || die
326 useradd -c Citadel -s /bin/false -r -d $CITADEL citadel 2>&1 >>$LOG || die
330 echo "* Installing WebCit..."
331 cd $BUILD 2>&1 >>$LOG || die
332 ( gzip -dc $WEBCIT_SOURCE | tar -xvf - ) 2>&1 >>$LOG || die
333 cd $BUILD/webcit 2>&1 >>$LOG || die
334 ./configure --prefix=$CITADEL --with-libical 2>&1 >>$LOG || die
335 $MAKE $MAKEOPTS 2>&1 >>$LOG || die
336 $MAKE install 2>&1 >>$LOG || die
340 ##### END Functions #####
342 ##### BEGIN main #####
344 # 1. Gather information about the target system
348 # 1A. Do we use the native packaging system or build our own copy of Citadel?
350 if [ "$os" = "Linux" ]; then
351 determine_distribution
352 elif [ "$os" = "FreeBSD" ]; then
353 # TODO: We detect FreeBSD but the port is still out of date...
357 # 1B. If we build our own, are its prerequisites present and usable?
359 if [ -z "$prepackaged" ]; then
365 # 2. Present the installation steps (from 1 above) to the user
367 echo "$SETUP will perform the following actions:"
369 echo "Configuration:"
370 echo "* Configure Citadel"
371 echo "* Configure WebCit"
375 if [ "$prepackaged" ]; then
376 show_packages_to_install
378 show_prerequisites_to_install
379 echo "* Install Citadel"
380 echo "* Install WebCit"
384 echo -n "Perform the above installation steps now? (yes) "
387 if [ "`echo $junk | cut -c 1 | tr N n`" = "n" ]; then
396 echo "Command output will not be sent to the terminal."
397 echo "To view progress, see the $LOG file."
400 # 3. Present any pre-install customizations to the user
402 # TODO: enter in the configuration dialogs
408 # 4. Do the installation
410 # 4A. Download any source code files or binary packages required
412 if [ "$prepackaged" ]; then
415 # 4B. For native packaging, call the native packaging system to install
420 # 4C. If we build our own, compile and install prerequisites then Citadel
422 download_prerequisite_sources
425 install_prerequisites
429 # 5. Do post-installation setup