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 # 2. Present the installation steps (from 1 above) to the user
51 # 3. Present any pre-install customizations to the user
52 # 4. Do the installation
53 # A. Download any source code files or binary packages required
54 # B. For native packaging, call the native packaging system to install
55 # C. If we build our own, compile and install prerequisites then Citadel
56 # 5. Do post-installation setup
60 ###############################################################################
63 # Begin user customization area
65 # These two directories specify where Citadel and its private support
66 # libraries will be installed. This keeps them safely tucked away from
67 # the rest of your system. The defaults should be fine for most people.
68 # NB: When binary packages are installed, these settings are ignored!
69 SUPPORT=/usr/local/ctdlsupport
70 CITADEL=/usr/local/citadel
71 WEBCIT=/usr/local/webcit
72 BUILD=/tmp/citadel-build.$$
73 export SUPPORT CITADEL WEBCIT
75 # Change the number of jobs to one plus the number of CPUs for best
76 # performance when compiling software.
79 # End user customization area
81 # We're now exporting a bunch of environment variables, and here's a list:
82 # CITADEL_INSTALLER Set to "web" to indicate this script
83 # CITADEL Directory where Citadel is installed
84 # SUPPORT Directory where support programs are installed
85 # LDAP_CONFIG Location of the slapd.conf file
86 # DISTRO_MAJOR Linux distribution name, if applicable
87 # DISTRO_MINOR Linux distribution name, if applicable
88 # DISTRO_VERSION Linux distribution version (major digit) if applicable
89 # CC C compiler being used
90 # MAKE Make program being used
91 # CFLAGS C compiler flags
92 # LDFLAGS Linker flags
94 # Let Citadel setup recognize the Citadel installer
96 export CITADEL_INSTALLER
98 DOWNLOAD_SITE=http://my.citadel.org/download
100 # Original source code packages.
101 DB_SOURCE=db-4.1.25.tar.gz
102 DB_PATCHES=db-4.1.25.patches
103 ICAL_SOURCE=libical-0.24.RC4.tar.gz
104 LDAP_SOURCE=openldap-stable-20040329.tgz
105 CITADEL_SOURCE=citadel-6.24.tar.gz
106 WEBCIT_SOURCE=webcit-5.22.tar.gz
108 SETUP="Citadel Easy Install"
112 ##### BEGIN Functions #####
115 echo Easy Install is aborting.
116 echo Please report this problem to the Citadel developers.
122 determine_distribution () {
123 # First look for Red Hat in general
124 if [ -x /bin/rpm ]; then
125 RELEASE_FILE=/dev/null
126 if /bin/rpm -q redhat-release >/dev/null 2>&1; then
128 RELEASE_FILE=/etc/redhat-release
130 if /bin/rpm -q whitebox-release >/dev/null 2>&1; then
131 DISTRO_MAJOR=WhiteBox
132 RELEASE_FILE=/etc/whitebox-release
134 if /bin/rpm -q fedora-release >/dev/null 2>&1; then
137 RELEASE_FILE=/etc/fedora-release
139 # Then look for specific version
140 ( cat $RELEASE_FILE | grep Enterprise ) >/dev/null 2>&1 && \
141 DISTRO_MINOR=Enterprise
142 DISTRO_VERSION=`tr -cd "[^0-9.]" < $RELEASE_FILE | cut -c 1`
146 if [ -f /etc/gentoo-release ]; then
151 # TODO: check for Debian
154 download_sources () {
155 echo "* Downloading Berkeley DB..."
156 wget -c $DOWNLOAD_SITE/$DB_SOURCE 2>&1 >>$LOG || die
157 echo "* Downloading libical..."
158 wget -c $DOWNLOAD_SITE/$ICAL_SOURCE 2>&1 >>$LOG || die
159 echo "* Downloading OpenLDAP..."
160 wget -c $DOWNLOAD_SITE/$LDAP_SOURCE 2>&1 >>$LOG || die
161 echo "* Downloading Citadel..."
162 wget -c $DOWNLOAD_SITE/$CITADEL_SOURCE 2>&1 >>$LOG || die
163 echo "* Downloading WebCit..."
164 wget -c $DOWNLOAD_SITE/$WEBCIT_SOURCE 2>&1 >>$LOG || die
168 echo "* Installing libical..."
169 cd $BUILD 2>&1 >>$LOG || die
170 ( gzip -dc $ICAL_SOURCE | tar -xvf - ) 2>&1 >>$LOG || die
171 cd $BUILD/libical-0.24 2>&1 >>$LOG || die
172 ./configure --prefix=$SUPPORT 2>&1 >>$LOG || die
173 $MAKE $MAKEOPTS 2>&1 >>$LOG || die
174 $MAKE install 2>&1 >>$LOG || die
179 echo "* Installing Berkeley DB..."
180 cd $BUILD 2>&1 >>$LOG || die
181 ( gzip -dc $DB_SOURCE | tar -xvf - ) 2>&1 >>$LOG || die
182 cd $BUILD/db-4.1.25 2>&1 >>$LOG || die
183 #patch -p0 < ../$DB_PATCHES 2>&1 >>$LOG || die
184 cd $BUILD/db-4.1.25/build_unix 2>&1 >>$LOG || die
185 ../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
186 $MAKE $MAKEOPTS 2>&1 >>$LOG || die
187 $MAKE install 2>&1 >>$LOG || die
192 echo "* Installing OpenLDAP..."
193 CFLAGS="${CFLAGS} -I${SUPPORT}/include"
195 LDFLAGS="-L${SUPPORT}/lib -Wl,--rpath -Wl,${SUPPORT}/lib"
196 export CFLAGS CPPFLAGS LDFLAGS
197 cd $BUILD 2>&1 >>$LOG || die
198 ( gzip -dc $LDAP_SOURCE | tar -xvf - ) 2>&1 >>$LOG || die
199 cd $BUILD/openldap-2.1.29 2>&1 >>$LOG || die
200 ./configure --prefix=$SUPPORT --enable-bdb 2>&1 >>$LOG || die
201 $MAKE $MAKEOPTS 2>&1 >>$LOG || die
202 LDAP_CONFIG=$SUPPORT/etc/openldap/slapd.conf
204 $MAKE install 2>&1 >>$LOG || die
208 install_prerequisites () {
210 # Create the support directories if they don't already exist
212 mkdir $SUPPORT 2>/dev/null
213 mkdir $SUPPORT/bin 2>/dev/null
214 mkdir $SUPPORT/sbin 2>/dev/null
215 mkdir $SUPPORT/lib 2>/dev/null
216 mkdir $SUPPORT/libexec 2>/dev/null
217 mkdir $SUPPORT/include 2>/dev/null
218 mkdir $SUPPORT/etc 2>/dev/null
237 echo "* Installing Citadel..."
239 CFLAGS="${CFLAGS} -I${SUPPORT}/include"
241 LDFLAGS="-L${SUPPORT}/lib -Wl,--rpath -Wl,${SUPPORT}/lib"
242 export CFLAGS CPPFLAGS LDFLAGS
244 cd $BUILD 2>&1 >>$LOG || die
245 ( gzip -dc $CITADEL_SOURCE | tar -xvf - ) 2>&1 >>$LOG || die
246 cd $BUILD/citadel 2>&1 >>$LOG || die
249 ./configure --prefix=$CITADEL --with-db=$SUPPORT --with-pam --enable-autologin --with-ldap --with-libical --disable-threaded-client 2>&1 >>$LOG || die
251 ./configure --prefix=$CITADEL --with-db=$OK_DB --with-pam --enable-autologin --with-ldap --with-libical --disable-threaded-client 2>&1 >>$LOG || die
253 $MAKE $MAKEOPTS 2>&1 >>$LOG || die
254 if [ -f $CITADEL/citadel.config ]
256 $MAKE upgrade 2>&1 >>$LOG || die
259 $MAKE install 2>&1 >>$LOG || die
260 useradd -c Citadel -s /bin/false -r -d $CITADEL citadel 2>&1 >>$LOG || die
264 echo "* Installing WebCit..."
265 cd $BUILD 2>&1 >>$LOG || die
266 ( gzip -dc $WEBCIT_SOURCE | tar -xvf - ) 2>&1 >>$LOG || die
267 cd $BUILD/webcit 2>&1 >>$LOG || die
268 ./configure --prefix=$WEBCIT --with-libical 2>&1 >>$LOG || die
269 $MAKE $MAKEOPTS 2>&1 >>$LOG || die
270 $MAKE install 2>&1 >>$LOG || die
274 ##### END Functions #####
276 ##### BEGIN main #####
278 # 1. Gather information about the target system
280 [ x$MAKE == x ] && MAKE=`which gmake`
281 [ x$MAKE == x ] && MAKE=`which make`
286 # 1A. Do we use the native packaging system or build our own copy of Citadel?
288 if [ "$os" = "Linux" ]; then
289 determine_distribution
290 elif [ "$os" = "FreeBSD" ]; then
291 # TODO: We detect FreeBSD but the port is still out of date...
295 # 2. Present the installation steps (from 1 above) to the user
297 echo "$SETUP will perform the following actions:"
299 echo "Configuration:"
300 echo "* Configure Citadel"
301 echo "* Configure WebCit"
305 if [ "$prepackaged" ]; then
306 show_packages_to_install
308 echo "* Install supporting libraries"
309 echo "* Install Citadel"
310 echo "* Install WebCit"
314 echo -n "Perform the above installation steps now? (yes) "
317 if [ "`echo $junk | cut -c 1 | tr N n`" = "n" ]; then
326 echo "Command output will not be sent to the terminal."
327 echo "To view progress, see the $LOG file."
330 # 3. Present any pre-install customizations to the user
332 # TODO: enter in the configuration dialogs
338 # 4. Do the installation
340 # 4A. Download any source code files or binary packages required
342 if [ "$prepackaged" ]; then
345 # 4B. For native packaging, call the native packaging system to install
350 # 4C. If we build our own, compile and install prerequisites then Citadel
353 install_prerequisites
357 # 5. Do post-installation setup