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 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:
38 # Package Version Status
41 # libical 0.24.RC4 Latest
42 # Berkeley DB 4.3.21 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
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 # CTDL_DIALOG Where (if at all) the "dialog" program may be found
97 # Let Citadel setup recognize the Citadel installer
99 export CITADEL_INSTALLER
101 DOWNLOAD_SITE=http://easyinstall.citadel.org
103 # Original source code packages.
104 DB_SOURCE=db-4.3.21.NC.tar.gz
105 # DB_PATCHES=db-x.x.x.patches
106 ICAL_SOURCE=libical-0.24.RC4.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.
124 determine_distribution () {
125 # First look for Red Hat in general
126 if [ -x /bin/rpm ]; then
127 RELEASE_FILE=/dev/null
128 if /bin/rpm -q redhat-release >/dev/null 2>&1; then
130 RELEASE_FILE=/etc/redhat-release
132 if /bin/rpm -q whitebox-release >/dev/null 2>&1; then
133 DISTRO_MAJOR=WhiteBox
134 RELEASE_FILE=/etc/whitebox-release
136 if /bin/rpm -q fedora-release >/dev/null 2>&1; then
139 RELEASE_FILE=/etc/fedora-release
141 # Then look for specific version
142 ( cat $RELEASE_FILE | grep Enterprise ) >/dev/null 2>&1 && \
143 DISTRO_MINOR=Enterprise
144 DISTRO_VERSION=`tr -cd "[^0-9.]" < $RELEASE_FILE | cut -c 1`
148 if [ -f /etc/gentoo-release ]; then
153 # TODO: check for Debian
157 cd $BUILD 2>&1 >>$LOG || die
158 $WGET $DOWNLOAD_SITE/libical-easyinstall.sum
159 SUM=`cat libical-easyinstall.sum`
160 SUMFILE=$SUPPORT/etc/libical-easyinstall.sum
161 if [ -r $SUMFILE ] ; then
162 OLDSUM=`cat $SUMFILE`
163 if [ $SUM = $OLDSUM ] ; then
164 echo "* libical does not need updating."
168 echo "* Downloading libical..."
169 $WGET $DOWNLOAD_SITE/$ICAL_SOURCE 2>&1 >>$LOG || die
170 echo "* Installing libical..."
171 ( gzip -dc $ICAL_SOURCE | tar -xvf - ) 2>&1 >>$LOG || die
172 cd $BUILD/libical-0.24 2>&1 >>$LOG || die
173 ./configure --prefix=$SUPPORT 2>&1 >>$LOG || die
174 $MAKE $MAKEOPTS 2>&1 >>$LOG || die
175 $MAKE install 2>&1 >>$LOG || die
178 rm -f $CITADEL/citadel-easyinstall.sum 2>/dev/null
179 rm -f $WEBCIT/webcit-easyinstall.sum 2>/dev/null
183 cd $BUILD 2>&1 >>$LOG || die
184 $WGET $DOWNLOAD_SITE/db-easyinstall.sum
185 SUM=`cat db-easyinstall.sum`
186 SUMFILE=$SUPPORT/etc/db-easyinstall.sum
187 if [ -r $SUMFILE ] ; then
188 OLDSUM=`cat $SUMFILE`
189 if [ $SUM = $OLDSUM ] ; then
190 echo "* Berkeley DB does not need updating."
194 echo "* Downloading Berkeley DB..."
195 $WGET $DOWNLOAD_SITE/$DB_SOURCE 2>&1 >>$LOG || die
196 echo "* Installing Berkeley DB..."
197 ( gzip -dc $DB_SOURCE | tar -xvf - ) 2>&1 >>$LOG || die
198 cd $BUILD/db-4.3.21.NC 2>&1 >>$LOG || die
199 #patch -p0 < ../$DB_PATCHES 2>&1 >>$LOG || die
200 cd $BUILD/db-4.3.21.NC/build_unix 2>&1 >>$LOG || die
201 ../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
202 $MAKE $MAKEOPTS 2>&1 >>$LOG || die
203 $MAKE install 2>&1 >>$LOG || die
206 rm -f $CITADEL/citadel-easyinstall.sum 2>/dev/null
209 install_prerequisites () {
211 # Create the support directories if they don't already exist
213 mkdir $SUPPORT 2>/dev/null
214 mkdir $SUPPORT/bin 2>/dev/null
215 mkdir $SUPPORT/sbin 2>/dev/null
216 mkdir $SUPPORT/lib 2>/dev/null
217 mkdir $SUPPORT/libexec 2>/dev/null
218 mkdir $SUPPORT/include 2>/dev/null
219 mkdir $SUPPORT/etc 2>/dev/null
234 cd $BUILD 2>&1 >>$LOG || die
235 if [ -f $CITADEL/citadel.config ]
238 echo "* Upgrading your existing Citadel installation."
243 CFLAGS="-I${SUPPORT}/include"
245 LDFLAGS="-L${SUPPORT}/lib -Wl,--rpath -Wl,${SUPPORT}/lib"
246 export CFLAGS CPPFLAGS LDFLAGS
248 DO_INSTALL_CITADEL=yes
249 $WGET $DOWNLOAD_SITE/citadel-easyinstall.sum
250 SUM=`cat citadel-easyinstall.sum`
251 SUMFILE=$CITADEL/citadel-easyinstall.sum
252 if [ -r $SUMFILE ] ; then
253 OLDSUM=`cat $SUMFILE`
254 if [ $SUM = $OLDSUM ] ; then
255 echo "* Citadel does not need updating."
256 DO_INSTALL_CITADEL=no
260 if [ $DO_INSTALL_CITADEL = yes ] ; then
261 echo "* Downloading Citadel..."
262 $WGET $DOWNLOAD_SITE/$CITADEL_SOURCE 2>&1 >>$LOG || die
263 echo "* Installing Citadel..."
264 cd $BUILD 2>&1 >>$LOG || die
265 ( gzip -dc $CITADEL_SOURCE | tar -xvf - ) 2>&1 >>$LOG || die
266 cd $BUILD/citadel 2>&1 >>$LOG || die
269 ./configure --prefix=$CITADEL --with-db=$SUPPORT --with-pam --enable-autologin --with-libical --disable-threaded-client 2>&1 >>$LOG || die
271 ./configure --prefix=$CITADEL --with-db=$OK_DB --with-pam --enable-autologin --with-libical --disable-threaded-client 2>&1 >>$LOG || die
273 $MAKE $MAKEOPTS 2>&1 >>$LOG || die
274 if [ $IS_UPGRADE = yes ]
276 echo "* Performing Citadel upgrade..."
277 $MAKE upgrade 2>&1 >>$LOG || die
279 echo "* Performing Citadel install..."
280 $MAKE install 2>&1 >>$LOG || die
281 useradd -c "Citadel service account" -d $CITADEL -s $CITADEL/citadel citadel 2>&1 >>$LOG
286 cd $BUILD 2>&1 >>$LOG || die
287 DO_INSTALL_WEBCIT=yes
288 $WGET $DOWNLOAD_SITE/webcit-easyinstall.sum
289 SUM=`cat webcit-easyinstall.sum`
290 SUMFILE=$WEBCIT/webcit-easyinstall.sum
291 if [ -r $SUMFILE ] ; then
292 OLDSUM=`cat $SUMFILE`
293 if [ $SUM = $OLDSUM ] ; then
294 echo "* WebCit does not need updating."
299 if [ $DO_INSTALL_WEBCIT = yes ] ; then
300 echo "* Downloading WebCit..."
301 $WGET $DOWNLOAD_SITE/$WEBCIT_SOURCE 2>&1 >>$LOG || die
302 echo "* Installing WebCit..."
303 cd $BUILD 2>&1 >>$LOG || die
304 ( gzip -dc $WEBCIT_SOURCE | tar -xvf - ) 2>&1 >>$LOG || die
305 cd $BUILD/webcit 2>&1 >>$LOG || die
306 ./configure --prefix=$WEBCIT --with-libical 2>&1 >>$LOG || die
307 $MAKE $MAKEOPTS 2>&1 >>$LOG || die
308 $MAKE install 2>&1 >>$LOG || die
316 echo "* Configuring your system ..."
318 if [ x$IS_UPGRADE == xyes ] ; then
319 echo Upgrading your existing Citadel installation.
320 #$CITADEL/setup -q || die
321 $CITADEL/setup </dev/tty || die
323 echo This is a new Citadel installation.
324 $CITADEL/setup </dev/tty || die
327 $WEBCIT/setup </dev/tty || die
332 ##### END Functions #####
334 ##### BEGIN main #####
336 # 1. Gather information about the target system
338 [ -n "$MAKE" ] && [ -x `which gmake` ] && MAKE=`which gmake`
339 ##### FIXME: non-GNU make does not work #####[ -z "$MAKE" ] && [ -x `which make` ] && MAKE=`which make`
344 #[ -n "$WGET" ] && [ -x `which wget` ] && WGET=`which wget`
345 #[ -z "$WGET" ] && [ -x `which curl` ] && WGET=`which curl`\ -O
347 [ -n "$WGET" ] && [ -x `which curl` ] && WGET=`which curl`\ -O
348 [ -z "$WGET" ] && [ -x `which wget` ] && WGET=`which wget`
354 # 1A. Do we use the native packaging system or build our own copy of Citadel?
356 if [ "$os" = "Linux" ]; then
357 determine_distribution
358 elif [ "$os" = "FreeBSD" ]; then
359 # TODO: We detect FreeBSD but the port is still out of date...
361 elif [ "$os" = "Darwin" ]; then
362 # TODO: Deal with Apple weirdness
372 # 2. Present the installation steps (from 1 above) to the user
374 if dialog --clear </dev/tty ; then
375 CTDL_DIALOG=`which dialog`
380 echo "$SETUP will perform the following actions:"
383 echo "* Download/install supporting libraries (if needed)"
384 echo "* Download/install Citadel (if needed)"
385 echo "* Download/install WebCit (if needed)"
387 echo "Configuration:"
388 echo "* Configure Citadel"
389 echo "* Configure WebCit"
391 echo -n "Perform the above installation steps now? "
394 if [ "`echo $yesno | cut -c 1 | tr N n`" = "n" ]; then
399 echo "Command output will not be sent to the terminal."
400 echo "To view progress, see the $LOG file."
403 # 3. Present any pre-install customizations to the user
405 # TODO: enter in the configuration dialogs
411 # 4. Do the installation
413 # 4A. Download any source code files or binary packages required
415 if [ "$prepackaged" ]; then
418 # 4B. For native packaging, call the native packaging system to install
423 # 4C. If we build our own, compile and install prerequisites then Citadel
425 install_prerequisites
429 # 5. Do post-installation setup