CC-1024 Update installation/build for webapp-only

Installation/uninstallation should work now.

Also removed more files that are no longer needed now that Studio doesnt
exist anymore.
This commit is contained in:
paul.baranowski 2010-10-11 17:22:04 +02:00
parent 3caab7db1e
commit b340ff3bb6
16 changed files with 254 additions and 1059 deletions

View file

@ -24,13 +24,16 @@ require_once(dirname(__FILE__).'/../backend/GreenBox.php');
require_once(dirname(__FILE__).'/../backend/cron/Cron.php');
require_once(dirname(__FILE__)."/installInit.php");
// Need to check that we are superuser before running this.
echo " *** Database Installation ***\n";
//sudo -u postgres createuser --no-superuser --no-createdb --no-createrole -A -P myuser
// Create the database user
$command = "sudo -u postgres psql postgres --command \"CREATE USER {$CC_CONFIG['dsn']['username']} "
." ENCRYPTED PASSWORD '{$CC_CONFIG['dsn']['password']}' CREATEDB NOCREATEUSER;\" 2>/dev/null";
." ENCRYPTED PASSWORD '{$CC_CONFIG['dsn']['password']}' LOGIN CREATEDB NOCREATEUSER;\" 2>/dev/null";
//echo $command."\n";
@exec($command, $output, $results);
if ($results == 0) {
echo " * User {$CC_CONFIG['dsn']['username']} created.\n";
@ -38,7 +41,8 @@ if ($results == 0) {
echo " * User {$CC_CONFIG['dsn']['username']} already exists.\n";
}
$command = "sudo -u postgres createdb {$CC_CONFIG['dsn']['database']} 2> /dev/null";
$command = "sudo -u postgres createdb {$CC_CONFIG['dsn']['database']} --owner {$CC_CONFIG['dsn']['username']} 2> /dev/null";
//echo $command."\n";
@exec($command, $output, $results);
if ($results == 0) {
echo " * Database '{$CC_CONFIG['dsn']['database']}' created.\n";
@ -50,11 +54,11 @@ if ($results == 0) {
campcaster_db_connect(true);
// Install postgres scripting language
$langIsInstalled = $CC_DBC->GetOne('select count(*) FROM pg_language WHERE lanname = \'plpgsql\'');
$langIsInstalled = $CC_DBC->GetOne('SELECT COUNT(*) FROM pg_language WHERE lanname = \'plpgsql\'');
if ($langIsInstalled == '0') {
echo " * Installing Postgres scripting language...\n";
$sql = "CREATE LANGUAGE 'plpgsql'";
camp_install_query($sql);
camp_install_query($sql, false);
} else {
echo " * Postgres scripting language already installed\n";
}
@ -392,19 +396,6 @@ if (!camp_db_table_exists($CC_CONFIG['accessTable'])) {
echo " * Skipping: database table already exists: ".$CC_CONFIG['accessTable']."\n";
}
echo " * Inserting default users...\n";
$gb = new GreenBox();
$r = $gb->initData(true);
if (PEAR::isError($r)) {
echo "\n * ERROR: ";
print_r($r);
}
//echo "done.\n";
//------------------------------------------------------------------------------
// Submodules
//------------------------------------------------------------------------------
if (!camp_db_table_exists($CC_CONFIG['transTable'])) {
echo " * Creating database table ".$CC_CONFIG['transTable']."...";
$sql = "CREATE TABLE ".$CC_CONFIG['transTable']." (
@ -485,19 +476,6 @@ if (!camp_db_table_exists($CC_CONFIG['scheduleTable'])) {
}
//if (!camp_db_table_exists($CC_CONFIG['playlogTable'])) {
// echo " * Creating database table ".$CC_CONFIG['playlogTable']."...";
// $sql = "CREATE TABLE ".$CC_CONFIG['playlogTable']."("
// ." id BIGINT NOT NULL,"
// ." audioClipId BIGINT NOT NULL,"
// ." timestamp TIMESTAMP NOT NULL,"
// ." PRIMARY KEY(id))";
// camp_install_query($sql);
//} else {
// echo " * Skipping: database table already exists: ".$CC_CONFIG['playlogTable']."\n";
//}
if (!camp_db_table_exists($CC_CONFIG['backupTable'])) {
echo " * Creating database table ".$CC_CONFIG['backupTable']."...";
$sql = "CREATE TABLE ".$CC_CONFIG['backupTable']." ("
@ -545,6 +523,19 @@ if (!camp_db_table_exists($CC_CONFIG['prefTable'])) {
echo " * Skipping: database table already exists: ".$CC_CONFIG['prefTable']."\n";
}
//------------------------------------------------------------------------
// Install default data
//------------------------------------------------------------------------
echo " *** Inserting Default Data ***\n";
$gb = new GreenBox();
$r = $gb->initData(true);
if (PEAR::isError($r)) {
echo "\n * ERROR: ";
print_r($r);
}
//echo "done.\n";
//------------------------------------------------------------------------
// Install storage directories
//------------------------------------------------------------------------

View file

@ -1,78 +0,0 @@
#!/bin/bash
#-------------------------------------------------------------------------------
# Copyright (c) 2010 Sourcefabric O.P.S.
#
# This file is part of the Campcaster project.
# http://campcaster.sourcefabric.org/
# 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 sets up the test database for Campcaster
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# 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
scheduler_dir=${products_dir}/scheduler
scheduler_bindir=${scheduler_dir}/bin
usrdir=`cd $basedir/usr; pwd;`
installlog=/tmp/campcaster_install.log
#-------------------------------------------------------------------------------
# The details of the setup
#-------------------------------------------------------------------------------
ls_database=Campcaster-test
ls_dbuser=test
ls_dbpassword=test
ls_dbserver=localhost
#-------------------------------------------------------------------------------
# Create the necessary database user and database itself
#-------------------------------------------------------------------------------
${scheduler_bindir}/createDatabase.sh --database=${ls_database} \
--dbuser=${ls_dbuser} \
--dbpassword=${ls_dbpassword} \
--dbserver=${ls_dbserver}
#-------------------------------------------------------------------------------
# Create the ODBC data source and driver
#-------------------------------------------------------------------------------
${scheduler_bindir}/createOdbcDataSource.sh --database=${ls_database} \
--dbserver=${ls_dbserver}
#-------------------------------------------------------------------------------
# Say goodbye
#-------------------------------------------------------------------------------
echo "Done."

View file

@ -23,43 +23,59 @@ echo "***************************\n";
require_once(dirname(__FILE__).'/../conf.php');
require_once(dirname(__FILE__).'/installInit.php');
require_once(dirname(__FILE__).'/../backend/cron/Cron.php');
campcaster_db_connect(false);
function camp_uninstall_delete_files($p_path)
{
if (!empty($p_path) && (strlen($p_path) > 4)) {
list($dirList,$fileList) = File_Find::maptree($p_path);
foreach ($fileList as $filepath) {
echo " * Removing $filepath...";
@unlink($filepath);
echo "done.\n";
}
foreach ($dirList as $dirpath) {
echo " * Removing $dirpath...";
@rmdir($dirpath);
echo "done.\n";
if (file_exists($p_path)) {
$dir = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($p_path), RecursiveIteratorIterator::CHILD_FIRST);
for ($dir->rewind(); $dir->valid(); $dir->next()) {
if ($dir->isDir()) {
rmdir($dir->getPathname());
} else {
unlink($dir->getPathname());
}
}
rmdir($p_path);
}
// list($dirList,$fileList) = File_Find::maptree($p_path);
// foreach ($fileList as $filepath) {
// echo " * Removing file $filepath...";
// @unlink($filepath);
// echo "done.\n";
// }
// foreach ($dirList as $dirpath) {
// echo " * Removing directory $dirpath...";
// @rmdir($dirpath);
// echo "done.\n";
// }
}
// echo " * Removing $p_path...";
// @rmdir($p_path);
// echo "done.\n";
}
if (!PEAR::isError($CC_DBC)) {
if (camp_db_table_exists($CC_CONFIG['prefTable'])) {
echo " * Removing database table ".$CC_CONFIG['prefTable']."...";
$sql = "DROP TABLE ".$CC_CONFIG['prefTable'];
camp_install_query($sql, false);
//------------------------------------------------------------------------
// Delete the database
// Note: Do not put a call to campcaster_db_connect()
// before this function, even if you called $CC_DBC->disconnect(), there will
// still be a connection to the database and you wont be able to delete it.
//------------------------------------------------------------------------
echo " * Dropping the database '".$CC_CONFIG['dsn']['database']."'...\n";
$command = "sudo -u postgres dropdb {$CC_CONFIG['dsn']['database']} 2> /dev/null";
@exec($command, $output, $results);
//campcaster_db_connect(true);
//$CC_DBC->disconnect();
$CC_DBC->dropSequence($CC_CONFIG['prefTable']."_id");
echo "done.\n";
} else {
echo " * Skipping: database table ".$CC_CONFIG['prefTable']."\n";
}
}
//------------------------------------------------------------------------
// Uninstall Cron job
//------------------------------------------------------------------------
$old_regex = '/transportCron\.php/';
echo " * Uninstall storageServer cron job...\n";
echo " * Uninstalling cron job...";
$cron = new Cron();
$access = $cron->openCrontab('write');
@ -68,138 +84,180 @@ if ($access != 'write') {
$r = $cron->forceWriteable();
} while ($r);
}
foreach ($cron->ct->getByType(CRON_CMD) as $id => $line) {
if (preg_match($old_regex, $line['command'])) {
echo " removing cron entry\n";
//echo " removing cron entry\n";
$cron->ct->delEntry($id);
}
}
$cron->closeCrontab();
echo "Done.\n";
echo "done.\n";
//------------------------------------------------------------------------
// Delete files
//------------------------------------------------------------------------
camp_uninstall_delete_files($CC_CONFIG['storageDir']);
camp_uninstall_delete_files($CC_CONFIG['transDir']);
camp_uninstall_delete_files($CC_CONFIG['accessDir']);
if (camp_db_table_exists($CC_CONFIG['transTable'])) {
echo " * Removing database table ".$CC_CONFIG['transTable']."...";
$sql = "DROP TABLE ".$CC_CONFIG['transTable'];
camp_install_query($sql, false);
$CC_DBC->dropSequence($CC_CONFIG['transTable']."_id");
echo "done.\n";
} else {
echo " * Skipping: database table ".$CC_CONFIG['transTable']."\n";
}
if (camp_db_table_exists($CC_CONFIG['filesTable'])) {
echo " * Removing database table ".$CC_CONFIG['filesTable']."...";
$sql = "DROP TABLE ".$CC_CONFIG['filesTable']." CASCADE";
camp_install_query($sql);
$CC_DBC->dropSequence($CC_CONFIG['filesTable']."_id");
} else {
echo " * Skipping: database table ".$CC_CONFIG['filesTable']."\n";
}
if (camp_db_table_exists($CC_CONFIG['playListTable'])) {
echo " * Removing database table ".$CC_CONFIG['playListTable']."...";
$sql = "DROP TABLE ".$CC_CONFIG['playListTable']." CASCADE";
camp_install_query($sql);
$CC_DBC->dropSequence($CC_CONFIG['playListTable']."_id");
} else {
echo " * Skipping: database table ".$CC_CONFIG['playListTable']."\n";
}
if (camp_db_table_exists($CC_CONFIG['playListContentsTable'])) {
echo " * Removing database table ".$CC_CONFIG['playListContentsTable']."...";
$sql = "DROP TABLE ".$CC_CONFIG['playListContentsTable'];
camp_install_query($sql);
$CC_DBC->dropSequence($CC_CONFIG['playListContentsTable']."_id");
} else {
echo " * Skipping: database table ".$CC_CONFIG['playListContentsTable']."\n";
}
//if (camp_db_sequence_exists($CC_CONFIG['filesSequence'])) {
// $sql = "DROP SEQUENCE ".$CC_CONFIG['filesSequence'];
// camp_install_query($sql);
//------------------------------------------------------------------------
// Delete DB tables
//------------------------------------------------------------------------
//echo " * Deleting DB tables...\n";
//if (!PEAR::isError($CC_DBC)) {
// if (camp_db_table_exists($CC_CONFIG['prefTable'])) {
// echo " * Removing database table ".$CC_CONFIG['prefTable']."...";
// $sql = "DROP TABLE ".$CC_CONFIG['prefTable'];
// camp_install_query($sql, false);
//
// $CC_DBC->dropSequence($CC_CONFIG['prefTable']."_id");
// echo "done.\n";
// } else {
// echo " * Skipping: database table ".$CC_CONFIG['prefTable']."\n";
// }
//}
//
if (camp_db_table_exists($CC_CONFIG['accessTable'])) {
echo " * Removing database table ".$CC_CONFIG['accessTable']."...";
$sql = "DROP TABLE ".$CC_CONFIG['accessTable'];
camp_install_query($sql);
} else {
echo " * Skipping: database table ".$CC_CONFIG['accessTable']."\n";
}
if (camp_db_table_exists($CC_CONFIG['permTable'])) {
echo " * Removing database table ".$CC_CONFIG['permTable']."...";
$sql = "DROP TABLE ".$CC_CONFIG['permTable'];
camp_install_query($sql, false);
$CC_DBC->dropSequence($CC_CONFIG['permTable']."_id");
echo "done.\n";
} else {
echo " * Skipping: database table ".$CC_CONFIG['permTable']."\n";
}
if (camp_db_table_exists($CC_CONFIG['sessTable'])) {
echo " * Removing database table ".$CC_CONFIG['sessTable']."...";
$sql = "DROP TABLE ".$CC_CONFIG['sessTable'];
camp_install_query($sql);
} else {
echo " * Skipping: database table ".$CC_CONFIG['sessTable']."\n";
}
if (camp_db_table_exists($CC_CONFIG['subjTable'])) {
echo " * Removing database table ".$CC_CONFIG['subjTable']."...";
$CC_DBC->dropSequence($CC_CONFIG['subjTable']."_id");
$sql = "DROP TABLE ".$CC_CONFIG['subjTable']." CASCADE";
camp_install_query($sql, false);
echo "done.\n";
} else {
echo " * Skipping: database table ".$CC_CONFIG['subjTable']."\n";
}
if (camp_db_table_exists($CC_CONFIG['smembTable'])) {
echo " * Removing database table ".$CC_CONFIG['smembTable']."...";
$sql = "DROP TABLE ".$CC_CONFIG['smembTable'];
camp_install_query($sql, false);
$CC_DBC->dropSequence($CC_CONFIG['smembTable']."_id");
echo "done.\n";
} else {
echo " * Skipping: database table ".$CC_CONFIG['smembTable']."\n";
}
if (camp_db_table_exists($CC_CONFIG['scheduleTable'])) {
echo " * Removing database table ".$CC_CONFIG['scheduleTable']."...";
camp_install_query("DROP TABLE ".$CC_CONFIG['scheduleTable']);
} else {
echo " * Skipping: database table ".$CC_CONFIG['scheduleTable']."\n";
}
if (camp_db_table_exists($CC_CONFIG['backupTable'])) {
echo " * Removing database table ".$CC_CONFIG['backupTable']."...";
camp_install_query("DROP TABLE ".$CC_CONFIG['backupTable']);
} else {
echo " * Skipping: database table ".$CC_CONFIG['backupTable']."\n";
}
//if (camp_db_table_exists($CC_CONFIG['playlogTable'])) {
// echo " * Removing database table ".$CC_CONFIG['playlogTable']."...";
// $sql = "DROP TABLE ".$CC_CONFIG['playlogTable'];
//if (camp_db_table_exists($CC_CONFIG['transTable'])) {
// echo " * Removing database table ".$CC_CONFIG['transTable']."...";
// $sql = "DROP TABLE ".$CC_CONFIG['transTable'];
// camp_install_query($sql, false);
//
// $CC_DBC->dropSequence($CC_CONFIG['transTable']."_id");
// echo "done.\n";
//} else {
// echo " * Skipping: database table ".$CC_CONFIG['transTable']."\n";
//}
//
//if (camp_db_table_exists($CC_CONFIG['filesTable'])) {
// echo " * Removing database table ".$CC_CONFIG['filesTable']."...";
// $sql = "DROP TABLE ".$CC_CONFIG['filesTable']." CASCADE";
// camp_install_query($sql);
// $CC_DBC->dropSequence($CC_CONFIG['filesTable']."_id");
//
//} else {
// echo " * Skipping: database table ".$CC_CONFIG['filesTable']."\n";
//}
//
//if (camp_db_table_exists($CC_CONFIG['playListTable'])) {
// echo " * Removing database table ".$CC_CONFIG['playListTable']."...";
// $sql = "DROP TABLE ".$CC_CONFIG['playListTable']." CASCADE";
// camp_install_query($sql);
// $CC_DBC->dropSequence($CC_CONFIG['playListTable']."_id");
//
//} else {
// echo " * Skipping: database table ".$CC_CONFIG['playListTable']."\n";
//}
//
//if (camp_db_table_exists($CC_CONFIG['playListContentsTable'])) {
// echo " * Removing database table ".$CC_CONFIG['playListContentsTable']."...";
// $sql = "DROP TABLE ".$CC_CONFIG['playListContentsTable'];
// camp_install_query($sql);
// $CC_DBC->dropSequence($CC_CONFIG['playListContentsTable']."_id");
//
//} else {
// echo " * Skipping: database table ".$CC_CONFIG['playListContentsTable']."\n";
//}
//
////if (camp_db_sequence_exists($CC_CONFIG['filesSequence'])) {
//// $sql = "DROP SEQUENCE ".$CC_CONFIG['filesSequence'];
//// camp_install_query($sql);
////}
////
//if (camp_db_table_exists($CC_CONFIG['accessTable'])) {
// echo " * Removing database table ".$CC_CONFIG['accessTable']."...";
// $sql = "DROP TABLE ".$CC_CONFIG['accessTable'];
// camp_install_query($sql);
//} else {
// echo " * Skipping: database table ".$CC_CONFIG['playlogTable']."\n";
// echo " * Skipping: database table ".$CC_CONFIG['accessTable']."\n";
//}
//
//if (camp_db_table_exists($CC_CONFIG['permTable'])) {
// echo " * Removing database table ".$CC_CONFIG['permTable']."...";
// $sql = "DROP TABLE ".$CC_CONFIG['permTable'];
// camp_install_query($sql, false);
//
// $CC_DBC->dropSequence($CC_CONFIG['permTable']."_id");
// echo "done.\n";
//} else {
// echo " * Skipping: database table ".$CC_CONFIG['permTable']."\n";
//}
//
//if (camp_db_table_exists($CC_CONFIG['sessTable'])) {
// echo " * Removing database table ".$CC_CONFIG['sessTable']."...";
// $sql = "DROP TABLE ".$CC_CONFIG['sessTable'];
// camp_install_query($sql);
//} else {
// echo " * Skipping: database table ".$CC_CONFIG['sessTable']."\n";
//}
//
//if (camp_db_table_exists($CC_CONFIG['subjTable'])) {
// echo " * Removing database table ".$CC_CONFIG['subjTable']."...";
// $CC_DBC->dropSequence($CC_CONFIG['subjTable']."_id");
//
// $sql = "DROP TABLE ".$CC_CONFIG['subjTable']." CASCADE";
// camp_install_query($sql, false);
//
// echo "done.\n";
//} else {
// echo " * Skipping: database table ".$CC_CONFIG['subjTable']."\n";
//}
//
//if (camp_db_table_exists($CC_CONFIG['smembTable'])) {
// echo " * Removing database table ".$CC_CONFIG['smembTable']."...";
// $sql = "DROP TABLE ".$CC_CONFIG['smembTable'];
// camp_install_query($sql, false);
//
// $CC_DBC->dropSequence($CC_CONFIG['smembTable']."_id");
// echo "done.\n";
//} else {
// echo " * Skipping: database table ".$CC_CONFIG['smembTable']."\n";
//}
//
//if (camp_db_table_exists($CC_CONFIG['scheduleTable'])) {
// echo " * Removing database table ".$CC_CONFIG['scheduleTable']."...";
// camp_install_query("DROP TABLE ".$CC_CONFIG['scheduleTable']);
//} else {
// echo " * Skipping: database table ".$CC_CONFIG['scheduleTable']."\n";
//}
//
//if (camp_db_table_exists($CC_CONFIG['backupTable'])) {
// echo " * Removing database table ".$CC_CONFIG['backupTable']."...";
// camp_install_query("DROP TABLE ".$CC_CONFIG['backupTable']);
//} else {
// echo " * Skipping: database table ".$CC_CONFIG['backupTable']."\n";
//}
//------------------------------------------------------------------------
// Disconnect from the database
//------------------------------------------------------------------------
//echo " * Disconnecting from database...\n";
//$CC_DBC->disconnect();
//------------------------------------------------------------------------
// Delete the database
// Note: we do all the table-dropping above because this command usually fails
// because there are usually still connections to the database.
//------------------------------------------------------------------------
//echo " * Dropping the database ".$CC_CONFIG['dsn']['database']."...\n";
//$command = "sudo -u postgres dropdb {$CC_CONFIG['dsn']['database']}";
//@exec($command, $output, $results);
//if ($results == 0) {
// echo " * Database '{$CC_CONFIG['dsn']['database']}' deleted.\n";
//} else {
// echo " * Could not delete database '{$CC_CONFIG['dsn']['database']}'.\n";
//}
//------------------------------------------------------------------------
// Delete the user
//------------------------------------------------------------------------
echo " * Deleting database user '{$CC_CONFIG['dsn']['username']}'...\n";
$command = "sudo -u postgres psql postgres --command \"DROP USER {$CC_CONFIG['dsn']['username']}\" 2> /dev/null";
@exec($command, $output, $results);
if ($results == 0) {
echo " * User '{$CC_CONFIG['dsn']['username']}' deleted.\n";
} else {
echo " * Nothing to delete..\n";
}
echo "************************************\n";
echo "* StorageServer Uninstall Complete *\n";

View file

@ -1,135 +0,0 @@
#!/bin/bash
#-------------------------------------------------------------------------------
# Copyright (c) 2010 Sourcefabric O.P.S.
#
# This file is part of the Campcaster project.
# http://campcaster.campware.org/
# 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 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
scheduler_dir=${products_dir}/scheduler
scheduler_bindir=${scheduler_dir}/bin
usrdir=`cd $basedir/usr; pwd;`
#-------------------------------------------------------------------------------
# Print the usage information for this script.
#-------------------------------------------------------------------------------
printUsage()
{
echo "Campcaster 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 Campcaster user database";
echo "for user: $user.";
echo ""
#-------------------------------------------------------------------------------
# The details of installation
#-------------------------------------------------------------------------------
postgres_user=postgres
ls_database=Campcaster-$user
ls_dbuser=test
ls_dbpassword=test
ls_dbserver=localhost
#-------------------------------------------------------------------------------
# Create the necessary database user and database itself
#-------------------------------------------------------------------------------
${scheduler_bindir}/createDatabase.sh --database=${ls_database} \
--dbuser=${ls_dbuser} \
--dbpassword=${ls_dbpassword} \
--dbserver=${ls_dbserver}
#-------------------------------------------------------------------------------
# Create the ODBC data source and driver
#-------------------------------------------------------------------------------
${scheduler_bindir}/createOdbcDataSource.sh --database=${ls_database} \
--dbserver=${ls_dbserver}
#-------------------------------------------------------------------------------
# Say goodbye
#-------------------------------------------------------------------------------
echo "Done."