4 # Automatic script to install Citadel on a target system.
5 # Copyright (C) 2004 Michael Hampton <error@citadel.org>
6 # Copyright (C) 2004 Art Cancro <ajc@uncensored.citadel.org>
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 # Reading this script? Here's some helpful hints:
24 # If you're seeing this in your browser, it's probably not what you want.
25 # You can either save it to disk and run it, or do it the easy way:
27 # wget -q -O - http://easyinstall.citadel.org/install | sh
29 # Note that this script installs software on your system and so it requires
30 # root privileges. Feel free to inspect the script to make sure I didn't
31 # do anything stupid...
33 # We have provided you the source code according to the terms of the respective
34 # software licenses included in the source code packages, even if you choose
35 # not to keep the source code around. You can always download it again later.
37 # We install the following versions in this release:
38 # Package Version Status
41 # libical 0.24.RC4 Latest
42 # Berkeley DB 4.1.25 + 2 patches Stable
43 # OpenLDAP 2.1.30 stable-20040329 Stable
46 ###############################################################################
48 # This is the general stuff we're going to do, in order:
50 # 1. Gather information about the target system
51 # 2. Present the installation steps (from 1 above) to the user
52 # 3. Present any pre-install customizations to the user
53 # 4. Do the installation
54 # A. Download any source code files or binary packages required
55 # B. For native packaging, call the native packaging system to install
56 # C. If we build our own, compile and install prerequisites then Citadel
57 # 5. Do post-installation setup
61 ###############################################################################
64 # Begin user customization area
66 # These two directories specify where Citadel and its private support
67 # libraries will be installed. This keeps them safely tucked away from
68 # the rest of your system. The defaults should be fine for most people.
69 # NB: When binary packages are installed, these settings are ignored!
70 SUPPORT=/usr/local/ctdlsupport
71 CITADEL=/usr/local/citadel
72 WEBCIT=/usr/local/webcit
73 BUILD=/tmp/citadel-build.$$
74 export SUPPORT CITADEL WEBCIT
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 # WEBCIT Directory where WebCit is installed
86 # SUPPORT Directory where support programs are installed
87 # LDAP_CONFIG Location of the slapd.conf file
88 # SLAPD_BINARY Location of the slapd binary
89 # DISTRO_MAJOR Linux distribution name, if applicable
90 # DISTRO_MINOR Linux distribution name, if applicable
91 # DISTRO_VERSION Linux distribution version (major digit) if applicable
92 # CC C compiler being used
93 # MAKE Make program being used
94 # CFLAGS C compiler flags
95 # LDFLAGS Linker flags
96 # IS_UPGRADE Set to "yes" if upgrading an existing Citadel
98 # Let Citadel setup recognize the Citadel installer
100 export CITADEL_INSTALLER
102 DOWNLOAD_SITE=http://easyinstall.citadel.org
104 # Original source code packages.
105 DB_SOURCE=db-4.1.25.tar.gz
106 DB_PATCHES=db-4.1.25.patches
107 ICAL_SOURCE=libical-0.24.RC4.tar.gz
108 LDAP_SOURCE=openldap-stable-20040329.tgz
109 CITADEL_SOURCE=citadel-easyinstall.tar.gz
110 WEBCIT_SOURCE=webcit-5.22.tar.gz
112 SETUP="Citadel Easy Install"
116 ##### BEGIN Functions #####
119 echo Easy Install is aborting.
120 echo Please report this problem to the Citadel developers.
126 determine_distribution () {
127 # First look for Red Hat in general
128 if [ -x /bin/rpm ]; then
129 RELEASE_FILE=/dev/null
130 if /bin/rpm -q redhat-release >/dev/null 2>&1; then
132 RELEASE_FILE=/etc/redhat-release
134 if /bin/rpm -q whitebox-release >/dev/null 2>&1; then
135 DISTRO_MAJOR=WhiteBox
136 RELEASE_FILE=/etc/whitebox-release
138 if /bin/rpm -q fedora-release >/dev/null 2>&1; then
141 RELEASE_FILE=/etc/fedora-release
143 # Then look for specific version
144 ( cat $RELEASE_FILE | grep Enterprise ) >/dev/null 2>&1 && \
145 DISTRO_MINOR=Enterprise
146 DISTRO_VERSION=`tr -cd "[^0-9.]" < $RELEASE_FILE | cut -c 1`
150 if [ -f /etc/gentoo-release ]; then
155 # TODO: check for Debian
158 download_sources () {
159 echo "* Downloading Berkeley DB..."
160 wget -c $DOWNLOAD_SITE/$DB_SOURCE 2>&1 >>$LOG || die
161 echo "* Downloading libical..."
162 wget -c $DOWNLOAD_SITE/$ICAL_SOURCE 2>&1 >>$LOG || die
163 echo "* Downloading OpenLDAP..."
164 wget -c $DOWNLOAD_SITE/$LDAP_SOURCE 2>&1 >>$LOG || die
165 echo "* Downloading Citadel..."
166 wget -c $DOWNLOAD_SITE/$CITADEL_SOURCE 2>&1 >>$LOG || die
167 echo "* Downloading WebCit..."
168 wget -c $DOWNLOAD_SITE/$WEBCIT_SOURCE 2>&1 >>$LOG || die
172 echo "* Installing libical..."
173 cd $BUILD 2>&1 >>$LOG || die
174 ( gzip -dc $ICAL_SOURCE | tar -xvf - ) 2>&1 >>$LOG || die
175 cd $BUILD/libical-0.24 2>&1 >>$LOG || die
176 ./configure --prefix=$SUPPORT 2>&1 >>$LOG || die
177 $MAKE $MAKEOPTS 2>&1 >>$LOG || die
178 $MAKE install 2>&1 >>$LOG || die
183 echo "* Installing Berkeley DB..."
184 cd $BUILD 2>&1 >>$LOG || die
185 ( gzip -dc $DB_SOURCE | tar -xvf - ) 2>&1 >>$LOG || die
186 cd $BUILD/db-4.1.25 2>&1 >>$LOG || die
187 #patch -p0 < ../$DB_PATCHES 2>&1 >>$LOG || die
188 cd $BUILD/db-4.1.25/build_unix 2>&1 >>$LOG || die
189 ../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
190 $MAKE $MAKEOPTS 2>&1 >>$LOG || die
191 $MAKE install 2>&1 >>$LOG || die
196 echo "* Installing OpenLDAP..."
197 CFLAGS="${CFLAGS} -I${SUPPORT}/include"
199 LDFLAGS="-L${SUPPORT}/lib -Wl,--rpath -Wl,${SUPPORT}/lib"
200 export CFLAGS CPPFLAGS LDFLAGS
201 cd $BUILD 2>&1 >>$LOG || die
202 ( gzip -dc $LDAP_SOURCE | tar -xvf - ) 2>&1 >>$LOG || die
203 cd $BUILD/openldap-2.1.29 2>&1 >>$LOG || die
204 ./configure --prefix=$SUPPORT --enable-bdb 2>&1 >>$LOG || die
205 $MAKE $MAKEOPTS 2>&1 >>$LOG || die
206 LDAP_CONFIG=$SUPPORT/etc/openldap/slapd.conf
208 SLAPD_BINARY=$SUPPORT/libexec/slapd
210 $MAKE install 2>&1 >>$LOG || die
214 install_prerequisites () {
216 # Create the support directories if they don't already exist
218 mkdir $SUPPORT 2>/dev/null
219 mkdir $SUPPORT/bin 2>/dev/null
220 mkdir $SUPPORT/sbin 2>/dev/null
221 mkdir $SUPPORT/lib 2>/dev/null
222 mkdir $SUPPORT/libexec 2>/dev/null
223 mkdir $SUPPORT/include 2>/dev/null
224 mkdir $SUPPORT/etc 2>/dev/null
243 echo "* Installing Citadel..."
245 CFLAGS="${CFLAGS} -I${SUPPORT}/include"
247 LDFLAGS="-L${SUPPORT}/lib -Wl,--rpath -Wl,${SUPPORT}/lib"
248 export CFLAGS CPPFLAGS LDFLAGS
250 cd $BUILD 2>&1 >>$LOG || die
251 ( gzip -dc $CITADEL_SOURCE | tar -xvf - ) 2>&1 >>$LOG || die
252 cd $BUILD/citadel 2>&1 >>$LOG || die
255 ./configure --prefix=$CITADEL --with-db=$SUPPORT --with-pam --enable-autologin --with-ldap --with-libical --disable-threaded-client 2>&1 >>$LOG || die
257 ./configure --prefix=$CITADEL --with-db=$OK_DB --with-pam --enable-autologin --with-ldap --with-libical --disable-threaded-client 2>&1 >>$LOG || die
259 $MAKE $MAKEOPTS 2>&1 >>$LOG || die
260 if [ -f $CITADEL/citadel.config ]
262 $MAKE upgrade 2>&1 >>$LOG || die
265 $MAKE install 2>&1 >>$LOG || die
266 useradd -c "Citadel service account" -b $CITADEL -s /bin/false -r -d $CITADEL citadel 2>&1 >>$LOG
269 echo "* Installing WebCit..."
270 cd $BUILD 2>&1 >>$LOG || die
271 ( gzip -dc $WEBCIT_SOURCE | tar -xvf - ) 2>&1 >>$LOG || die
272 cd $BUILD/webcit 2>&1 >>$LOG || die
273 ./configure --prefix=$WEBCIT --with-libical 2>&1 >>$LOG || die
274 $MAKE $MAKEOPTS 2>&1 >>$LOG || die
275 $MAKE install 2>&1 >>$LOG || die
281 echo "* Configuring your system ..."
283 if [ x$IS_UPGRADE == xyes ] ; then
284 echo Upgrading your existing Citadel installation.
285 #$CITADEL/setup -q || die
286 $CITADEL/setup || die
288 echo This is a new Citadel installation.
289 $CITADEL/setup || die
297 ##### END Functions #####
299 ##### BEGIN main #####
301 # 1. Gather information about the target system
303 [ x$MAKE == x ] && MAKE=`which gmake`
304 [ x$MAKE == x ] && MAKE=`which make`
309 # 1A. Do we use the native packaging system or build our own copy of Citadel?
311 if [ "$os" = "Linux" ]; then
312 determine_distribution
313 elif [ "$os" = "FreeBSD" ]; then
314 # TODO: We detect FreeBSD but the port is still out of date...
318 # 2. Present the installation steps (from 1 above) to the user
320 echo "$SETUP will perform the following actions:"
322 echo "Configuration:"
323 echo "* Configure Citadel"
324 echo "* Configure WebCit"
328 if [ "$prepackaged" ]; then
329 show_packages_to_install
331 echo "* Install supporting libraries"
332 echo "* Install Citadel"
333 echo "* Install WebCit"
337 echo -n "Perform the above installation steps now? (yes) "
340 if [ "`echo $junk | cut -c 1 | tr N n`" = "n" ]; then
349 echo "Command output will not be sent to the terminal."
350 echo "To view progress, see the $LOG file."
353 # 3. Present any pre-install customizations to the user
355 # TODO: enter in the configuration dialogs
361 # 4. Do the installation
363 # 4A. Download any source code files or binary packages required
365 if [ "$prepackaged" ]; then
368 # 4B. For native packaging, call the native packaging system to install
373 # 4C. If we build our own, compile and install prerequisites then Citadel
376 install_prerequisites
380 # 5. Do post-installation setup