rationalizing and updating the database creation scripts (now there are 2, instead of 4 as before); this fixes #1815
This commit is contained in:
parent
0bab7b928a
commit
9b75a37237
|
@ -312,7 +312,9 @@ echo "Creating ODBC data source and driver...";
|
|||
if [ -f /usr/lib/libodbcpsql.so ]; then
|
||||
odbcinst_template=$install_etc/odbcinst_template
|
||||
elif [ -f /usr/lib/odbc/psqlodbc.so ]; then
|
||||
odbcinst_template=$install_etc/odbcinst_debian_template
|
||||
odbcinst_template=$install_etc/odbcinst_old_debian_template
|
||||
elif [ -f /usr/lib/odbc/psqlodbcw.so ]; then
|
||||
odbcinst_template=$install_etc/odbcinst_new_debian_template
|
||||
else
|
||||
echo "###############################"
|
||||
echo "Postgresql driver for unixODBC not found;"
|
||||
|
|
|
@ -43,6 +43,9 @@ toolsdir=$srcdir/tools
|
|||
modules_dir=$srcdir/modules
|
||||
products_dir=$srcdir/products
|
||||
|
||||
scheduler_dir=${products_dir}/scheduler
|
||||
scheduler_bindir=${scheduler_dir}/bin
|
||||
|
||||
usrdir=`cd $basedir/usr; pwd;`
|
||||
|
||||
installlog=/tmp/livesupport_install.log
|
||||
|
@ -51,87 +54,26 @@ installlog=/tmp/livesupport_install.log
|
|||
#-------------------------------------------------------------------------------
|
||||
# The details of the setup
|
||||
#-------------------------------------------------------------------------------
|
||||
ls_dbserver=localhost
|
||||
ls_database=LiveSupport-test
|
||||
ls_dbuser=test
|
||||
ls_dbpassword=test
|
||||
ls_database=LiveSupport-test
|
||||
|
||||
|
||||
postgres_user=postgres
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# 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 to see if this script is being run as root
|
||||
#-------------------------------------------------------------------------------
|
||||
if [ `whoami` != "root" ]; then
|
||||
echo "Please run this script as root.";
|
||||
exit ;
|
||||
fi
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Check for required tools
|
||||
#-------------------------------------------------------------------------------
|
||||
echo "Checking for required tools..."
|
||||
|
||||
check_exe "psql" || exit 1;
|
||||
check_exe "odbcinst" || exit 1;
|
||||
ls_dbserver=localhost
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Create the necessary database user and database itself
|
||||
#-------------------------------------------------------------------------------
|
||||
echo "Creating database and database user...";
|
||||
|
||||
su - $postgres_user -c "echo \"CREATE USER $ls_dbuser \
|
||||
ENCRYPTED PASSWORD '$ls_dbpassword' \
|
||||
CREATEDB NOCREATEUSER;\" \
|
||||
| psql template1" \
|
||||
|| echo "Couldn't create database user $ls_dbuser.";
|
||||
|
||||
su - $postgres_user -c "echo \"CREATE DATABASE \\\"$ls_database\\\" \
|
||||
OWNER $ls_dbuser ENCODING 'utf-8';\" \
|
||||
| psql template1" \
|
||||
|| echo "Couldn't create database $ls_database.";
|
||||
|
||||
|
||||
# TODO: check for the success of these operations somehow
|
||||
${scheduler_bindir}/createDatabase.sh --database=${ls_database} \
|
||||
--dbuser=${ls_dbuser} \
|
||||
--dbpassword=${ls_dbpassword} \
|
||||
--dbserver=${ls_dbserver}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Create the ODBC data source and driver
|
||||
#-------------------------------------------------------------------------------
|
||||
echo "Creating ODBC data source and driver...";
|
||||
|
||||
odbcinst_template=$products_dir/scheduler/etc/odbcinst_test_template
|
||||
odbc_template=$products_dir/scheduler/etc/odbc_test_template
|
||||
|
||||
# check for an existing PostgreSQL ODBC driver, and only install if necessary
|
||||
odbcinst_res=`odbcinst -q -d | grep "\[PostgreSQL\]"`
|
||||
if [ "x$odbcinst_res" == "x" ]; then
|
||||
echo "Registering ODBC PostgreSQL driver...";
|
||||
odbcinst -i -d -v -f $odbcinst_template || exit 1;
|
||||
fi
|
||||
|
||||
echo "Registering LiveSupport ODBC data source...";
|
||||
odbcinst -i -s -l -f $odbc_template || exit 1;
|
||||
${scheduler_bindir}/createOdbcDataSource.sh --database=${ls_database} \
|
||||
--dbserver=${ls_dbserver}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
|
|
@ -48,6 +48,9 @@ toolsdir=$srcdir/tools
|
|||
modules_dir=$srcdir/modules
|
||||
products_dir=$srcdir/products
|
||||
|
||||
scheduler_dir=${products_dir}/scheduler
|
||||
scheduler_bindir=${scheduler_dir}/bin
|
||||
|
||||
usrdir=`cd $basedir/usr; pwd;`
|
||||
|
||||
|
||||
|
@ -114,86 +117,20 @@ ls_dbpassword=test
|
|||
ls_dbserver=localhost
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# 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 to see if this script is being run as root
|
||||
#-------------------------------------------------------------------------------
|
||||
if [ `whoami` != "root" ]; then
|
||||
echo "Please run this script as root.";
|
||||
exit ;
|
||||
fi
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Check for required tools
|
||||
#-------------------------------------------------------------------------------
|
||||
echo "Checking for required tools..."
|
||||
|
||||
check_exe "psql" || exit 1;
|
||||
check_exe "odbcinst" || exit 1;
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Create the necessary database user and database itself
|
||||
#-------------------------------------------------------------------------------
|
||||
echo "Creating database and database user...";
|
||||
|
||||
# FIXME: the below might not work for remote databases
|
||||
|
||||
su - $postgres_user -c "echo \"CREATE USER $ls_dbuser \
|
||||
ENCRYPTED PASSWORD '$ls_dbpassword' \
|
||||
CREATEDB NOCREATEUSER;\" \
|
||||
| psql template1" \
|
||||
|| echo "Couldn't create database user $ls_dbuser.";
|
||||
|
||||
su - $postgres_user -c "echo \"CREATE DATABASE \\\"$ls_database\\\" \
|
||||
OWNER $ls_dbuser ENCODING 'utf-8';\" \
|
||||
| psql template1" \
|
||||
|| echo "Couldn't create database $ls_database.";
|
||||
|
||||
|
||||
# TODO: check for the success of these operations somehow
|
||||
${scheduler_bindir}/createDatabase.sh --database=${ls_database} \
|
||||
--dbuser=${ls_dbuser} \
|
||||
--dbpassword=${ls_dbpassword} \
|
||||
--dbserver=${ls_dbserver}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Create the ODBC data source and driver
|
||||
#-------------------------------------------------------------------------------
|
||||
echo "Creating ODBC data source and driver...";
|
||||
|
||||
odbcinst_template=$products_dir/scheduler/etc/odbcinst_template
|
||||
odbc_template=$products_dir/scheduler/etc/odbc_template
|
||||
odbc_template_tmp=/tmp/odbc_template.$$
|
||||
|
||||
replace_sed_string="s/ls_database/$ls_database/; \
|
||||
s/ls_dbserver/$ls_dbserver/;"
|
||||
|
||||
# check for an existing PostgreSQL ODBC driver, and only install if necessary
|
||||
odbcinst_res=`odbcinst -q -d | grep "\[PostgreSQL\]"`
|
||||
if [ "x$odbcinst_res" == "x" ]; then
|
||||
echo "Registering ODBC PostgreSQL driver...";
|
||||
odbcinst -i -d -v -f $odbcinst_template || exit 1;
|
||||
fi
|
||||
|
||||
echo "Registering LiveSupport ODBC data source...";
|
||||
cat $odbc_template | sed -e "$replace_sed_string" > $odbc_template_tmp
|
||||
odbcinst -i -s -l -f $odbc_template_tmp || exit 1;
|
||||
rm -f $odbc_template_tmp
|
||||
${scheduler_bindir}/createOdbcDataSource.sh --database=${ls_database} \
|
||||
--dbserver=${ls_dbserver}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
|
|
@ -1,203 +0,0 @@
|
|||
#!/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$
|
||||
# Version : $Revision$
|
||||
# Location : $URL$
|
||||
#-------------------------------------------------------------------------------
|
||||
#-------------------------------------------------------------------------------
|
||||
# This script sets up the development environment for a user.
|
||||
#
|
||||
# Invoke as:
|
||||
# ./bin/user_setup_root.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 "LiveSupport user database setup script.";
|
||||
echo "parameters:";
|
||||
echo "";
|
||||
echo " -u, --user The user to set up the environment for.";
|
||||
echo " Required parameter.";
|
||||
echo " -h, --help Print this message and exit.";
|
||||
echo "";
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Process command line parameters
|
||||
#-------------------------------------------------------------------------------
|
||||
CMD=${0##*/}
|
||||
|
||||
opts=$(getopt -o hu: -l help,user: -n $CMD -- "$@") || exit 1
|
||||
eval set -- "$opts"
|
||||
while true; do
|
||||
case "$1" in
|
||||
-h|--help)
|
||||
printUsage;
|
||||
exit 0;;
|
||||
-u|--user)
|
||||
user=$2;
|
||||
shift; shift;;
|
||||
--)
|
||||
shift;
|
||||
break;;
|
||||
*)
|
||||
echo "Unrecognized option $1.";
|
||||
printUsage;
|
||||
exit 1;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ "x$user" == "x" ]; then
|
||||
echo "Required parameter user missing.";
|
||||
printUsage;
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
|
||||
echo "Creating the LiveSupport user database";
|
||||
echo "for user: $user.";
|
||||
echo ""
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# The details of installation
|
||||
#-------------------------------------------------------------------------------
|
||||
postgres_user=postgres
|
||||
|
||||
ls_database=LiveSupport-$user
|
||||
ls_dbuser=test
|
||||
ls_dbpassword=test
|
||||
ls_dbserver=localhost
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# 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 to see if this script is being run as root
|
||||
#-------------------------------------------------------------------------------
|
||||
if [ `whoami` != "root" ]; then
|
||||
echo "Please run this script as root.";
|
||||
exit ;
|
||||
fi
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Check for required tools
|
||||
#-------------------------------------------------------------------------------
|
||||
echo "Checking for required tools..."
|
||||
|
||||
check_exe "psql" || exit 1;
|
||||
check_exe "odbcinst" || exit 1;
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Create the necessary database user and database itself
|
||||
#-------------------------------------------------------------------------------
|
||||
echo "Creating database and database user...";
|
||||
|
||||
# FIXME: the below might not work for remote databases
|
||||
|
||||
su - $postgres_user -c "echo \"CREATE USER $ls_dbuser \
|
||||
ENCRYPTED PASSWORD '$ls_dbpassword' \
|
||||
CREATEDB NOCREATEUSER;\" \
|
||||
| psql template1" \
|
||||
|| echo "Couldn't create database user $ls_dbuser.";
|
||||
|
||||
su - $postgres_user -c "echo \"CREATE DATABASE \\\"$ls_database\\\" \
|
||||
OWNER $ls_dbuser ENCODING 'utf-8';\" \
|
||||
| psql template1" \
|
||||
|| echo "Couldn't create database $ls_database.";
|
||||
|
||||
|
||||
# TODO: check for the success of these operations somehow
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Create the ODBC data source and driver
|
||||
#-------------------------------------------------------------------------------
|
||||
echo "Creating ODBC data source and driver...";
|
||||
|
||||
odbcinst_template=$products_dir/scheduler/etc/odbcinst_debian_template
|
||||
odbc_template=$products_dir/scheduler/etc/odbc_template
|
||||
odbc_template_tmp=/tmp/odbc_template.$$
|
||||
|
||||
replace_sed_string="s/ls_database/$ls_database/; \
|
||||
s/ls_dbserver/$ls_dbserver/;"
|
||||
|
||||
# check for an existing PostgreSQL ODBC driver, and only install if necessary
|
||||
odbcinst_res=`odbcinst -q -d | grep "\[PostgreSQL\]"`
|
||||
if [ "x$odbcinst_res" == "x" ]; then
|
||||
echo "Registering ODBC PostgreSQL driver...";
|
||||
odbcinst -i -d -v -f $odbcinst_template || exit 1;
|
||||
fi
|
||||
|
||||
echo "Registering LiveSupport ODBC data source...";
|
||||
cat $odbc_template | sed -e "$replace_sed_string" > $odbc_template_tmp
|
||||
odbcinst -i -s -l -f $odbc_template_tmp || exit 1;
|
||||
rm -f $odbc_template_tmp
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Say goodbye
|
||||
#-------------------------------------------------------------------------------
|
||||
echo "Done."
|
||||
|
|
@ -161,7 +161,9 @@ echo "Creating ODBC data source and driver...";
|
|||
if [ -f /usr/lib/libodbcpsql.so ]; then
|
||||
odbcinst_template=$etcdir/odbcinst_template
|
||||
elif [ -f /usr/lib/odbc/psqlodbc.so ]; then
|
||||
odbcinst_template=$etcdir/odbcinst_debian_template
|
||||
odbcinst_template=$etcdir/odbcinst_old_debian_template
|
||||
elif [ -f /usr/lib/odbc/psqlodbcw.so ]; then
|
||||
odbcinst_template=$etcdir/odbcinst_new_debian_template
|
||||
else
|
||||
echo "can't find ODBC driver for PostgreSQL neither at /usr/lib";
|
||||
echo "nor at /usr/lib/odbc. please install proper ODBC drivers";
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
[PostgreSQL]
|
||||
Description = PostgreSQL driver
|
||||
Driver = /usr/lib/odbc/psqlodbcw.so
|
||||
Setup = /usr/lib/odbc/libodbcpsqlS.so
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
[PostgreSQL]
|
||||
Description = PostgreSQL driver
|
||||
Driver = /usr/lib/libodbcpsql.so
|
||||
Setup = /usr/lib/libodbcpsqlS.so
|
||||
|
Loading…
Reference in New Issue