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('../../../storageServer/var/GreenBox.php');
require_once('../../../storageServer/var/install/installInit.php');
campcaster_db_connect();
require_once('../../../storageServer/var/install/installMain.php');
echo "**********************************\n";

View File

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

View File

@ -31,8 +31,8 @@
#-------------------------------------------------------------------------------
WWW_ROOT=`cd var/install; php -q getWwwRoot.php` || exit $?
echo "#StorageServer step 1:"
echo "# root URL: $WWW_ROOT"
echo " *** StorageServer bin/setupDirs.sh BEGIN"
echo " *** Root URL: $WWW_ROOT"
PHP_PWD=`bin/getUrl.sh $WWW_ROOT/install/getPwd.php` || \
{
errno=$?
@ -42,14 +42,14 @@ PHP_PWD=`bin/getUrl.sh $WWW_ROOT/install/getPwd.php` || \
fi
exit $errno
}
echo "# webspace mapping test:"
echo "# mod_php : $PHP_PWD"
echo " *** Webspace mapping test:"
echo " *** mod_php : $PHP_PWD"
INSTALL_DIR="$PWD/var/install"
echo "# install : $INSTALL_DIR"
echo " *** install : $INSTALL_DIR"
if [ $PHP_PWD == $INSTALL_DIR ]; then
echo "# mapping OK"
echo " *** Mapping OK"
else
echo "# WARNING: probably problem in webspace mapping !!!"
echo " *** WARNING: there was a problem with webspace mapping!!!"
fi
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=$?;
echo $HTTP_GROUP;
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 $*
do
echo "mkdir $i"
mkdir -p $i || exit $?
echo " *** chown :$HTTP_GROUP $i"
chown :$HTTP_GROUP $i || \
{
{
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;
}
}
echo " *** chmod g+sw $i"
chmod g+sw $i || exit $?
done
echo "# Directories setup finished OK"
echo " *** StorageServer bin/setupDirs.sh END"
exit 0

View File

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

View File

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

View File

@ -5,6 +5,7 @@ if (!function_exists('pg_connect')) {
}
require_once('DB.php');
require_once('File/Find.php');
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);
if (PEAR::isError($CC_DBC)) {
echo $CC_DBC->getMessage()."\n";
echo $CC_DBC->getUserInfo()."\n";
echo "Database connection problem.\n";
echo "Check if database '{$CC_CONFIG['dsn']['database']}' exists".
" with corresponding permissions.\n";
exit(1);
} else {
echo " * Connected to database\n";
function campcaster_db_connect($p_exitOnError = true) {
global $CC_DBC, $CC_CONFIG;
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
if (PEAR::isError($CC_DBC)) {
echo $CC_DBC->getMessage()."\n";
echo $CC_DBC->getUserInfo()."\n";
echo "Database connection problem.\n";
echo "Check if database '{$CC_CONFIG['dsn']['database']}' exists".
" with corresponding permissions.\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
ON ".$CC_CONFIG['filesTable']." (name)";
camp_install_query($sql);
camp_install_query($sql, false);
$sql = "CREATE INDEX ".$CC_CONFIG['filesTable']."_md5_idx
ON ls_files (md5)";

View File

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

View File

@ -18,55 +18,38 @@ if (isset($arr["DOCUMENT_ROOT"]) && ($arr["DOCUMENT_ROOT"] != "") ) {
exit;
}
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 " * 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");
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 (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']);
?>