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:
parent
3f895d9ae3
commit
1e48e8c7da
9 changed files with 70 additions and 76 deletions
|
@ -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');
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
?>
|
|
@ -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)";
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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']);
|
||||
|
||||
?>
|
Loading…
Add table
Add a link
Reference in a new issue