sintonia/livesupport/bin/install.sh

245 lines
8.3 KiB
Bash
Executable File

#!/bin/sh
#-------------------------------------------------------------------------------
# Copyright (c) 2004 Media Development Loan Fund
#
# This file is part of the LiveSupport project.
# http://livesupport.campware.org/
# To report bugs, send an e-mail to bugs@campware.org
#
# LiveSupport is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# LiveSupport is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with LiveSupport; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#
# Author : $Author: tomas $
# Version : $Revision: 1.12 $
# Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/bin/Attic/install.sh,v $
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# This script installs LiveSupport.
#
# Invoke as:
# ./bin/install.sh
#
# To get usage help, try the -h option
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# Determine directories, files
#-------------------------------------------------------------------------------
reldir=`dirname $0`/..
basedir=`cd $reldir; pwd;`
bindir=$basedir/bin
etcdir=$basedir/etc
docdir=$basedir/doc
tmpdir=$basedir/tmp
toolsdir=$basedir/tools
modules_dir=$basedir/modules
products_dir=$basedir/products
usrdir=`cd $basedir/usr; pwd;`
#-------------------------------------------------------------------------------
# Print the usage information for this script.
#-------------------------------------------------------------------------------
printUsage()
{
echo "LiveSupport install script.";
echo "parameters";
echo "";
echo " -d, --directory The installation directory, required.";
echo " -D, --database The name of the LiveSupport database.";
echo " [default: LiveSupport]";
echo " -g, --apache-group The group the apache daemon runs as.";
echo " [default: apache]";
echo " -H, --host The fully qualified host name of the system";
echo " [default: guess].";
echo " -p, --port The port of the apache web server [default: 80]"
echo " -P, --scheduler-port The port of the scheduler daemon to install"
echo " [default: 3344]";
echo " -r, --www-root The root directory for web documents served";
echo " by apache [default: /var/www]";
echo " -s, --dbserver The name of the database server host.";
echo " [default: localhost]";
echo " -u, --dbuser The name of the database user to access the"
echo " database. [default: livesupport]";
echo " -w, --dbpassword The database user password.";
echo " [default: livesupport]";
echo " -h, --help Print this message and exit.";
echo "";
}
#-------------------------------------------------------------------------------
# Process command line parameters
#-------------------------------------------------------------------------------
CMD=${0##*/}
opts=$(getopt -o d:D:g:H:hp:P:r:s:u:w: -l apache-group:,database:,dbserver:,dbuser:,dbpassword:,directory:,host:,help,port:,scheduler-port:,www-root: -n $CMD -- "$@") || exit 1
eval set -- "$opts"
while true; do
case "$1" in
-d|--directory)
installdir=$2;
shift; shift;;
-D|--database)
database=$2;
shift; shift;;
-g|--apache-group)
apache_group=$2;
shift; shift;;
-H|--host)
hostname=$2;
shift; shift;;
-h|--help)
printUsage;
exit 0;;
-p|--port)
http_port=$2;
shift; shift;;
-P|--scheduler-port)
scheduler_port=$2;
shift; shift;;
-r|--www-root)
www_root=$2;
shift; shift;;
-s|--dbserver)
dbserver=$2;
shift; shift;;
-u|--dbuser)
dbuser=$2;
shift; shift;;
-w|--dbpassword)
dbpassword=$2;
shift; shift;;
--)
shift;
break;;
*)
echo "Unrecognized option $1.";
printUsage;
exit 1;
esac
done
if [ "x$installdir" == "x" ]; then
echo "Required parameter install directory not specified.";
printUsage;
exit 1;
fi
if [ "x$hostname" == "x" ]; then
hostname=`hostname -f`;
fi
if [ "x$http_port" == "x" ]; then
http_port=80;
fi
if [ "x$scheduler_port" == "x" ]; then
scheduler_port=3344;
fi
if [ "x$dbserver" == "x" ]; then
dbserver=localhost;
fi
if [ "x$database" == "x" ]; then
database=LiveSupport;
fi
if [ "x$dbuser" == "x" ]; then
dbuser=livesupport;
fi
if [ "x$dbpassword" == "x" ]; then
dbpassword=livesupport;
fi
if [ "x$apache_group" == "x" ]; then
apache_group=apache;
fi
if [ "x$www_root" == "x" ]; then
www_root=/var/www
fi
echo "Installing LiveSupport.";
echo "";
echo "Using the following installation parameters:";
echo "";
echo " installation directory: $installdir";
echo " host name: $hostname";
echo " web server port: $http_port";
echo " scheduler port: $scheduler_port";
echo " database server: $dbserver";
echo " database: $database";
echo " database user: $dbuser";
echo " database user password: $dbpassword";
echo " apache daemon group: $apache_group";
echo " apache document root: $www_root";
echo ""
#-------------------------------------------------------------------------------
# Check if we're in the CVS, and bail out if so
#-------------------------------------------------------------------------------
if [ -f CVS/Root ]; then
echo "ERROR: this script is not intended to be run from the CVS sources.";
echo " run this script from inside the source tarball";
exit 1;
fi
#-------------------------------------------------------------------------------
# Do pre-install checks
#-------------------------------------------------------------------------------
$bindir/preInstall.sh --apache-group $apache_group || exit 1;
#-------------------------------------------------------------------------------
# Copy the files
#-------------------------------------------------------------------------------
$bindir/copyInstall.sh --directory $installdir || exit 1;
#-------------------------------------------------------------------------------
# Do post-install setup
#-------------------------------------------------------------------------------
$bindir/postInstallScheduler.sh --directory $installdir \
--database $database \
--apache-group $apache_group \
--host $hostname \
--port $http_port \
--scheduler-port $scheduler_port \
--dbserver $dbserver \
--dbuser $dbuser \
--dbpassword $dbpassword \
--www-root $www_root \
|| exit 1;
$bindir/postInstallGLiveSupport.sh --directory $installdir \
--host $hostname \
--port $http_port \
--scheduler-port $scheduler_port \
|| exit 1;
#-------------------------------------------------------------------------------
# Say goodbye
#-------------------------------------------------------------------------------
echo "Done."