Better output when installing/uninstalling storage server. All media files and temp files are now deleted when you uninstall. Bug fix: the media files will still be deleted even if the database is gone. Bug fix: during storage server install, the storage server directories and all files must be created first before the are CHGRP and CHMOD.

This commit is contained in:
paul 2007-01-23 20:51:17 +00:00
parent 3f895d9ae3
commit 1e48e8c7da
9 changed files with 70 additions and 76 deletions

View File

@ -27,6 +27,7 @@ echo "*************************\n";
require_once('../conf.php'); require_once('../conf.php');
require_once('../../../storageServer/var/GreenBox.php'); require_once('../../../storageServer/var/GreenBox.php');
require_once('../../../storageServer/var/install/installInit.php'); require_once('../../../storageServer/var/install/installInit.php');
campcaster_db_connect();
require_once('../../../storageServer/var/install/installMain.php'); require_once('../../../storageServer/var/install/installMain.php');
echo "**********************************\n"; echo "**********************************\n";

View File

@ -26,6 +26,7 @@ echo "***************************\n";
require_once('../conf.php'); require_once('../conf.php');
require_once('../../../storageServer/var/install/installInit.php'); require_once('../../../storageServer/var/install/installInit.php');
campcaster_db_connect();
require_once('../../../storageServer/var/install/uninstallMain.php'); require_once('../../../storageServer/var/install/uninstallMain.php');
echo "************************************\n"; echo "************************************\n";

View File

@ -31,8 +31,8 @@
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
WWW_ROOT=`cd var/install; php -q getWwwRoot.php` || exit $? WWW_ROOT=`cd var/install; php -q getWwwRoot.php` || exit $?
echo "#StorageServer step 1:" echo " *** StorageServer bin/setupDirs.sh BEGIN"
echo "# root URL: $WWW_ROOT" echo " *** Root URL: $WWW_ROOT"
PHP_PWD=`bin/getUrl.sh $WWW_ROOT/install/getPwd.php` || \ PHP_PWD=`bin/getUrl.sh $WWW_ROOT/install/getPwd.php` || \
{ {
errno=$? errno=$?
@ -42,14 +42,14 @@ PHP_PWD=`bin/getUrl.sh $WWW_ROOT/install/getPwd.php` || \
fi fi
exit $errno exit $errno
} }
echo "# webspace mapping test:" echo " *** Webspace mapping test:"
echo "# mod_php : $PHP_PWD" echo " *** mod_php : $PHP_PWD"
INSTALL_DIR="$PWD/var/install" INSTALL_DIR="$PWD/var/install"
echo "# install : $INSTALL_DIR" echo " *** install : $INSTALL_DIR"
if [ $PHP_PWD == $INSTALL_DIR ]; then if [ $PHP_PWD == $INSTALL_DIR ]; then
echo "# mapping OK" echo " *** Mapping OK"
else else
echo "# WARNING: probably problem in webspace mapping !!!" echo " *** WARNING: there was a problem with webspace mapping!!!"
fi fi
HTTP_GROUP=`bin/getUrl.sh $WWW_ROOT/install/getGname.php` || \ HTTP_GROUP=`bin/getUrl.sh $WWW_ROOT/install/getGname.php` || \
@ -57,22 +57,22 @@ HTTP_GROUP=`bin/getUrl.sh $WWW_ROOT/install/getGname.php` || \
ERN=$?; ERN=$?;
echo $HTTP_GROUP; echo $HTTP_GROUP;
echo " -> Probably wrong setting in var/conf.php: URL configuration"; echo " -> Probably wrong setting in var/conf.php: URL configuration";
exit $ERN; exit $ERN;
} }
echo "# group running http daemon: $HTTP_GROUP" echo " *** The system group that is running the http daemon: '$HTTP_GROUP'"
for i in $* for i in $*
do do
echo "mkdir $i" echo " *** chown :$HTTP_GROUP $i"
mkdir -p $i || exit $?
chown :$HTTP_GROUP $i || \ chown :$HTTP_GROUP $i || \
{ {
ERN=$?; ERN=$?;
echo " -> You should have permissions to set group owner to group $HTTP_GROUP"; echo "ERROR: chown :$HTTP_GROUP $i -> You should have permissions to set group owner to group '$HTTP_GROUP'";
exit $ERN; exit $ERN;
} }
echo " *** chmod g+sw $i"
chmod g+sw $i || exit $? chmod g+sw $i || exit $?
done done
echo "# Directories setup finished OK" echo " *** StorageServer bin/setupDirs.sh END"
exit 0 exit 0

View File

@ -217,11 +217,11 @@ recheck: clean check
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# Specific targets # Specific targets
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
storage: dir_setup db_init storage: db_init dir_setup
storagecheck: storage testonly storagecheck: storage testonly
dir_setup: ${DOXYGEN_DIR} dir_setup:
bin/setupDirs.sh ${STOR_DIR} ${ACCESS_DIR} ${TRANS_DIR} ${BUFF_DIR} bin/setupDirs.sh ${STOR_DIR} ${ACCESS_DIR} ${TRANS_DIR} ${BUFF_DIR}
db_init: db_init:

View File

@ -29,6 +29,7 @@ echo "*************************\n";
require_once('../conf.php'); require_once('../conf.php');
require_once('../GreenBox.php'); require_once('../GreenBox.php');
require_once("installInit.php"); require_once("installInit.php");
campcaster_db_connect(true);
require_once('installMain.php'); require_once('installMain.php');
require_once('installStorage.php'); require_once('installStorage.php');

View File

@ -5,6 +5,7 @@ if (!function_exists('pg_connect')) {
} }
require_once('DB.php'); require_once('DB.php');
require_once('File/Find.php');
function camp_db_table_exists($p_name) function camp_db_table_exists($p_name)
{ {
@ -32,18 +33,22 @@ function camp_install_query($sql, $verbose = true)
} }
} }
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE); function campcaster_db_connect($p_exitOnError = true) {
if (PEAR::isError($CC_DBC)) { global $CC_DBC, $CC_CONFIG;
echo $CC_DBC->getMessage()."\n"; $CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
echo $CC_DBC->getUserInfo()."\n"; if (PEAR::isError($CC_DBC)) {
echo "Database connection problem.\n"; echo $CC_DBC->getMessage()."\n";
echo "Check if database '{$CC_CONFIG['dsn']['database']}' exists". echo $CC_DBC->getUserInfo()."\n";
" with corresponding permissions.\n"; echo "Database connection problem.\n";
exit(1); echo "Check if database '{$CC_CONFIG['dsn']['database']}' exists".
} else { " with corresponding permissions.\n";
echo " * Connected to database\n"; if ($p_exitOnError) {
exit(1);
}
} else {
echo " * Connected to database\n";
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
}
} }
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
?> ?>

View File

@ -287,7 +287,7 @@ if (!camp_db_table_exists($CC_CONFIG['filesTable'])) {
$sql = "CREATE INDEX ".$CC_CONFIG['filesTable']."_name_idx $sql = "CREATE INDEX ".$CC_CONFIG['filesTable']."_name_idx
ON ".$CC_CONFIG['filesTable']." (name)"; ON ".$CC_CONFIG['filesTable']." (name)";
camp_install_query($sql); camp_install_query($sql, false);
$sql = "CREATE INDEX ".$CC_CONFIG['filesTable']."_md5_idx $sql = "CREATE INDEX ".$CC_CONFIG['filesTable']."_md5_idx
ON ls_files (md5)"; ON ls_files (md5)";

View File

@ -25,8 +25,11 @@ echo "***************************\n";
require_once('../conf.php'); require_once('../conf.php');
require_once('installInit.php'); require_once('installInit.php');
campcaster_db_connect(false);
require_once('uninstallStorage.php'); require_once('uninstallStorage.php');
require_once('uninstallMain.php'); if (!PEAR::isError($CC_DBC)) {
require_once('uninstallMain.php');
}
echo "************************************\n"; echo "************************************\n";
echo "* StorageServer Uninstall Complete *\n"; echo "* StorageServer Uninstall Complete *\n";

View File

@ -18,55 +18,38 @@ if (isset($arr["DOCUMENT_ROOT"]) && ($arr["DOCUMENT_ROOT"] != "") ) {
exit; exit;
} }
function camp_uninstall_delete_files($p_path)
if (camp_db_table_exists($CC_CONFIG['prefTable'])) { {
echo " * Removing database table ".$CC_CONFIG['prefTable']."..."; if (!empty($p_path) && (strlen($p_path) > 4)) {
$sql = "DROP TABLE ".$CC_CONFIG['prefTable']; list($dirList,$fileList) = File_Find::maptree($p_path);
camp_install_query($sql, false); foreach ($fileList as $filepath) {
echo " * Removing $filepath...";
$CC_DBC->dropSequence($CC_CONFIG['prefTable']."_id_seq"); @unlink($filepath);
echo "done.\n"; echo "done.\n";
} else { }
echo " * Skipping: database table ".$CC_CONFIG['prefTable']."\n"; foreach ($dirList as $dirpath) {
} echo " * Removing $dirpath...";
@rmdir($dirpath);
echo "done.\n";
echo " * Removing all media files in ".$CC_CONFIG['storageDir']."...\n";
$d = @dir($CC_CONFIG['storageDir']);
while (is_object($d) && (false !== ($entry = $d->read()))){
if (filetype($CC_CONFIG['storageDir']."/$entry") == 'dir') {
if ( ($entry != 'CVS') && ($entry != 'tmp') && (strlen($entry)==3) ) {
$dd = dir($CC_CONFIG['storageDir']."/$entry");
while (false !== ($ee = $dd->read())) {
if (substr($ee, 0, 1) !== '.') {
$filename = $CC_CONFIG['storageDir']."/$entry/$ee";
echo " * Removing $filename...";
unlink($filename);
echo "done.\n";
}
}
$dd->close();
rmdir($CC_CONFIG['storageDir']."/$entry");
} }
} }
} }
if (is_object($d)) {
$d->close(); 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_seq");
echo "done.\n";
} else {
echo " * Skipping: database table ".$CC_CONFIG['prefTable']."\n";
}
} }
echo "done.\n";
//echo " * Removing all temporary files in ".$CC_CONFIG['bufferDir']."...";
//if (file_exists($CC_CONFIG['bufferDir'])) {
// $d = dir($CC_CONFIG['bufferDir']);
// while (false !== ($entry = $d->read())) {
// if (substr($entry, 0, 1) != '.') {
// unlink($CC_CONFIG['bufferDir']."/$entry");
// }
// }
// $d->close();
// @rmdir($this->bufferDir);
//}
//echo "done.\n";
camp_uninstall_delete_files($CC_CONFIG['storageDir']);
camp_uninstall_delete_files($CC_CONFIG['transDir']);
camp_uninstall_delete_files($CC_CONFIG['accessDir']);
?> ?>