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 # curl 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 we 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:
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 # SLAPD_BINARY Location of the slapd binary
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
94 # IS_UPGRADE Set to "yes" if upgrading an existing Citadel
95 # IS_AUTOLOGIN Set to "yes" to force enabling autologin
96 # CTDL_DIALOG Where (if at all) the "dialog" program may be found
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.3.29.NC.tar.gz
106 # DB_PATCHES=db-x.x.x.patches
107 ICAL_SOURCE=libical-0.24.RC4.tar.gz
108 CITADEL_SOURCE=citadel-easyinstall.tar.gz
109 WEBCIT_SOURCE=webcit-easyinstall.tar.gz
111 SETUP="Citadel Easy Install"
114 ##### BEGIN Functions #####
117 echo Easy Install is aborting.
118 echo Please report this problem to the Citadel developers.
127 if [ -x `which wget` ] ; then
128 wget $FILENAME >/dev/null 2>>$LOG || die
130 if [ -x `which curl` ] ; then
131 curl $FILENAME >$FILENAME 2>>$LOG || die
133 echo Unable to find a wget or curl command.
134 echo Easy Install cannot continue.
143 determine_distribution () {
144 # First look for Red Hat in general
145 if [ -x /bin/rpm ]; then
146 RELEASE_FILE=/dev/null
147 if /bin/rpm -q redhat-release >/dev/null 2>&1; then
149 RELEASE_FILE=/etc/redhat-release
151 if /bin/rpm -q whitebox-release >/dev/null 2>&1; then
152 DISTRO_MAJOR=WhiteBox
153 RELEASE_FILE=/etc/whitebox-release
155 if /bin/rpm -q fedora-release >/dev/null 2>&1; then
158 RELEASE_FILE=/etc/fedora-release
160 # Then look for specific version
161 ( cat $RELEASE_FILE | grep Enterprise ) >/dev/null 2>&1 && \
162 DISTRO_MINOR=Enterprise
163 DISTRO_VERSION=`tr -cd "[^0-9.]" < $RELEASE_FILE | cut -c 1`
167 if [ -f /etc/gentoo-release ]; then
172 # TODO: check for Debian
176 cd $BUILD 2>&1 >>$LOG || die
177 FILENAME=$DOWNLOAD_SITE/libical-easyinstall.sum ; download_this
178 SUM=`cat libical-easyinstall.sum`
179 SUMFILE=$SUPPORT/etc/libical-easyinstall.sum
180 if [ -r $SUMFILE ] ; then
181 OLDSUM=`cat $SUMFILE`
182 if [ $SUM = $OLDSUM ] ; then
183 echo "* libical does not need updating."
187 echo "* Downloading libical..."
188 FILENAME=$DOWNLOAD_SITE/$ICAL_SOURCE ; download_this
189 echo "* Installing libical..."
190 ( gzip -dc $ICAL_SOURCE | tar -xvf - ) 2>&1 >>$LOG || die
191 cd $BUILD/libical-0.24 2>&1 >>$LOG || die
192 ./configure --prefix=$SUPPORT 2>&1 >>$LOG || die
193 $MAKE $MAKEOPTS 2>&1 >>$LOG || die
194 $MAKE install 2>&1 >>$LOG || die
197 rm -f $CITADEL/citadel-easyinstall.sum 2>/dev/null
198 rm -f $WEBCIT/webcit-easyinstall.sum 2>/dev/null
202 cd $BUILD 2>&1 >>$LOG || die
203 FILENAME=$DOWNLOAD_SITE/db-easyinstall.sum ; download_this
204 SUM=`cat db-easyinstall.sum`
205 SUMFILE=$SUPPORT/etc/db-easyinstall.sum
206 if [ -r $SUMFILE ] ; then
207 OLDSUM=`cat $SUMFILE`
208 if [ $SUM = $OLDSUM ] ; then
209 echo "* Berkeley DB does not need updating."
213 echo "* Downloading Berkeley DB..."
214 FILENAME=$DOWNLOAD_SITE/$DB_SOURCE ; download_this
215 echo "* Installing Berkeley DB..."
216 ( gzip -dc $DB_SOURCE | tar -xvf - ) 2>&1 >>$LOG || die
217 cd $BUILD/db-4.3.29.NC 2>&1 >>$LOG || die
218 #patch -p0 < ../$DB_PATCHES 2>&1 >>$LOG || die
219 cd $BUILD/db-4.3.29.NC/build_unix 2>&1 >>$LOG || die
220 ../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
221 $MAKE $MAKEOPTS 2>&1 >>$LOG || die
222 $MAKE install 2>&1 >>$LOG || die
225 rm -f $CITADEL/citadel-easyinstall.sum 2>/dev/null
228 install_prerequisites () {
230 # Create the support directories if they don't already exist
232 mkdir $SUPPORT 2>/dev/null
233 mkdir $SUPPORT/bin 2>/dev/null
234 mkdir $SUPPORT/sbin 2>/dev/null
235 mkdir $SUPPORT/lib 2>/dev/null
236 mkdir $SUPPORT/libexec 2>/dev/null
237 mkdir $SUPPORT/include 2>/dev/null
238 mkdir $SUPPORT/etc 2>/dev/null
253 cd $BUILD 2>&1 >>$LOG || die
254 if [ -f $CITADEL/citadel.config ]
257 echo "* Upgrading your existing Citadel installation."
262 CFLAGS="-I${SUPPORT}/include"
264 LDFLAGS="-L${SUPPORT}/lib -Wl,--rpath -Wl,${SUPPORT}/lib"
265 export CFLAGS CPPFLAGS LDFLAGS
267 DO_INSTALL_CITADEL=yes
268 FILENAME=$DOWNLOAD_SITE/citadel-easyinstall.sum ; download_this
269 SUM=`cat citadel-easyinstall.sum`
270 SUMFILE=$CITADEL/citadel-easyinstall.sum
271 if [ -r $SUMFILE ] ; then
272 OLDSUM=`cat $SUMFILE`
273 if [ $SUM = $OLDSUM ] ; then
274 echo "* Citadel does not need updating."
275 DO_INSTALL_CITADEL=no
279 if [ $DO_INSTALL_CITADEL = yes ] ; then
280 echo "* Downloading Citadel..."
281 FILENAME=$DOWNLOAD_SITE/$CITADEL_SOURCE ; download_this
282 echo "* Installing Citadel..."
283 cd $BUILD 2>&1 >>$LOG || die
284 ( gzip -dc $CITADEL_SOURCE | tar -xvf - ) 2>&1 >>$LOG || die
285 cd $BUILD/citadel 2>&1 >>$LOG || die
286 if [ x$IS_AUTOLOGIN = xyes ] ; then
287 AL="--enable-autologin"
293 ./configure --prefix=$CITADEL --with-db=$SUPPORT --with-pam $AL --with-libical --disable-threaded-client 2>&1 >>$LOG || die
295 ./configure --prefix=$CITADEL --with-db=$OK_DB --with-pam $AL --with-libical --disable-threaded-client 2>&1 >>$LOG || die
297 $MAKE $MAKEOPTS 2>&1 >>$LOG || die
298 if [ $IS_UPGRADE = yes ]
300 echo "* Performing Citadel upgrade..."
301 $MAKE upgrade 2>&1 >>$LOG || die
303 echo "* Performing Citadel install..."
304 $MAKE install 2>&1 >>$LOG || die
305 useradd -c "Citadel service account" -d $CITADEL -s $CITADEL/citadel citadel 2>&1 >>$LOG
310 cd $BUILD 2>&1 >>$LOG || die
311 DO_INSTALL_WEBCIT=yes
312 FILENAME=$DOWNLOAD_SITE/webcit-easyinstall.sum ; download_this
313 SUM=`cat webcit-easyinstall.sum`
314 SUMFILE=$WEBCIT/webcit-easyinstall.sum
315 if [ -r $SUMFILE ] ; then
316 OLDSUM=`cat $SUMFILE`
317 if [ $SUM = $OLDSUM ] ; then
318 echo "* WebCit does not need updating."
323 if [ $DO_INSTALL_WEBCIT = yes ] ; then
324 echo "* Downloading WebCit..."
325 FILENAME=$DOWNLOAD_SITE/$WEBCIT_SOURCE ; download_this
326 echo "* Installing WebCit..."
327 cd $BUILD 2>&1 >>$LOG || die
328 ( gzip -dc $WEBCIT_SOURCE | tar -xvf - ) 2>&1 >>$LOG || die
329 cd $BUILD/webcit 2>&1 >>$LOG || die
330 ./configure --prefix=$WEBCIT --with-libical 2>&1 >>$LOG || die
331 $MAKE $MAKEOPTS 2>&1 >>$LOG || die
332 $MAKE install 2>&1 >>$LOG || die
340 echo "* Configuring your system ..."
342 if [ x$IS_UPGRADE == xyes ] ; then
343 echo Upgrading your existing Citadel installation.
344 $CITADEL/setup </dev/tty || die
346 echo This is a new Citadel installation.
347 $CITADEL/setup </dev/tty || die
350 $WEBCIT/setup </dev/tty || die
355 ##### END Functions #####
357 ##### BEGIN main #####
359 # 1. Gather information about the target system
361 # Non-GNU make does not work.
362 # This probably ought to be fixed, but for now we will simply require GNU make.
365 if gmake -v 2>&1 | grep -i GNU ; then
368 if make -v 2>&1 | grep -i GNU ; then
373 if [ $MAKE == xx ] ; then
375 echo 'Easy Install requires GNU Make (gmake), which was not found.'
376 echo 'Please install gmake and try again.'
391 # 1A. Do we use the native packaging system or build our own copy of Citadel?
393 if [ "$os" = "Linux" ]; then
394 determine_distribution
395 elif [ "$os" = "FreeBSD" ]; then
396 # TODO: We detect FreeBSD but the port is still out of date...
398 elif [ "$os" = "Darwin" ]; then
399 # TODO: Deal with Apple weirdness
409 # 1B. Determine whether we are upgrading an autologin installation
410 [ -x $CITADEL/chkpwd ] && {
415 # 2. Present the installation steps (from 1 above) to the user
417 if dialog --clear </dev/tty ; then
418 CTDL_DIALOG=`which dialog`
423 echo "$SETUP will perform the following actions:"
426 echo "* Download/install supporting libraries (if needed)"
427 echo "* Download/install Citadel (if needed)"
428 echo "* Download/install WebCit (if needed)"
430 echo "Configuration:"
431 echo "* Configure Citadel"
432 echo "* Configure WebCit"
433 if [ x$IS_AUTOLOGIN = xyes ] ; then
434 echo 'NOTE: this is an autologin installation.'
435 echo ' Authentication against user accounts on the host system is enabled.'
438 echo -n "Perform the above installation steps now? "
441 if [ "`echo $yesno | cut -c 1 | tr N n`" = "n" ]; then
446 echo "Command output will not be sent to the terminal."
447 echo "To view progress, see the $LOG file."
450 # 3. Present any pre-install customizations to the user
452 # TODO: enter in the configuration dialogs
458 # 4. Do the installation
460 # 4A. Download any source code files or binary packages required
462 if [ "$prepackaged" ]; then
465 # 4B. For native packaging, call the native packaging system to install
470 # 4C. If we build our own, compile and install prerequisites then Citadel
472 install_prerequisites
476 # 5. Do post-installation setup