2006-11-29 17:19:45 +01:00
|
|
|
#!/bin/bash
|
2006-10-19 16:55:07 +02:00
|
|
|
#-------------------------------------------------------------------------------
|
2010-07-16 18:50:06 +02:00
|
|
|
# Copyright (c) 2010 Sourcefabric O.P.S.
|
2006-10-19 16:55:07 +02:00
|
|
|
#
|
|
|
|
# This file is part of the Campcaster project.
|
2010-07-16 18:50:06 +02:00
|
|
|
# http://campcaster.sourcefabric.org/
|
2006-10-19 16:55:07 +02:00
|
|
|
# To report bugs, send an e-mail to bugs@campware.org
|
|
|
|
#
|
|
|
|
# Campcaster 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.
|
|
|
|
#
|
|
|
|
# Campcaster 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 Campcaster; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# This script makes pre-install steps and checks for Campcaster.
|
|
|
|
#
|
|
|
|
# Invoke as:
|
|
|
|
# ./bin/preInstall.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
|
|
|
|
srcdir=$basedir/src
|
|
|
|
tmpdir=$basedir/tmp
|
|
|
|
toolsdir=$srcdir/tools
|
|
|
|
modules_dir=$srcdir/modules
|
|
|
|
products_dir=$srcdir/products
|
|
|
|
|
|
|
|
usrdir=`cd $basedir/usr; pwd;`
|
|
|
|
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# Print the usage information for this script.
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
printUsage()
|
|
|
|
{
|
|
|
|
echo "Campcaster pre-install script.";
|
|
|
|
echo "parameters";
|
|
|
|
echo "";
|
|
|
|
echo " -g, --apache-group The group the apache daemon runs as.";
|
|
|
|
echo " [default: apache]";
|
|
|
|
echo " -h, --help Print this message and exit.";
|
|
|
|
echo "";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# Process command line parameters
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
CMD=${0##*/}
|
|
|
|
|
|
|
|
opts=$(getopt -o g:h -l apache-group:,help -n $CMD -- "$@") || exit 1
|
|
|
|
eval set -- "$opts"
|
|
|
|
while true; do
|
|
|
|
case "$1" in
|
|
|
|
-g|--apache-group)
|
|
|
|
apache_group=$2;
|
|
|
|
shift; shift;;
|
|
|
|
-h|--help)
|
|
|
|
printUsage;
|
|
|
|
exit 0;;
|
|
|
|
--)
|
|
|
|
shift;
|
|
|
|
break;;
|
|
|
|
*)
|
|
|
|
echo "Unrecognized option $1.";
|
|
|
|
printUsage;
|
|
|
|
exit 1;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ "x$apache_group" == "x" ]; then
|
|
|
|
apache_group=apache;
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
echo "Making pre-install steps for Campcaster.";
|
|
|
|
echo "";
|
|
|
|
echo "Using the following installation parameters:";
|
|
|
|
echo "";
|
|
|
|
echo " apache daemon group: $apache_group";
|
|
|
|
echo ""
|
|
|
|
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# Check for the apache group to be a real group
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
group_tmp_file=/tmp/ls_group_check.$$
|
|
|
|
touch $group_tmp_file
|
|
|
|
test_result=`chgrp $apache_group $group_tmp_file 2> /dev/null`
|
|
|
|
if [ $? != 0 ]; then
|
|
|
|
rm -f $group_tmp_file;
|
|
|
|
echo "Unable to use apache deamon group $apache_group.";
|
|
|
|
echo "Please check if $apache_group is a correct user group.";
|
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
rm -f $group_tmp_file;
|
|
|
|
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# Function to check for the existence of an executable on the PATH
|
|
|
|
#
|
|
|
|
# @param $1 the name of the exectuable
|
|
|
|
# @return 0 if the executable exists on the PATH, non-0 otherwise
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
check_exe() {
|
|
|
|
if [ -x "`which $1 2> /dev/null`" ]; then
|
|
|
|
echo "Executable $1 found...";
|
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
echo "Executable $1 not found...";
|
|
|
|
return 1;
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# Check for required tools
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
echo "Checking for required tools..."
|
|
|
|
|
|
|
|
check_exe "sed" || exit 1;
|
|
|
|
check_exe "psql" || exit 1;
|
|
|
|
check_exe "php" || exit 1;
|
|
|
|
check_exe "odbcinst" || exit 1;
|
|
|
|
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# Say goodbye
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
echo "Done."
|
|
|
|
|