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, version 2.
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 # curl http://easyinstall.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 we 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:
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
73 BUILD=$WORKDIR/citadel-build.$$
74 LOG=$WORKDIR/citadel-install-log.txt
75 export SUPPORT CITADEL WEBCIT
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 # WEBCIT Directory where WebCit is installed
85 # SUPPORT Directory where support programs are installed
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
93 # IS_UPGRADE Set to "yes" if upgrading an existing Citadel
94 # CTDL_DIALOG Where (if at all) the "dialog" program may be found
96 # Let Citadel setup recognize the Citadel installer
98 export CITADEL_INSTALLER
100 DOWNLOAD_SITE=http://easyinstall.citadel.org
102 # Original source code packages.
103 DB_SOURCE=db-4.3.29.NC.tar.gz
104 # DB_PATCHES=db-x.x.x.patches
105 ICAL_SOURCE=libical-0.26-6.aurore.tar.gz
106 LIBSIEVE_SOURCE=libsieve-2.2.3.tar.gz
107 CITADEL_SOURCE=citadel-easyinstall.tar.gz
108 WEBCIT_SOURCE=webcit-easyinstall.tar.gz
110 SETUP="Citadel Easy Install"
113 ##### BEGIN Functions #####
116 echo Easy Install is aborting.
117 echo Please report this problem to the Citadel developers.
125 WGET=`which wget 2>/dev/null`
126 CURL=`which curl 2>/dev/null`
127 if [ -n "${WGET}" -a -x "${WGET}" ]; then
128 $WGET $DOWNLOAD_SITE/$FILENAME >/dev/null 2>>$LOG || die
130 if [ -n "${CURL}" -a -x "${CURL}" ]; then
131 $CURL $DOWNLOAD_SITE/$FILENAME >$FILENAME 2>>$LOG || die
133 echo Unable to find a wget or curl command.
134 echo Easy Install cannot continue.
142 determine_distribution () {
143 # First look for Red Hat in general
144 if [ -x /bin/rpm ]; then
145 RELEASE_FILE=/dev/null
146 if /bin/rpm -q redhat-release >/dev/null 2>&1; then
148 RELEASE_FILE=/etc/redhat-release
150 if /bin/rpm -q whitebox-release >/dev/null 2>&1; then
151 DISTRO_MAJOR=WhiteBox
152 RELEASE_FILE=/etc/whitebox-release
154 if /bin/rpm -q fedora-release >/dev/null 2>&1; then
157 RELEASE_FILE=/etc/fedora-release
159 # Then look for specific version
160 ( cat $RELEASE_FILE | grep Enterprise ) >/dev/null 2>&1 && \
161 DISTRO_MINOR=Enterprise
162 DISTRO_VERSION=`tr -cd "[^0-9.]" < $RELEASE_FILE | cut -c 1`
166 if [ -f /etc/gentoo-release ]; then
171 # TODO: check for Debian
175 cd $BUILD 2>&1 >>$LOG || die
176 FILENAME=libical-easyinstall.sum ; download_this
177 SUM=`cat libical-easyinstall.sum`
178 SUMFILE=$SUPPORT/etc/libical-easyinstall.sum
179 if [ -r $SUMFILE ] ; then
180 OLDSUM=`cat $SUMFILE`
181 if [ $SUM = $OLDSUM ] ; then
182 echo "* libical does not need updating."
186 echo "* Downloading libical..."
187 FILENAME=$ICAL_SOURCE ; download_this
188 echo "* Installing libical..."
189 ( gzip -dc $ICAL_SOURCE | tar -xf - ) 2>&1 >>$LOG || die
190 cd $BUILD/libical-0.26 2>&1 >>$LOG || die
191 ./configure --prefix=$SUPPORT 2>&1 >>$LOG || die
192 $MAKE $MAKEOPTS 2>&1 >>$LOG || die
193 $MAKE install 2>&1 >>$LOG || die
196 rm -f $CITADEL/citadel-easyinstall.sum 2>/dev/null
197 rm -f $WEBCIT/webcit-easyinstall.sum 2>/dev/null
200 install_libsieve () {
201 cd $BUILD 2>&1 >>$LOG || die
202 FILENAME=libsieve-easyinstall.sum ; download_this
203 SUM=`cat libsieve-easyinstall.sum`
204 SUMFILE=$SUPPORT/etc/libsieve-easyinstall.sum
205 if [ -r $SUMFILE ] ; then
206 OLDSUM=`cat $SUMFILE`
207 if [ $SUM = $OLDSUM ] ; then
208 echo "* libsieve does not need updating."
212 echo "* Downloading libsieve..."
213 FILENAME=$LIBSIEVE_SOURCE ; download_this
214 echo "* Installing libsieve..."
215 ( gzip -dc $LIBSIEVE_SOURCE | tar -xf - ) 2>&1 >>$LOG || die
216 cd $BUILD/libsieve-2.2.3/src 2>&1 >>$LOG || die
217 ./configure --prefix=$SUPPORT 2>&1 >>$LOG || die
218 $MAKE $MAKEOPTS 2>&1 >>$LOG || die
219 $MAKE install 2>&1 >>$LOG || die
222 rm -f $CITADEL/citadel-easyinstall.sum 2>/dev/null
226 cd $BUILD 2>&1 >>$LOG || die
227 FILENAME=db-easyinstall.sum ; download_this
228 SUM=`cat db-easyinstall.sum`
229 SUMFILE=$SUPPORT/etc/db-easyinstall.sum
230 if [ -r $SUMFILE ] ; then
231 OLDSUM=`cat $SUMFILE`
232 if [ $SUM = $OLDSUM ] ; then
233 echo "* Berkeley DB does not need updating."
237 echo "* Downloading Berkeley DB..."
238 FILENAME=$DB_SOURCE ; download_this
239 echo "* Installing Berkeley DB..."
240 ( gzip -dc $DB_SOURCE | tar -xf - ) 2>&1 >>$LOG || die
241 cd $BUILD/db-4.3.29.NC 2>&1 >>$LOG || die
242 #patch -p0 < ../$DB_PATCHES 2>&1 >>$LOG || die
243 cd $BUILD/db-4.3.29.NC/build_unix 2>&1 >>$LOG || die
244 ../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
245 $MAKE $MAKEOPTS 2>&1 >>$LOG || die
246 $MAKE install 2>&1 >>$LOG || die
249 rm -f $CITADEL/citadel-easyinstall.sum 2>/dev/null
252 install_prerequisites () {
254 # Create the support directories if they don't already exist
256 mkdir $SUPPORT 2>/dev/null
257 mkdir $SUPPORT/bin 2>/dev/null
258 mkdir $SUPPORT/sbin 2>/dev/null
259 mkdir $SUPPORT/lib 2>/dev/null
260 mkdir $SUPPORT/libexec 2>/dev/null
261 mkdir $SUPPORT/include 2>/dev/null
262 mkdir $SUPPORT/etc 2>/dev/null
270 if [ -z "$OK_LIBSIEVE" ]
281 cd $BUILD 2>&1 >>$LOG || die
282 if [ -f $CITADEL/citadel.config ]
285 echo "* Upgrading your existing Citadel installation."
290 CFLAGS="-I${SUPPORT}/include"
292 LDFLAGS="-L${SUPPORT}/lib -Wl,--rpath -Wl,${SUPPORT}/lib"
293 export CFLAGS CPPFLAGS LDFLAGS
295 DO_INSTALL_CITADEL=yes
296 FILENAME=citadel-easyinstall.sum ; download_this
297 SUM=`cat citadel-easyinstall.sum`
298 SUMFILE=$CITADEL/citadel-easyinstall.sum
299 if [ -r $SUMFILE ] ; then
300 OLDSUM=`cat $SUMFILE`
301 if [ $SUM = $OLDSUM ] ; then
302 echo "* Citadel does not need updating."
303 DO_INSTALL_CITADEL=no
307 if [ $DO_INSTALL_CITADEL = yes ] ; then
308 echo "* Downloading Citadel..."
309 FILENAME=$CITADEL_SOURCE ; download_this
310 echo "* Installing Citadel..."
311 cd $BUILD 2>&1 >>$LOG || die
312 ( gzip -dc $CITADEL_SOURCE | tar -xf - ) 2>&1 >>$LOG || die
313 cd $BUILD/citadel 2>&1 >>$LOG || die
316 ./configure --prefix=$CITADEL --with-db=$SUPPORT --with-pam --with-libical --disable-threaded-client 2>&1 >>$LOG || die
318 ./configure --prefix=$CITADEL --with-db=$OK_DB --with-pam --with-libical --disable-threaded-client 2>&1 >>$LOG || die
320 $MAKE $MAKEOPTS 2>&1 >>$LOG || die
321 if [ $IS_UPGRADE = yes ]
323 echo "* Performing Citadel upgrade..."
324 $MAKE upgrade 2>&1 >>$LOG || die
326 echo "* Performing Citadel install..."
327 $MAKE install 2>&1 >>$LOG || die
328 useradd -c "Citadel service account" -d $CITADEL -s $CITADEL/citadel citadel 2>&1 >>$LOG
333 cd $BUILD 2>&1 >>$LOG || die
334 DO_INSTALL_WEBCIT=yes
335 FILENAME=webcit-easyinstall.sum ; download_this
336 SUM=`cat webcit-easyinstall.sum`
337 SUMFILE=$WEBCIT/webcit-easyinstall.sum
338 if [ -r $SUMFILE ] ; then
339 OLDSUM=`cat $SUMFILE`
340 if [ $SUM = $OLDSUM ] ; then
341 echo "* WebCit does not need updating."
346 if [ $DO_INSTALL_WEBCIT = yes ] ; then
347 echo "* Downloading WebCit..."
348 FILENAME=$WEBCIT_SOURCE ; download_this
349 echo "* Installing WebCit..."
350 cd $BUILD 2>&1 >>$LOG || die
351 ( gzip -dc $WEBCIT_SOURCE | tar -xf - ) 2>&1 >>$LOG || die
352 cd $BUILD/webcit 2>&1 >>$LOG || die
353 ./configure --prefix=$WEBCIT --with-libical 2>&1 >>$LOG || die
354 $MAKE $MAKEOPTS 2>&1 >>$LOG || die
355 $MAKE install 2>&1 >>$LOG || die
363 echo "* Configuring your system ..."
365 if [ x$IS_UPGRADE == xyes ] ; then
366 echo Upgrading your existing Citadel installation.
367 $CITADEL/setup </dev/tty || die
369 echo This is a new Citadel installation.
370 $CITADEL/setup </dev/tty || die
373 $WEBCIT/setup </dev/tty || die
378 ##### END Functions #####
380 ##### BEGIN main #####
382 # 1. Gather information about the target system
384 # Non-GNU make does not work.
385 # This probably ought to be fixed, but for now we will simply require GNU make.
388 if gmake -v 2>&1 | grep -i GNU ; then
391 if make -v 2>&1 | grep -i GNU ; then
396 if [ $MAKE == xx ] ; then
398 echo 'Easy Install requires GNU Make (gmake), which was not found.'
399 echo 'Please install gmake and try again.'
414 # 1A. Do we use the native packaging system or build our own copy of Citadel?
416 if [ "$os" = "Linux" ]; then
417 determine_distribution
418 elif [ "$os" = "FreeBSD" ]; then
419 # TODO: We detect FreeBSD but the port is still out of date...
421 elif [ "$os" = "Darwin" ]; then
422 # TODO: Deal with Apple weirdness
433 # 2. Present the installation steps (from 1 above) to the user
435 if dialog 2>&1 </dev/tty | grep gauge >/dev/null 2>&1 ; then
436 CTDL_DIALOG=`which dialog`
438 elif cdialog 2>&1 </dev/tty | grep gauge >/dev/null 2>&1 ; then
439 CTDL_DIALOG=`which cdialog`
444 echo "$SETUP will perform the following actions:"
447 echo "* Download/install supporting libraries (if needed)"
448 echo "* Download/install Citadel (if needed)"
449 echo "* Download/install WebCit (if needed)"
451 echo "Configuration:"
452 echo "* Configure Citadel"
453 echo "* Configure WebCit"
455 echo -n "Perform the above installation steps now? "
458 if [ "`echo $yesno | cut -c 1 | tr N n`" = "n" ]; then
463 echo "Command output will not be sent to the terminal."
464 echo "To view progress, see the $LOG file."
467 # 3. Present any pre-install customizations to the user
469 # TODO: enter in the configuration dialogs
475 # 4. Do the installation
477 # 4A. Download any source code files or binary packages required
479 if [ "$prepackaged" ]; then
482 # 4B. For native packaging, call the native packaging system to install
487 # 4C. If we build our own, compile and install prerequisites then Citadel
489 install_prerequisites
493 # 5. Do post-installation setup