From 73d672b552823a7a33a130819ab7f8dcc0e9ede0 Mon Sep 17 00:00:00 2001 From: "paul.baranowski" Date: Fri, 10 Sep 2010 14:37:02 -0400 Subject: [PATCH] Fixed installation errors found by Doug. Moved all database installation into one file (pulled stuff from scheduler and classes). Same with uninstallation. Removed ability to reset the storage through and XMLRPC call. This is very dangerous to allow. Disallowed remote execution of CleanStor.php. Changed database table prefix from "ls_" to "cc_". Removed all groups. --- bin/user_setup.sh | 16 - src/modules/storageServer/var/BasicStor.php | 136 +++-- src/modules/storageServer/var/CleanStor.php | 9 + src/modules/storageServer/var/Prefs.php | 54 -- src/modules/storageServer/var/StoredFile.php | 2 +- src/modules/storageServer/var/conf.php | 26 +- src/modules/storageServer/var/cron/Cron.php | 2 +- .../storageServer/var/cron/Crontab.php | 5 +- .../storageServer/var/install/install.php | 473 +++++++++++++++++- .../storageServer/var/install/installInit.php | 12 +- .../storageServer/var/install/installMain.php | 333 ------------ .../var/install/installStorage.php | 115 ----- .../storageServer/var/install/uninstall.php | 166 +++++- .../var/install/uninstallMain.php | 101 ---- .../var/install/uninstallStorage.php | 77 --- .../storageServer/var/xmlrpc/XR_LocStor.php | 34 +- .../var/xmlrpc/schedulerPhpClient.php | 14 +- .../storageServer/var/xmlrpc/xrLocStor.php | 2 +- .../storageServer/var/xmlrpc/xr_cli_test.php | 16 +- .../storageServer/var/xmlrpc/xr_web_test.php | 5 +- .../scheduler/bin/campcaster-scheduler.sh | 12 +- .../bin/campcaster-scheduler_devenv.sh | 12 +- src/products/scheduler/etc/Makefile.in | 20 - .../scheduler/var/install/install.php | 27 - .../scheduler/var/install/installInit.php | 80 --- .../var/install/installScheduler.php | 51 -- .../scheduler/var/install/uninstall.php | 24 - .../var/install/uninstallScheduler.php | 34 -- 28 files changed, 775 insertions(+), 1083 deletions(-) delete mode 100644 src/modules/storageServer/var/install/installMain.php delete mode 100644 src/modules/storageServer/var/install/installStorage.php delete mode 100644 src/modules/storageServer/var/install/uninstallMain.php delete mode 100644 src/modules/storageServer/var/install/uninstallStorage.php delete mode 100644 src/products/scheduler/var/install/install.php delete mode 100644 src/products/scheduler/var/install/installInit.php delete mode 100644 src/products/scheduler/var/install/installScheduler.php delete mode 100644 src/products/scheduler/var/install/uninstall.php delete mode 100644 src/products/scheduler/var/install/uninstallScheduler.php diff --git a/bin/user_setup.sh b/bin/user_setup.sh index 9db992565..e45c8cdc1 100755 --- a/bin/user_setup.sh +++ b/bin/user_setup.sh @@ -316,22 +316,6 @@ echo "Setting up storageServer..." make -C $modules_dir/storageServer storage || exit 1 -#------------------------------------------------------------------------------- -# Setup the database tables for the scheduler -#------------------------------------------------------------------------------- -echo "Setting up database tables for the scheduler..." - -make -C $products_dir/scheduler init || exit 1 - - -#------------------------------------------------------------------------------- -# Add "scheduler" user -#------------------------------------------------------------------------------- -echo "Adding the 'scheduler' user..." - -php $modules_dir/storageServer/var/install/campcaster-user.php --addupdate scheduler $scheduler_storage_pass - - #------------------------------------------------------------------------------- # Setup directory permissions #------------------------------------------------------------------------------- diff --git a/src/modules/storageServer/var/BasicStor.php b/src/modules/storageServer/var/BasicStor.php index 2c1daad33..d55b47085 100644 --- a/src/modules/storageServer/var/BasicStor.php +++ b/src/modules/storageServer/var/BasicStor.php @@ -1381,20 +1381,18 @@ class BasicStor { return $uid; } if (Subjects::IsGroup($uid) === FALSE) { - $res = Alib::AddPerm($uid, '_all', $fid, 'A'); + $res = Alib::AddPerm($uid, '_all', '0', 'A'); if (PEAR::isError($res)) { return $res; } - if (!$CC_CONFIG['isArchive']) { - $res = Subjects::AddSubjectToGroup($login, $CC_CONFIG['StationPrefsGr']); - if (PEAR::isError($res)) { - return $res; - } - $res = Subjects::AddSubjectToGroup($login, $CC_CONFIG['AllGr']); - if (PEAR::isError($res)) { - return $res; - } - } +// $res = Subjects::AddSubjectToGroup($login, $CC_CONFIG['StationPrefsGr']); +// if (PEAR::isError($res)) { +// return $res; +// } +// $res = Subjects::AddSubjectToGroup($login, $CC_CONFIG['AllGr']); +// if (PEAR::isError($res)) { +// return $res; +// } } return $uid; } @@ -1764,10 +1762,8 @@ class BasicStor { } else { $this->deleteData(); } - if (!$CC_CONFIG['isArchive']) { - $tr = new Transport($this); - $tr->resetData(); - } + $tr = new Transport($this); + $tr->resetData(); $res = array('cnt'=>0, 'results'=>array()); if (!$loadSampleData) { return $res; @@ -1892,57 +1888,57 @@ class BasicStor { { global $CC_CONFIG; // Create the Admin group - if (!empty($CC_CONFIG['AdminsGr'])) { - if (!Subjects::GetSubjId($CC_CONFIG['AdminsGr'])) { - echo " * Creating group '".$CC_CONFIG['AdminsGr']."'..."; - // Add the admin group - $admid = Subjects::AddSubj($CC_CONFIG['AdminsGr']); - if (PEAR::isError($admid)) { - return $admid; - } - - // Add the "all" permission to the "admin" group - $res = Alib::AddPerm($admid, '_all', $this->rootId, 'A'); - if (PEAR::isError($res)) { - return $res; - } - echo "done.\n"; - } else { - echo " * Skipping: group already exists: '".$CC_CONFIG['AdminsGr']."'\n"; - } - } +// if (!empty($CC_CONFIG['AdminsGr'])) { +// if (!Subjects::GetSubjId($CC_CONFIG['AdminsGr'])) { +// echo " * Creating group '".$CC_CONFIG['AdminsGr']."'..."; +// // Add the admin group +// $admid = Subjects::AddSubj($CC_CONFIG['AdminsGr']); +// if (PEAR::isError($admid)) { +// return $admid; +// } +// +// // Add the "all" permission to the "admin" group +// $res = Alib::AddPerm($admid, '_all', $this->storId, 'A'); +// if (PEAR::isError($res)) { +// return $res; +// } +// echo "done.\n"; +// } else { +// echo " * Skipping: group already exists: '".$CC_CONFIG['AdminsGr']."'\n"; +// } +// } // Add the "all" group - if (!empty($CC_CONFIG['AllGr'])) { - if (!Subjects::GetSubjId($CC_CONFIG['AllGr'])) { - echo " * Creating group '".$CC_CONFIG['AllGr']."'..."; - $allid = Subjects::AddSubj($CC_CONFIG['AllGr']); - if (PEAR::isError($allid)) { - return $allid; - } - - // Add the "read" permission to the "all" group. - Alib::AddPerm($allid, 'read', $this->rootId, 'A'); - echo "done.\n"; - } else { - echo " * Skipping: group already exists: '".$CC_CONFIG['AllGr']."'\n"; - } - } +// if (!empty($CC_CONFIG['AllGr'])) { +// if (!Subjects::GetSubjId($CC_CONFIG['AllGr'])) { +// echo " * Creating group '".$CC_CONFIG['AllGr']."'..."; +// $allid = Subjects::AddSubj($CC_CONFIG['AllGr']); +// if (PEAR::isError($allid)) { +// return $allid; +// } +// +// // Add the "read" permission to the "all" group. +// Alib::AddPerm($allid, 'read', $this->storId, 'A'); +// echo "done.\n"; +// } else { +// echo " * Skipping: group already exists: '".$CC_CONFIG['AllGr']."'\n"; +// } +// } // Add the "Station Preferences" group - if (!empty($CC_CONFIG['StationPrefsGr'])) { - if (!Subjects::GetSubjId('scheduler')) { - echo " * Creating group '".$CC_CONFIG['StationPrefsGr']."'..."; - $stPrefGr = Subjects::AddSubj($CC_CONFIG['StationPrefsGr']); - if (PEAR::isError($stPrefGr)) { - return $stPrefGr; - } - Subjects::AddSubjectToGroup('root', $CC_CONFIG['StationPrefsGr']); - echo "done.\n"; - } else { - echo " * Skipping: group already exists: '".$CC_CONFIG['StationPrefsGr']."'\n"; - } - } +// if (!empty($CC_CONFIG['StationPrefsGr'])) { +// if (!Subjects::GetSubjId('scheduler')) { +// echo " * Creating group '".$CC_CONFIG['StationPrefsGr']."'..."; +// $stPrefGr = Subjects::AddSubj($CC_CONFIG['StationPrefsGr']); +// if (PEAR::isError($stPrefGr)) { +// return $stPrefGr; +// } +// Subjects::AddSubjectToGroup('root', $CC_CONFIG['StationPrefsGr']); +// echo "done.\n"; +// } else { +// echo " * Skipping: group already exists: '".$CC_CONFIG['StationPrefsGr']."'\n"; +// } +// } // Add the root user if it doesnt exist yet. $rootUid = Subjects::GetSubjId('root'); @@ -1954,10 +1950,10 @@ class BasicStor { } // Add root user to the admin group - $r = Subjects::AddSubjectToGroup('root', $CC_CONFIG['AdminsGr']); - if (PEAR::isError($r)) { - return $r; - } +// $r = Subjects::AddSubjectToGroup('root', $CC_CONFIG['AdminsGr']); +// if (PEAR::isError($r)) { +// return $r; +// } echo "done.\n"; } else { echo " * Skipping: user already exists: 'root'\n"; @@ -1966,19 +1962,19 @@ class BasicStor { // Create the user named 'scheduler'. if (!Subjects::GetSubjId('scheduler')) { echo " * Creating user 'scheduler'..."; - Subjects::AddSubj('scheduler', $CC_CONFIG['schedulerPass']); - $res = Alib::AddPerm($rootUid, 'read', $this->rootId, 'A'); + $subid = Subjects::AddSubj('scheduler', $CC_CONFIG['schedulerPass']); + $res = Alib::AddPerm($subid, 'read', '0', 'A'); if (PEAR::isError($res)) { return $res; } - $r = Subjects::AddSubjectToGroup('scheduler', $CC_CONFIG['AllGr']); + //$r = Subjects::AddSubjectToGroup('scheduler', $CC_CONFIG['AllGr']); echo "done.\n"; } else { echo " * Skipping: user already exists: 'scheduler'\n"; } // Need to add 'scheduler' to group StationPrefs - Subjects::AddSubjectToGroup('scheduler', $CC_CONFIG['StationPrefsGr']); + //Subjects::AddSubjectToGroup('scheduler', $CC_CONFIG['StationPrefsGr']); } diff --git a/src/modules/storageServer/var/CleanStor.php b/src/modules/storageServer/var/CleanStor.php index 92a024f0e..341aa6c6e 100644 --- a/src/modules/storageServer/var/CleanStor.php +++ b/src/modules/storageServer/var/CleanStor.php @@ -1,5 +1,14 @@ createSequence("{$this->prefTable}_id_seq"); -// $r = $CC_DBC->query("CREATE TABLE {$this->prefTable} ( -// id int not null, -// subjid int REFERENCES ".$CC_CONFIG['subjTable']." ON DELETE CASCADE, -// keystr varchar(255), -// valstr text -// )"); -// if (PEAR::isError($r)) { -// return $r; -// } -// $CC_DBC->query("CREATE UNIQUE INDEX {$this->prefTable}_id_idx -// ON {$this->prefTable} (id)"); -// $CC_DBC->query("CREATE UNIQUE INDEX {$this->prefTable}_subj_key_idx -// ON {$this->prefTable} (subjid, keystr)"); -// $CC_DBC->query("CREATE INDEX {$this->prefTable}_subjid_idx -// ON {$this->prefTable} (subjid)"); -// $stPrefGr = Subjects::GetSubjId($CC_CONFIG['StationPrefsGr']); -// if (PEAR::isError($stPrefGr)) { -// echo $stPrefGr->getMessage()."\n"; -// } -// $r = Prefs::Insert($stPrefGr, 'stationName', "Radio Station 1"); -// if (PEAR::isError($r)) { -// echo $r->getMessage()."\n"; -// } -// $genres = file_get_contents(dirname(__FILE__).'/../genres.xml'); -// $r = Prefs::Insert($stPrefGr, 'genres', $genres); -// if (PEAR::isError($r)) { -// echo $r->getMessage()."\n"; -// } -// return TRUE; -// } - - - /** - * Uninstall database table for preference storage - * - * @return boolean - */ -// function uninstall() -// { -// global $CC_CONFIG, $CC_DBC; -// $CC_DBC->query("DROP TABLE {$this->prefTable}"); -// $CC_DBC->dropSequence("{$this->prefTable}_id_seq"); -// } - } // class Prefs ?> \ No newline at end of file diff --git a/src/modules/storageServer/var/StoredFile.php b/src/modules/storageServer/var/StoredFile.php index dffb38987..a2ee340ea 100644 --- a/src/modules/storageServer/var/StoredFile.php +++ b/src/modules/storageServer/var/StoredFile.php @@ -458,7 +458,7 @@ class StoredFile { if (!is_integer($storedFile->id)) { // NOTE: POSTGRES-SPECIFIC - $sql = "SELECT currval('file_id_seq')"; + $sql = "SELECT currval('".$CC_CONFIG["filesSequence"]."')"; $storedFile->id = $CC_DBC->getOne($sql); } // Insert metadata diff --git a/src/modules/storageServer/var/conf.php b/src/modules/storageServer/var/conf.php index 2182911fd..8e31d59a3 100644 --- a/src/modules/storageServer/var/conf.php +++ b/src/modules/storageServer/var/conf.php @@ -15,7 +15,6 @@ *
bufferDir
directory for temporary files *
transDir
directory for incomplete transferred files *
accessDir
directory for symlinks to accessed files - *
isArchive
local/central flag *
validate
enable/disable validator *
useTrash
enable/disable safe delete (move to trash) *
storageUrlPath
path-URL-part of storageServer base dir @@ -44,20 +43,20 @@ $CC_CONFIG = array( 'phptype' => 'pgsql', 'database' => 'Campcaster-paul', ), - 'tblNamePrefix' => 'ls_', + 'tblNamePrefix' => 'cc_', /* ================================================ storage configuration */ 'authCookieName'=> 'campcaster_session_id', - 'AdminsGr' => 'Admins', - 'StationPrefsGr'=> 'StationPrefs', - 'AllGr' => 'All', + //'AdminsGr' => 'Admins', + //'StationPrefsGr'=> 'StationPrefs', + //'AllGr' => 'All', 'TrashName' => 'trash_', 'storageDir' => dirname(__FILE__).'/../../storageServer/var/stor', 'bufferDir' => dirname(__FILE__).'/../../storageServer/var/stor/buffer', 'transDir' => dirname(__FILE__).'/../../storageServer/var/trans', 'accessDir' => dirname(__FILE__).'/../../storageServer/var/access', 'pearPath' => dirname(__FILE__).'/../../../../usr/lib/pear', +// 'zendPath' => dirname(__FILE__).'/../../../../usr/lib', 'cronDir' => dirname(__FILE__).'/../../storageServer/var/cron', - 'isArchive' => FALSE, 'validate' => TRUE, 'useTrash' => TRUE, @@ -71,6 +70,7 @@ $CC_CONFIG = array( 'archiveUrlPath' => '/campcasterStorageServer', 'archiveXMLRPC' => 'xmlrpc/xrLocStor.php', 'archiveUrlHost' => 'localhost', +// 'archiveUrlHost' => '192.168.30.166', 'archiveUrlPort' => 80, 'archiveAccountLogin' => 'root', 'archiveAccountPass' => 'q', @@ -110,6 +110,7 @@ $CC_CONFIG = array( 'lockfile' => dirname(__FILE__).'/../../storageServer/var/stor/buffer/cron.lock', 'cronfile' => dirname(__FILE__).'/cron/croncall.php', 'paramdir' => dirname(__FILE__).'/cron/params', + 'systemPrefId' => "0", // ID for system prefs in prefs table ); // Add database table names @@ -122,15 +123,16 @@ $CC_CONFIG['subjTable'] = $CC_CONFIG['tblNamePrefix'].'subjs'; $CC_CONFIG['smembTable'] = $CC_CONFIG['tblNamePrefix'].'smemb'; $CC_CONFIG['transTable'] = $CC_CONFIG['tblNamePrefix'].'trans'; $CC_CONFIG['prefTable'] = $CC_CONFIG['tblNamePrefix'].'pref'; -$CC_CONFIG['playlogTable'] = 'playlog'; -$CC_CONFIG['scheduleTable'] = 'schedule'; -$CC_CONFIG['backupTable'] = 'backup'; +$CC_CONFIG['playlogTable'] = $CC_CONFIG['tblNamePrefix'].'playlog'; +$CC_CONFIG['scheduleTable'] = $CC_CONFIG['tblNamePrefix'].'schedule'; +$CC_CONFIG['backupTable'] = $CC_CONFIG['tblNamePrefix'].'backup'; +$CC_CONFIG['filesSequence'] = $CC_CONFIG['tblNamePrefix']."file_id_seq"; $CC_CONFIG['sysSubjs'] = array( - 'root', $CC_CONFIG['AdminsGr'], $CC_CONFIG['AllGr'], $CC_CONFIG['StationPrefsGr'] + 'root', /*$CC_CONFIG['AdminsGr'],*/ /*$CC_CONFIG['AllGr'],*/ /*$CC_CONFIG['StationPrefsGr']*/ ); -$old_ip = get_include_path(); -set_include_path('.'.PATH_SEPARATOR.$CC_CONFIG['pearPath'].PATH_SEPARATOR.$old_ip); +$old_include_path = get_include_path(); +set_include_path('.'.PATH_SEPARATOR.$CC_CONFIG['pearPath'].PATH_SEPARATOR.$old_include_path); // see if a ~/.campcaster/storageServer.conf.php exists, and // overwrite the settings from there if any diff --git a/src/modules/storageServer/var/cron/Cron.php b/src/modules/storageServer/var/cron/Cron.php index cef4f0592..c9b940552 100755 --- a/src/modules/storageServer/var/cron/Cron.php +++ b/src/modules/storageServer/var/cron/Cron.php @@ -164,7 +164,7 @@ class Cron { */ function lockCrontab() { - return touch($this->lockfile); + return @touch($this->lockfile); } /** diff --git a/src/modules/storageServer/var/cron/Crontab.php b/src/modules/storageServer/var/cron/Crontab.php index e9c5fcd3a..92b40ac38 100755 --- a/src/modules/storageServer/var/cron/Crontab.php +++ b/src/modules/storageServer/var/cron/Crontab.php @@ -111,7 +111,7 @@ class Crontab // It's a regular crontab-entry $ct = split("[ \t]", $line, 6); - $this->addCron($ct[0], $ct[1], $ct[2], $ct[3], $ct[4], $ct[5], $ct[6]); + $this->addCron($ct[0], $ct[1], $ct[2], $ct[3], $ct[4], $ct[5]); } } @@ -122,6 +122,9 @@ class Crontab { global $DEBUG, $PATH; + if (empty($this->linetypes)) { + return; + } $filename = ($DEBUG ? tempnam("$PATH/crons", "cron") : tempnam("/tmp", "cron")); $file = fopen($filename, "w"); diff --git a/src/modules/storageServer/var/install/install.php b/src/modules/storageServer/var/install/install.php index 702f95733..d4c5ef3a9 100644 --- a/src/modules/storageServer/var/install/install.php +++ b/src/modules/storageServer/var/install/install.php @@ -5,11 +5,10 @@ * @copyright 2010 Sourcefabric O.P.S. * @license http://www.gnu.org/licenses/gpl.txt * - * Note: This file was broken into two parts: install.php and - * installMain.php so that the archive server could use the same - * installation script, but with just a different config file. */ +$WHITE_SCREEN_OF_DEATH = false; + // Do not allow remote execution $arr = array_diff_assoc($_SERVER, $_ENV); if (isset($arr["DOCUMENT_ROOT"]) && ($arr["DOCUMENT_ROOT"] != "") ) { @@ -27,8 +26,472 @@ require_once('../conf.php'); require_once('../GreenBox.php'); require_once("installInit.php"); campcaster_db_connect(true); -require_once('installMain.php'); -require_once('installStorage.php'); + +//------------------------------------------------------------------------------ +// Install database tables +//------------------------------------------------------------------------------ +if (!camp_db_table_exists($CC_CONFIG['subjTable'])) { + echo " * Creating database table ".$CC_CONFIG['subjTable']."..."; + $sql = "CREATE TABLE ".$CC_CONFIG['subjTable']." ( + id int not null PRIMARY KEY, + login varchar(255) not null default'', + pass varchar(255) not null default'', + type char(1) not null default 'U', + realname varchar(255) not null default'', + lastlogin timestamp, + lastfail timestamp + )"; + camp_install_query($sql, false); + + $sql = "CREATE UNIQUE INDEX ".$CC_CONFIG['subjTable']."_id_idx + ON ".$CC_CONFIG['subjTable']." (id)"; + camp_install_query($sql, false); + + $sql = "CREATE UNIQUE INDEX ".$CC_CONFIG['subjTable']."_login_idx + ON ".$CC_CONFIG['subjTable']." (login)"; + camp_install_query($sql, false); + + $CC_DBC->createSequence($CC_CONFIG['subjTable']."_id_seq"); + echo "done.\n"; +} else { + echo " * Skipping: database table already exists: ".$CC_CONFIG['subjTable']."\n"; +} + +if (!camp_db_table_exists($CC_CONFIG['smembTable'])) { + echo " * Creating database table ".$CC_CONFIG['smembTable']."..."; + $sql = "CREATE TABLE ".$CC_CONFIG['smembTable']." ( + id int not null PRIMARY KEY, + uid int not null default 0, + gid int not null default 0, + level int not null default 0, + mid int)"; + camp_install_query($sql, false); + + $sql = "CREATE UNIQUE INDEX ".$CC_CONFIG['smembTable']."_id_idx + ON ".$CC_CONFIG['smembTable']." (id)"; + camp_install_query($sql, false); + + $CC_DBC->createSequence($CC_CONFIG['smembTable']."_id_seq"); + echo "done.\n"; +} else { + echo " * Skipping: database table already exists: ".$CC_CONFIG['smembTable']."\n"; +} + +if (!camp_db_table_exists($CC_CONFIG['permTable'])) { + echo " * Creating database table ".$CC_CONFIG['permTable']."..."; + $sql = "CREATE TABLE ".$CC_CONFIG['permTable']." ( + permid int not null PRIMARY KEY, + subj int REFERENCES ".$CC_CONFIG['subjTable']." ON DELETE CASCADE, + action varchar(20), + obj int, + type char(1))"; + camp_install_query($sql, false); + + $sql = "CREATE UNIQUE INDEX ".$CC_CONFIG['permTable']."_permid_idx + ON ".$CC_CONFIG['permTable']." (permid)"; + camp_install_query($sql, false); + + $sql = "CREATE INDEX ".$CC_CONFIG['permTable']."_subj_obj_idx + ON ".$CC_CONFIG['permTable']." (subj, obj)"; + camp_install_query($sql, false); + + $sql = "CREATE UNIQUE INDEX ".$CC_CONFIG['permTable']."_all_idx + ON ".$CC_CONFIG['permTable']." (subj, action, obj)"; + camp_install_query($sql, false); + + $CC_DBC->createSequence($CC_CONFIG['permTable']."_id_seq"); + echo "done.\n"; +} else { + echo " * Skipping: database table already exists: ".$CC_CONFIG['permTable']."\n"; +} + +if (!camp_db_table_exists($CC_CONFIG['sessTable'])) { + echo " * Creating database table ".$CC_CONFIG['sessTable']."..."; + $sql = "CREATE TABLE ".$CC_CONFIG['sessTable']." ( + sessid char(32) not null PRIMARY KEY, + userid int REFERENCES ".$CC_CONFIG['subjTable']." ON DELETE CASCADE, + login varchar(255), + ts timestamp)"; + camp_install_query($sql, false); + + $sql = "CREATE UNIQUE INDEX ".$CC_CONFIG['sessTable']."_sessid_idx + ON ".$CC_CONFIG['sessTable']." (sessid)"; + camp_install_query($sql, false); + + $sql = "CREATE INDEX ".$CC_CONFIG['sessTable']."_userid_idx + ON ".$CC_CONFIG['sessTable']." (userid)"; + camp_install_query($sql, false); + + $sql = "CREATE INDEX ".$CC_CONFIG['sessTable']."_login_idx + ON ".$CC_CONFIG['sessTable']." (login)"; + camp_install_query($sql); +} else { + echo " * Skipping: database table already exists: ".$CC_CONFIG['sessTable']."\n"; +} + +/** + * file states: + * + * file types: + * + * access types: + * + */ +if (!camp_db_table_exists($CC_CONFIG['filesTable'])) { + echo " * Creating database table ".$CC_CONFIG['filesTable']."..."; + $sql = "CREATE TABLE ".$CC_CONFIG['filesTable']." ( + id int not null, + gunid bigint not null, -- global unique ID + name varchar(255) not null default'', -- human file id ;) + mime varchar(255) not null default'', -- mime type + ftype varchar(128) not null default'', -- file type + state varchar(128) not null default'empty', -- file state + currentlyaccessing int not null default 0, -- access counter + editedby int REFERENCES ".$CC_CONFIG['subjTable'].", -- who edits it + mtime timestamp(6) with time zone, -- lst modif.time + md5 char(32) + )"; + camp_install_query($sql, false); + + $sql = "CREATE UNIQUE INDEX ".$CC_CONFIG['filesTable']."_id_idx + ON ".$CC_CONFIG['filesTable']." (id)"; + camp_install_query($sql, false); + + $sql = "CREATE UNIQUE INDEX ".$CC_CONFIG['filesTable']."_gunid_idx + ON ".$CC_CONFIG['filesTable']." (gunid)"; + camp_install_query($sql, false); + + $sql = "CREATE INDEX ".$CC_CONFIG['filesTable']."_name_idx + ON ".$CC_CONFIG['filesTable']." (name)"; + camp_install_query($sql, false); + + $sql = "CREATE INDEX ".$CC_CONFIG['filesTable']."_md5_idx + ON ".$CC_CONFIG['filesTable']." (md5)"; + camp_install_query($sql); + +} else { + echo " * Skipping: database table already exists: ".$CC_CONFIG['filesTable']."\n"; +} + +if (!camp_db_sequence_exists($CC_CONFIG["filesSequence"])) { + echo " * Creating database sequence ".$CC_CONFIG['filesSequence']."..."; + $sql = "CREATE SEQUENCE ".$CC_CONFIG["filesSequence"] + ." INCREMENT 1 + MINVALUE 1 + MAXVALUE 9223372036854775807 + START 1000000 + CACHE 1"; + camp_install_query($sql); +} else { + echo " * Skipping: database sequence already exists: ".$CC_CONFIG['filesSequence']."\n"; +} + +/** + * id subjns subject predns predicate objns object + * y1 literal xmbf NULL namespace literal http://www.sotf.org/xbmf + * x1 gunid xbmf contributor NULL NULL + * x2 mdid x1 xbmf role literal Editor + * + * predefined shortcuts: + * _L = literal + * _G = gunid (global id of media file) + * _I = mdid (local id of metadata record) + * _nssshortcut = namespace shortcut definition + * _blank = blank node + */ +if (!camp_db_table_exists($CC_CONFIG['mdataTable'])) { + echo " * Creating database table ".$CC_CONFIG['mdataTable']."..."; + $CC_DBC->createSequence($CC_CONFIG['mdataTable']."_id_seq"); + $sql = "CREATE TABLE ".$CC_CONFIG['mdataTable']." ( + id int not null, + gunid bigint, + subjns varchar(255), -- subject namespace shortcut/uri + subject varchar(255) not null default '', + predns varchar(255), -- predicate namespace shortcut/uri + predicate varchar(255) not null, + predxml char(1) not null default 'T', -- Tag or Attribute + objns varchar(255), -- object namespace shortcut/uri + object text + )"; + camp_install_query($sql, false); + + $sql = "CREATE UNIQUE INDEX ".$CC_CONFIG['mdataTable']."_id_idx + ON ".$CC_CONFIG['mdataTable']." (id)"; + camp_install_query($sql, false); + + $sql = "CREATE INDEX ".$CC_CONFIG['mdataTable']."_gunid_idx + ON ".$CC_CONFIG['mdataTable']." (gunid)"; + camp_install_query($sql, false); + + $sql = "CREATE INDEX ".$CC_CONFIG['mdataTable']."_subj_idx + ON ".$CC_CONFIG['mdataTable']." (subjns, subject)"; + camp_install_query($sql, false); + + $sql = "CREATE INDEX ".$CC_CONFIG['mdataTable']."_pred_idx + ON ".$CC_CONFIG['mdataTable']." (predns, predicate)"; + camp_install_query($sql); +} else { + echo " * Skipping: database table already exists: ".$CC_CONFIG['mdataTable']."\n"; +} + +if (!camp_db_table_exists($CC_CONFIG['accessTable'])) { + echo " * Creating database table ".$CC_CONFIG['accessTable']."..."; + $sql = "CREATE TABLE ".$CC_CONFIG['accessTable']." ( + gunid bigint, -- global unique id + token bigint, -- access token + chsum char(32) not null default'', -- md5 checksum + ext varchar(128) not null default'', -- extension + type varchar(20) not null default'', -- access type + parent bigint, -- parent token + owner int REFERENCES ".$CC_CONFIG['subjTable'].", -- subject have started it + ts timestamp + )"; + camp_install_query($sql, false); + + $sql = "CREATE INDEX ".$CC_CONFIG['accessTable']."_token_idx + ON ".$CC_CONFIG['accessTable']." (token)"; + camp_install_query($sql, false); + + $sql = "CREATE INDEX ".$CC_CONFIG['accessTable']."_gunid_idx + ON ".$CC_CONFIG['accessTable']." (gunid)"; + camp_install_query($sql, false); + + $sql = "CREATE INDEX ".$CC_CONFIG['accessTable']."_parent_idx + ON ".$CC_CONFIG['accessTable']." (parent)"; + camp_install_query($sql); +} else { + 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']." ( + id int not null, -- primary key + trtok char(16) not null, -- transport token + direction varchar(128) not null, -- direction: up|down + state varchar(128) not null, -- state + trtype varchar(128) not null, -- transport type + lock char(1) not null default 'N',-- running lock + target varchar(255) default NULL, -- target system, + -- if NULL => predefined set + rtrtok char(16) default NULL, -- remote hub's transport token + mdtrtok char(16), -- metadata transport token + gunid bigint, -- global unique id + pdtoken bigint, -- put/download token from archive + url varchar(255), -- url on remote side + localfile varchar(255), -- pathname of local part + fname varchar(255), -- mnemonic filename + title varchar(255), -- dc:title mdata value (or filename ...) + expectedsum char(32), -- expected file checksum + realsum char(32), -- checksum of transported part + expectedsize int, -- expected filesize in bytes + realsize int, -- filesize of transported part + uid int, -- local user id of transport owner + errmsg varchar(255), -- error message string for failed tr. + jobpid int, -- pid of transport job + start timestamp, -- starttime + ts timestamp -- mtime + )"; + camp_install_query($sql, false); + + $CC_DBC->createSequence($CC_CONFIG['transTable']."_id_seq"); + $sql = "CREATE UNIQUE INDEX ".$CC_CONFIG['transTable']."_id_idx + ON ".$CC_CONFIG['transTable']." (id)"; + camp_install_query($sql, false); + + $sql = "CREATE UNIQUE INDEX ".$CC_CONFIG['transTable']."_trtok_idx + ON ".$CC_CONFIG['transTable']." (trtok)"; + camp_install_query($sql, false); + + $sql = "CREATE UNIQUE INDEX ".$CC_CONFIG['transTable']."_token_idx + ON ".$CC_CONFIG['transTable']." (pdtoken)"; + camp_install_query($sql, false); + + $sql = "CREATE INDEX ".$CC_CONFIG['transTable']."_gunid_idx + ON ".$CC_CONFIG['transTable']." (gunid)"; + camp_install_query($sql, false); + + $sql = "CREATE INDEX ".$CC_CONFIG['transTable']."_state_idx + ON ".$CC_CONFIG['transTable']." (state)"; + camp_install_query($sql); +} else { + echo " * Skipping: database table already exists: ".$CC_CONFIG['transTable']."\n"; +} + +/** + * Scheduler tables. + */ +if (!camp_db_table_exists($CC_CONFIG['scheduleTable'])) { + echo " * Creating database table ".$CC_CONFIG['scheduleTable']."..."; + $sql = "CREATE TABLE ".$CC_CONFIG['scheduleTable']."(" + ." id BIGINT NOT NULL," + ." playlist BIGINT NOT NULL," + ." starts TIMESTAMP NOT NULL," + ." ends TIMESTAMP NOT NULL," + ." PRIMARY KEY(id))"; + camp_install_query($sql); +} else { + echo " * Skipping: database table already exists: ".$CC_CONFIG['scheduleTable']."\n"; +} + + +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']." (" + ." token VARCHAR(64) NOT NULL," + ." sessionId VARCHAR(64) NOT NULL," + ." status VARCHAR(32) NOT NULL," + ." fromTime TIMESTAMP NOT NULL," + ." toTime TIMESTAMP NOT NULL," + ." PRIMARY KEY(token))"; + camp_install_query($sql); +} else { + echo " * Skipping: database table already exists: ".$CC_CONFIG['backupTable']."\n"; +} + +if (!camp_db_table_exists($CC_CONFIG['prefTable'])) { + echo " * Creating database table ".$CC_CONFIG['prefTable']."..."; + $CC_DBC->createSequence($CC_CONFIG['prefTable']."_id_seq"); + $sql = "CREATE TABLE ".$CC_CONFIG['prefTable']." ( + id int not null, + subjid int REFERENCES ".$CC_CONFIG['subjTable']." ON DELETE CASCADE, + keystr varchar(255), + valstr text + )"; + camp_install_query($sql, false); + + $sql = "CREATE UNIQUE INDEX ".$CC_CONFIG['prefTable']."_id_idx + ON ".$CC_CONFIG['prefTable']." (id)"; + camp_install_query($sql, false); + + $sql = "CREATE UNIQUE INDEX ".$CC_CONFIG['prefTable']."_subj_key_idx + ON ".$CC_CONFIG['prefTable']." (subjid, keystr)"; + camp_install_query($sql, false); + + $sql = "CREATE INDEX ".$CC_CONFIG['prefTable']."_subjid_idx + ON ".$CC_CONFIG['prefTable']." (subjid)"; + camp_install_query($sql); + + echo " * Inserting starting data into table ".$CC_CONFIG['prefTable']."..."; + //$stPrefGr = Subjects::GetSubjId($CC_CONFIG['StationPrefsGr']); + Prefs::Insert($CC_CONFIG["systemPrefId"], 'stationName', "Radio Station 1"); + $genres = file_get_contents( dirname(__FILE__).'/../genres.xml'); + Prefs::Insert($CC_CONFIG["systemPrefId"], 'genres', $genres); + echo "done.\n"; +} else { + echo " * Skipping: database table already exists: ".$CC_CONFIG['prefTable']."\n"; +} + +//------------------------------------------------------------------------ +// Install storage directories +//------------------------------------------------------------------------ +foreach (array('storageDir', 'bufferDir', 'transDir', 'accessDir', 'pearPath', 'cronDir') as $d) { + $test = file_exists($CC_CONFIG[$d]); + if ( $test === FALSE ) { + @mkdir($CC_CONFIG[$d], 02775); + if (file_exists($CC_CONFIG[$d])) { + $rp = realpath($CC_CONFIG[$d]); + echo " * Directory $rp created\n"; + } else { + echo " * Failed creating {$CC_CONFIG[$d]}\n"; + exit(1); + } + } elseif (is_writable($CC_CONFIG[$d])) { + $rp = realpath($CC_CONFIG[$d]); + echo " * Skipping directory already exists: $rp\n"; + } else { + $rp = realpath($CC_CONFIG[$d]); + echo " * WARNING: Directory already exists, but is not writable: $rp\n"; + //exit(1); + } + $CC_CONFIG[$d] = $rp; +} + +//------------------------------------------------------------------------ +// Storage directory writability test +//------------------------------------------------------------------------ + +echo " * Testing writability of ".$CC_CONFIG['storageDir']."..."; +if (!($fp = @fopen($CC_CONFIG['storageDir']."/_writeTest", 'w'))) { + echo "\nPlease make directory {$CC_CONFIG['storageDir']} writeable by your webserver". + "\nand run install again\n\n"; + exit(1); +} else { + fclose($fp); + unlink($CC_CONFIG['storageDir']."/_writeTest"); +} +echo "done.\n"; + +//------------------------------------------------------------------------ +// Install Cron job +//------------------------------------------------------------------------ +require_once(dirname(__FILE__).'/../cron/Cron.php'); +$m = '*/2'; +$h ='*'; +$dom = '*'; +$mon = '*'; +$dow = '*'; +$command = realpath("{$CC_CONFIG['cronDir']}/transportCron.php"); +$old_regex = '/transportCron\.php/'; +echo " * Install storageServer cron job...\n"; + +$cron = new Cron(); +$access = $cron->openCrontab('write'); +if ($access != 'write') { + do { + $r = $cron->forceWriteable(); + } while ($r); +} + +foreach ($cron->ct->getByType(CRON_CMD) as $id => $line) { + if (preg_match($old_regex, $line['command'])) { + echo " * Removing old entry: ".$line['command']."\n"; + $cron->ct->delEntry($id); + } +} +echo " * Adding new entry: ".$command."\n"; +$cron->ct->addCron($m, $h, $dom, $mon, $dow, $command); +$cron->closeCrontab(); +echo " Done.\n"; echo "**********************************\n"; echo "* StorageServer Install Complete *\n"; diff --git a/src/modules/storageServer/var/install/installInit.php b/src/modules/storageServer/var/install/installInit.php index 247cc10b1..c126e2d34 100644 --- a/src/modules/storageServer/var/install/installInit.php +++ b/src/modules/storageServer/var/install/installInit.php @@ -3,7 +3,6 @@ if (!function_exists('pg_connect')) { trigger_error("PostgreSQL PHP extension required and not found.", E_USER_ERROR); exit(2); } - require_once('DB.php'); require_once('File/Find.php'); @@ -18,6 +17,17 @@ function camp_db_table_exists($p_name) return true; } +function camp_db_sequence_exists($p_name) +{ + global $CC_DBC; + $sql = "SELECT 1 FROM pg_class where relname = '$p_name'"; + $result = $CC_DBC->GetOne($sql); + if (!PEAR::isError($result) && $result == "1") { + return true; + } + return false; +} + function camp_install_query($sql, $verbose = true) { global $CC_DBC; diff --git a/src/modules/storageServer/var/install/installMain.php b/src/modules/storageServer/var/install/installMain.php deleted file mode 100644 index f1e3ff54f..000000000 --- a/src/modules/storageServer/var/install/installMain.php +++ /dev/null @@ -1,333 +0,0 @@ -createSequence($CC_CONFIG['subjTable']."_id_seq"); - echo "done.\n"; -} else { - echo " * Skipping: database table already exists: ".$CC_CONFIG['subjTable']."\n"; -} - -if (!camp_db_table_exists($CC_CONFIG['smembTable'])) { - echo " * Creating database table ".$CC_CONFIG['smembTable']."..."; - $sql = "CREATE TABLE ".$CC_CONFIG['smembTable']." ( - id int not null PRIMARY KEY, - uid int not null default 0, - gid int not null default 0, - level int not null default 0, - mid int)"; - camp_install_query($sql, false); - - $sql = "CREATE UNIQUE INDEX ".$CC_CONFIG['smembTable']."_id_idx - ON ".$CC_CONFIG['smembTable']." (id)"; - camp_install_query($sql, false); - - $CC_DBC->createSequence($CC_CONFIG['smembTable']."_id_seq"); - echo "done.\n"; -} else { - echo " * Skipping: database table already exists: ".$CC_CONFIG['smembTable']."\n"; -} - -if (!camp_db_table_exists($CC_CONFIG['permTable'])) { - echo " * Creating database table ".$CC_CONFIG['permTable']."..."; - $sql = "CREATE TABLE ".$CC_CONFIG['permTable']." ( - permid int not null PRIMARY KEY, - subj int REFERENCES ".$CC_CONFIG['subjTable']." ON DELETE CASCADE, - action varchar(20), - obj int, - type char(1))"; - camp_install_query($sql, false); - - $sql = "CREATE UNIQUE INDEX ".$CC_CONFIG['permTable']."_permid_idx - ON ".$CC_CONFIG['permTable']." (permid)"; - camp_install_query($sql, false); - - $sql = "CREATE INDEX ".$CC_CONFIG['permTable']."_subj_obj_idx - ON ".$CC_CONFIG['permTable']." (subj, obj)"; - camp_install_query($sql, false); - - $sql = "CREATE UNIQUE INDEX ".$CC_CONFIG['permTable']."_all_idx - ON ".$CC_CONFIG['permTable']." (subj, action, obj)"; - camp_install_query($sql, false); - - $CC_DBC->createSequence($CC_CONFIG['permTable']."_id_seq"); - echo "done.\n"; -} else { - echo " * Skipping: database table already exists: ".$CC_CONFIG['permTable']."\n"; -} - -if (!camp_db_table_exists($CC_CONFIG['sessTable'])) { - echo " * Creating database table ".$CC_CONFIG['sessTable']."..."; - $sql = "CREATE TABLE ".$CC_CONFIG['sessTable']." ( - sessid char(32) not null PRIMARY KEY, - userid int REFERENCES ".$CC_CONFIG['subjTable']." ON DELETE CASCADE, - login varchar(255), - ts timestamp)"; - camp_install_query($sql, false); - - $sql = "CREATE UNIQUE INDEX ".$CC_CONFIG['sessTable']."_sessid_idx - ON ".$CC_CONFIG['sessTable']." (sessid)"; - camp_install_query($sql, false); - - $sql = "CREATE INDEX ".$CC_CONFIG['sessTable']."_userid_idx - ON ".$CC_CONFIG['sessTable']." (userid)"; - camp_install_query($sql, false); - - $sql = "CREATE INDEX ".$CC_CONFIG['sessTable']."_login_idx - ON ".$CC_CONFIG['sessTable']." (login)"; - camp_install_query($sql); -} else { - echo " * Skipping: database table already exists: ".$CC_CONFIG['sessTable']."\n"; -} - -/** - * file states: - *
    - *
  • empty
  • - *
  • incomplete
  • - *
  • ready
  • - *
  • edited
  • - *
  • deleted
  • - *
- * file types: - *
    - *
  • audioclip
  • - *
  • playlist
  • - *
  • webstream
  • - *
- * access types: - *
    - *
  • access
  • - *
  • download
  • - *
- */ -if (!camp_db_table_exists($CC_CONFIG['filesTable'])) { - echo " * Creating database table ".$CC_CONFIG['filesTable']."..."; - $sql = "CREATE TABLE ".$CC_CONFIG['filesTable']." ( - id int not null, - gunid bigint not null, -- global unique ID - name varchar(255) not null default'', -- human file id ;) - mime varchar(255) not null default'', -- mime type - ftype varchar(128) not null default'', -- file type - state varchar(128) not null default'empty', -- file state - currentlyaccessing int not null default 0, -- access counter - editedby int REFERENCES ".$CC_CONFIG['subjTable'].", -- who edits it - mtime timestamp(6) with time zone, -- lst modif.time - md5 char(32) - )"; - camp_install_query($sql, false); - - $sql = "CREATE UNIQUE INDEX ".$CC_CONFIG['filesTable']."_id_idx - ON ".$CC_CONFIG['filesTable']." (id)"; - camp_install_query($sql, false); - - $sql = "CREATE UNIQUE INDEX ".$CC_CONFIG['filesTable']."_gunid_idx - ON ".$CC_CONFIG['filesTable']." (gunid)"; - camp_install_query($sql, false); - - $sql = "CREATE INDEX ".$CC_CONFIG['filesTable']."_name_idx - ON ".$CC_CONFIG['filesTable']." (name)"; - camp_install_query($sql, false); - - $sql = "CREATE INDEX ".$CC_CONFIG['filesTable']."_md5_idx - ON ls_files (md5)"; - camp_install_query($sql); - - $sql = "CREATE SEQUENCE file_id_seq - INCREMENT 1 - MINVALUE 1 - MAXVALUE 9223372036854775807 - START 1000000 - CACHE 1"; - camp_install_query($sql); - -} else { - echo " * Skipping: database table already exists: ".$CC_CONFIG['filesTable']."\n"; -} - -/** - * id subjns subject predns predicate objns object - * y1 literal xmbf NULL namespace literal http://www.sotf.org/xbmf - * x1 gunid xbmf contributor NULL NULL - * x2 mdid x1 xbmf role literal Editor - * - * predefined shortcuts: - * _L = literal - * _G = gunid (global id of media file) - * _I = mdid (local id of metadata record) - * _nssshortcut = namespace shortcut definition - * _blank = blank node - */ -if (!camp_db_table_exists($CC_CONFIG['mdataTable'])) { - echo " * Creating database table ".$CC_CONFIG['mdataTable']."..."; - $CC_DBC->createSequence($CC_CONFIG['mdataTable']."_id_seq"); - $sql = "CREATE TABLE ".$CC_CONFIG['mdataTable']." ( - id int not null, - gunid bigint, - subjns varchar(255), -- subject namespace shortcut/uri - subject varchar(255) not null default '', - predns varchar(255), -- predicate namespace shortcut/uri - predicate varchar(255) not null, - predxml char(1) not null default 'T', -- Tag or Attribute - objns varchar(255), -- object namespace shortcut/uri - object text - )"; - camp_install_query($sql, false); - - $sql = "CREATE UNIQUE INDEX ".$CC_CONFIG['mdataTable']."_id_idx - ON ".$CC_CONFIG['mdataTable']." (id)"; - camp_install_query($sql, false); - - $sql = "CREATE INDEX ".$CC_CONFIG['mdataTable']."_gunid_idx - ON ".$CC_CONFIG['mdataTable']." (gunid)"; - camp_install_query($sql, false); - - $sql = "CREATE INDEX ".$CC_CONFIG['mdataTable']."_subj_idx - ON ".$CC_CONFIG['mdataTable']." (subjns, subject)"; - camp_install_query($sql, false); - - $sql = "CREATE INDEX ".$CC_CONFIG['mdataTable']."_pred_idx - ON ".$CC_CONFIG['mdataTable']." (predns, predicate)"; - camp_install_query($sql); -} else { - echo " * Skipping: database table already exists: ".$CC_CONFIG['mdataTable']."\n"; -} - -if (!camp_db_table_exists($CC_CONFIG['accessTable'])) { - echo " * Creating database table ".$CC_CONFIG['accessTable']."..."; - $sql = "CREATE TABLE ".$CC_CONFIG['accessTable']." ( - gunid bigint, -- global unique id - token bigint, -- access token - chsum char(32) not null default'', -- md5 checksum - ext varchar(128) not null default'', -- extension - type varchar(20) not null default'', -- access type - parent bigint, -- parent token - owner int REFERENCES ".$CC_CONFIG['subjTable'].", -- subject have started it - ts timestamp - )"; - camp_install_query($sql, false); - - $sql = "CREATE INDEX ".$CC_CONFIG['accessTable']."_token_idx - ON ".$CC_CONFIG['accessTable']." (token)"; - camp_install_query($sql, false); - - $sql = "CREATE INDEX ".$CC_CONFIG['accessTable']."_gunid_idx - ON ".$CC_CONFIG['accessTable']." (gunid)"; - camp_install_query($sql, false); - - $sql = "CREATE INDEX ".$CC_CONFIG['accessTable']."_parent_idx - ON ".$CC_CONFIG['accessTable']." (parent)"; - camp_install_query($sql); -} else { - echo " * Skipping: database table already exists: ".$CC_CONFIG['accessTable']."\n"; -} - -echo " * Inserting starting data into tables...\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']." ( - id int not null, -- primary key - trtok char(16) not null, -- transport token - direction varchar(128) not null, -- direction: up|down - state varchar(128) not null, -- state - trtype varchar(128) not null, -- transport type - lock char(1) not null default 'N',-- running lock - target varchar(255) default NULL, -- target system, - -- if NULL => predefined set - rtrtok char(16) default NULL, -- remote hub's transport token - mdtrtok char(16), -- metadata transport token - gunid bigint, -- global unique id - pdtoken bigint, -- put/download token from archive - url varchar(255), -- url on remote side - localfile varchar(255), -- pathname of local part - fname varchar(255), -- mnemonic filename - title varchar(255), -- dc:title mdata value (or filename ...) - expectedsum char(32), -- expected file checksum - realsum char(32), -- checksum of transported part - expectedsize int, -- expected filesize in bytes - realsize int, -- filesize of transported part - uid int, -- local user id of transport owner - errmsg varchar(255), -- error message string for failed tr. - jobpid int, -- pid of transport job - start timestamp, -- starttime - ts timestamp -- mtime - )"; - camp_install_query($sql, false); - - $CC_DBC->createSequence($CC_CONFIG['transTable']."_id_seq"); - $sql = "CREATE UNIQUE INDEX ".$CC_CONFIG['transTable']."_id_idx - ON ".$CC_CONFIG['transTable']." (id)"; - camp_install_query($sql, false); - - $sql = "CREATE UNIQUE INDEX ".$CC_CONFIG['transTable']."_trtok_idx - ON ".$CC_CONFIG['transTable']." (trtok)"; - camp_install_query($sql, false); - - $sql = "CREATE UNIQUE INDEX ".$CC_CONFIG['transTable']."_token_idx - ON ".$CC_CONFIG['transTable']." (pdtoken)"; - camp_install_query($sql, false); - - $sql = "CREATE INDEX ".$CC_CONFIG['transTable']."_gunid_idx - ON ".$CC_CONFIG['transTable']." (gunid)"; - camp_install_query($sql, false); - - $sql = "CREATE INDEX ".$CC_CONFIG['transTable']."_state_idx - ON ".$CC_CONFIG['transTable']." (state)"; - camp_install_query($sql); -} else { - echo " * Skipping: database table already exists: ".$CC_CONFIG['transTable']."\n"; -} - -?> \ No newline at end of file diff --git a/src/modules/storageServer/var/install/installStorage.php b/src/modules/storageServer/var/install/installStorage.php deleted file mode 100644 index 3b9a0396c..000000000 --- a/src/modules/storageServer/var/install/installStorage.php +++ /dev/null @@ -1,115 +0,0 @@ -createSequence($CC_CONFIG['prefTable']."_id_seq"); - $sql = "CREATE TABLE ".$CC_CONFIG['prefTable']." ( - id int not null, - subjid int REFERENCES ".$CC_CONFIG['subjTable']." ON DELETE CASCADE, - keystr varchar(255), - valstr text - )"; - camp_install_query($sql, false); - - $sql = "CREATE UNIQUE INDEX ".$CC_CONFIG['prefTable']."_id_idx - ON ".$CC_CONFIG['prefTable']." (id)"; - camp_install_query($sql, false); - - $sql = "CREATE UNIQUE INDEX ".$CC_CONFIG['prefTable']."_subj_key_idx - ON ".$CC_CONFIG['prefTable']." (subjid, keystr)"; - camp_install_query($sql, false); - - $sql = "CREATE INDEX ".$CC_CONFIG['prefTable']."_subjid_idx - ON ".$CC_CONFIG['prefTable']." (subjid)"; - camp_install_query($sql); - - echo " * Inserting starting data into table ".$CC_CONFIG['prefTable']."..."; - $stPrefGr = Subjects::GetSubjId($CC_CONFIG['StationPrefsGr']); - Prefs::Insert($stPrefGr, 'stationName', "Radio Station 1"); - $genres = file_get_contents( dirname(__FILE__).'/../genres.xml'); - Prefs::Insert($stPrefGr, 'genres', $genres); - echo "done.\n"; -} else { - echo " * Skipping: database table already exists: ".$CC_CONFIG['prefTable']."\n"; -} - -//------------------------------------------------------------------------ -// Install storage directories -//------------------------------------------------------------------------ -foreach (array('storageDir', 'bufferDir', 'transDir', 'accessDir', 'pearPath', 'cronDir') as $d) { - $test = file_exists($CC_CONFIG[$d]); - if ( $test === FALSE ) { - @mkdir($CC_CONFIG[$d], 02775); - if (file_exists($CC_CONFIG[$d])) { - $rp = realpath($CC_CONFIG[$d]); - echo " * Directory $rp created\n"; - } else { - echo " * Failed creating {$CC_CONFIG[$d]}\n"; - exit(1); - } - } elseif (is_writable($CC_CONFIG[$d])) { - $rp = realpath($CC_CONFIG[$d]); - echo " * Skipping directory already exists: $rp\n"; - } else { - $rp = realpath($CC_CONFIG[$d]); - echo " * ERROR. Directory already exists, but is not writable: $rp\n"; - exit(1); - } - $CC_CONFIG[$d] = $rp; -} - -//------------------------------------------------------------------------ -// Storage directory writability test -//------------------------------------------------------------------------ - -echo " * Testing writability of ".$CC_CONFIG['storageDir']."..."; -if (!($fp = @fopen($CC_CONFIG['storageDir']."/_writeTest", 'w'))) { - echo "\nPlease make directory {$CC_CONFIG['storageDir']} writeable by your webserver". - "\nand run install again\n\n"; - exit(1); -} else { - fclose($fp); - unlink($CC_CONFIG['storageDir']."/_writeTest"); -} -echo "done.\n"; - -//------------------------------------------------------------------------ -// Install Cron job -//------------------------------------------------------------------------ -require_once(dirname(__FILE__).'/../cron/Cron.php'); -$m = '*/2'; -$h ='*'; -$dom = '*'; -$mon = '*'; -$dow = '*'; -$command = realpath("{$CC_CONFIG['cronDir']}/transportCron.php"); -$old_regex = '/transportCron\.php/'; -echo " * Install storageServer cron job...\n"; - -$cron = new Cron(); -$access = $cron->openCrontab('write'); -if ($access != 'write') { - do { - $r = $cron->forceWriteable(); - } while ($r); -} - -foreach ($cron->ct->getByType(CRON_CMD) as $id => $line) { - if (preg_match($old_regex, $line['command'])) { - echo " * Removing old entry: ".$line['command']."\n"; - $cron->ct->delEntry($id); - } -} -echo " * Adding new entry: ".$command."\n"; -$cron->ct->addCron($m, $h, $dom, $mon, $dow, $command); -$cron->closeCrontab(); -echo " Done.\n"; -?> diff --git a/src/modules/storageServer/var/install/uninstall.php b/src/modules/storageServer/var/install/uninstall.php index 7f15d31b7..7199e3d69 100644 --- a/src/modules/storageServer/var/install/uninstall.php +++ b/src/modules/storageServer/var/install/uninstall.php @@ -23,9 +23,171 @@ echo "***************************\n"; require_once('../conf.php'); require_once('installInit.php'); campcaster_db_connect(false); -require_once('uninstallStorage.php'); + +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 (!PEAR::isError($CC_DBC)) { - require_once('uninstallMain.php'); + 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"; + } +} + +//------------------------------------------------------------------------ +// Uninstall Cron job +//------------------------------------------------------------------------ +require_once(dirname(__FILE__).'/../cron/Cron.php'); +$old_regex = '/transportCron\.php/'; +echo " * Uninstall storageServer cron job...\n"; + +$cron = new Cron(); +$access = $cron->openCrontab('write'); +if ($access != 'write') { + do { + $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"; + $cron->ct->delEntry($id); + } +} + +$cron->closeCrontab(); +echo "Done.\n"; + +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_seq"); + echo "done.\n"; +} else { + echo " * Skipping: database table ".$CC_CONFIG['transTable']."\n"; +} + +if (camp_db_table_exists($CC_CONFIG['mdataTable'])) { + echo " * Removing database table ".$CC_CONFIG['mdataTable']."..."; + $sql = "DROP TABLE ".$CC_CONFIG['mdataTable']; + camp_install_query($sql, false); + + $CC_DBC->dropSequence($CC_CONFIG['mdataTable']."_id_seq"); + echo "done.\n"; +} else { + echo " * Skipping: database table ".$CC_CONFIG['mdataTable']."\n"; +} + +if (camp_db_table_exists($CC_CONFIG['filesTable'])) { + echo " * Removing database table ".$CC_CONFIG['filesTable']."..."; + $sql = "DROP TABLE ".$CC_CONFIG['filesTable']; + camp_install_query($sql); +} else { + echo " * Skipping: database table ".$CC_CONFIG['filesTable']."\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['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_seq"); + 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_seq"); + + $sql = "DROP TABLE ".$CC_CONFIG['subjTable']; + 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_seq"); + 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']; + camp_install_query($sql); +} else { + echo " * Skipping: database table ".$CC_CONFIG['playlogTable']."\n"; } echo "************************************\n"; diff --git a/src/modules/storageServer/var/install/uninstallMain.php b/src/modules/storageServer/var/install/uninstallMain.php deleted file mode 100644 index 52638ae90..000000000 --- a/src/modules/storageServer/var/install/uninstallMain.php +++ /dev/null @@ -1,101 +0,0 @@ -dropSequence($CC_CONFIG['transTable']."_id_seq"); - echo "done.\n"; -} else { - echo " * Skipping: database table ".$CC_CONFIG['transTable']."\n"; -} - -if (camp_db_table_exists($CC_CONFIG['mdataTable'])) { - echo " * Removing database table ".$CC_CONFIG['mdataTable']."..."; - $sql = "DROP TABLE ".$CC_CONFIG['mdataTable']; - camp_install_query($sql, false); - - $CC_DBC->dropSequence($CC_CONFIG['mdataTable']."_id_seq"); - echo "done.\n"; -} else { - echo " * Skipping: database table ".$CC_CONFIG['mdataTable']."\n"; -} - -if (camp_db_table_exists($CC_CONFIG['filesTable'])) { - echo " * Removing database table ".$CC_CONFIG['filesTable']."..."; - $sql = "DROP TABLE ".$CC_CONFIG['filesTable']; - camp_install_query($sql); -} else { - echo " * Skipping: database table ".$CC_CONFIG['filesTable']."\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_seq"); - 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_seq"); - - $sql = "DROP TABLE ".$CC_CONFIG['subjTable']; - 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_seq"); - echo "done.\n"; -} else { - echo " * Skipping: database table ".$CC_CONFIG['smembTable']."\n"; -} - -?> \ No newline at end of file diff --git a/src/modules/storageServer/var/install/uninstallStorage.php b/src/modules/storageServer/var/install/uninstallStorage.php deleted file mode 100644 index 9a7f964d7..000000000 --- a/src/modules/storageServer/var/install/uninstallStorage.php +++ /dev/null @@ -1,77 +0,0 @@ - 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 (!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"; - } -} - -//------------------------------------------------------------------------ -// Uninstall Cron job -//------------------------------------------------------------------------ -require_once(dirname(__FILE__).'/../cron/Cron.php'); -$old_regex = '/transportCron\.php/'; -echo " * Uninstall storageServer cron job...\n"; - -$cron = new Cron(); -$access = $cron->openCrontab('write'); -if ($access != 'write') { - do { - $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"; - $cron->ct->delEntry($id); - } -} - -$cron->closeCrontab(); -echo "Done.\n"; - -camp_uninstall_delete_files($CC_CONFIG['storageDir']); -camp_uninstall_delete_files($CC_CONFIG['transDir']); -camp_uninstall_delete_files($CC_CONFIG['accessDir']); - -?> \ No newline at end of file diff --git a/src/modules/storageServer/var/xmlrpc/XR_LocStor.php b/src/modules/storageServer/var/xmlrpc/XR_LocStor.php index 3ee030648..fbea52d81 100644 --- a/src/modules/storageServer/var/xmlrpc/XR_LocStor.php +++ b/src/modules/storageServer/var/xmlrpc/XR_LocStor.php @@ -3523,23 +3523,23 @@ class XR_LocStor extends LocStor { * @return XML_RPC_Response * @see LocStor::getAudioClip */ - public function xr_resetStorage($input) - { - list($ok, $r) = XR_LocStor::xr_getParams($input); - if (!$ok) { - return $r; - } - $res = $this->resetStorage( - isset($r['loadSampleData']) ? $r['loadSampleData'] : TRUE, - !(isset($r['invalidateSessionIds']) ? $r['invalidateSessionIds'] : FALSE) - ); - if (PEAR::isError($res)) { - return new XML_RPC_Response(0, 805, - "xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo() - ); - } - return new XML_RPC_Response(XML_RPC_encode($res)); - } +// public function xr_resetStorage($input) +// { +// list($ok, $r) = XR_LocStor::xr_getParams($input); +// if (!$ok) { +// return $r; +// } +// $res = $this->resetStorage( +// isset($r['loadSampleData']) ? $r['loadSampleData'] : TRUE, +// !(isset($r['invalidateSessionIds']) ? $r['invalidateSessionIds'] : FALSE) +// ); +// if (PEAR::isError($res)) { +// return new XML_RPC_Response(0, 805, +// "xr_getAudioClip: ".$res->getMessage()." ".$res->getUserInfo() +// ); +// } +// return new XML_RPC_Response(XML_RPC_encode($res)); +// } /** * Test XMLRPC - strupper and return given string, diff --git a/src/modules/storageServer/var/xmlrpc/schedulerPhpClient.php b/src/modules/storageServer/var/xmlrpc/schedulerPhpClient.php index 7d67a281a..d3fce621a 100644 --- a/src/modules/storageServer/var/xmlrpc/schedulerPhpClient.php +++ b/src/modules/storageServer/var/xmlrpc/schedulerPhpClient.php @@ -222,13 +222,13 @@ $mdefs = array( '1320'=>'missing session ID argument', ) ), - "ResetStorageMethod" => array( - 'm'=>'resetStorage', - 'p'=>array(), - 't'=>array(), - 'r'=>array(), - 'e'=>array('3001'=>'storage client reported an error'), - ), +// "ResetStorageMethod" => array( +// 'm'=>'resetStorage', +// 'p'=>array(), +// 't'=>array(), +// 'r'=>array(), +// 'e'=>array('3001'=>'storage client reported an error'), +// ), "RevertEditedPlaylistMethod" => array( 'm'=>'revertEditedPlaylist', 'p'=>array('sessionId'/*string*/, 'playlistId'/*string*/), diff --git a/src/modules/storageServer/var/xmlrpc/xrLocStor.php b/src/modules/storageServer/var/xmlrpc/xrLocStor.php index 0c08d6d8b..cffb85514 100644 --- a/src/modules/storageServer/var/xmlrpc/xrLocStor.php +++ b/src/modules/storageServer/var/xmlrpc/xrLocStor.php @@ -88,7 +88,7 @@ $methods = array( 'accessRawAudioData' => 'Get access to raw audio data.', 'releaseRawAudioData' => 'Release access to raw audio data.', 'getAudioClip' => 'Return the contents of an Audio clip.', - 'resetStorage' => 'Reset storageServer for debugging.', +// 'resetStorage' => 'Reset storageServer for debugging.', 'storeWebstream' => 'Store audio stream identified by URL', 'createPlaylist' => 'Create a new Playlist metafile.', diff --git a/src/modules/storageServer/var/xmlrpc/xr_cli_test.php b/src/modules/storageServer/var/xmlrpc/xr_cli_test.php index 1ee4ab6cb..4c8124a0f 100644 --- a/src/modules/storageServer/var/xmlrpc/xr_cli_test.php +++ b/src/modules/storageServer/var/xmlrpc/xr_cli_test.php @@ -109,8 +109,8 @@ $infos = array( 'p'=>array('sessid', 'gunid', 'metadata'), 'r'=>'status'), "searchMetadata" => array('m'=>"locstor.searchMetadata", 'p'=>NULL), "browseCategory" => array('m'=>"locstor.browseCategory", 'p'=>NULL), - "resetStorage" => array('m'=>"locstor.resetStorage", - 'p'=>array()), +// "resetStorage" => array('m'=>"locstor.resetStorage", +// 'p'=>array()), # 'p'=>array('loadSampleData', 'invalidateSessionIds')), "storeWebstream" => array('m'=>"locstor.storeWebstream", 'p'=>array('sessid', 'gunid', 'metadata', 'fname', 'url'), @@ -259,12 +259,12 @@ switch ($method) { ), ); break; - case "resetStorage": - $parr = array( - 'loadSampleData'=>(boolean)$pars[0], - 'invalidateSessionIds'=>(boolean)$pars[1], - ); - break; +// case "resetStorage": +// $parr = array( +// 'loadSampleData'=>(boolean)$pars[0], +// 'invalidateSessionIds'=>(boolean)$pars[1], +// ); +// break; default: $pinfo = $infos[$method]['p']; if (is_null($pinfo)) { diff --git a/src/modules/storageServer/var/xmlrpc/xr_web_test.php b/src/modules/storageServer/var/xmlrpc/xr_web_test.php index 0673db834..9f7516923 100644 --- a/src/modules/storageServer/var/xmlrpc/xr_web_test.php +++ b/src/modules/storageServer/var/xmlrpc/xr_web_test.php @@ -99,9 +99,8 @@ $methodDefs = array( 'p'=>array('sessid', 'gunid', 'metadata'), 'r'=>'status'), "searchMetadata" => array('m'=>"locstor.searchMetadata", 'p'=>NULL), "browseCategory" => array('m'=>"locstor.browseCategory", 'p'=>NULL), - "resetStorage" => array('m'=>"locstor.resetStorage", - 'p'=>array()), -# 'p'=>array('loadSampleData', 'invalidateSessionIds')), +// "resetStorage" => array('m'=>"locstor.resetStorage", +// 'p'=>array()), "storeWebstream" => array('m'=>"locstor.storeWebstream", 'p'=>array('sessid', 'gunid', 'metadata', 'fname', 'url'), 'r'=>array('gunid') diff --git a/src/products/scheduler/bin/campcaster-scheduler.sh b/src/products/scheduler/bin/campcaster-scheduler.sh index 9560b0978..4a647ab75 100755 --- a/src/products/scheduler/bin/campcaster-scheduler.sh +++ b/src/products/scheduler/bin/campcaster-scheduler.sh @@ -84,16 +84,6 @@ case "$mode" in $scheduler_exe -c $config_file status ;; - 'install') - echo "Installing Campcaster scheduler database tables..." - BASE_DIR=$basedir php $vardir/install/install.php -c $config_file - ;; - - 'uninstall') - echo "Uninstalling Campcaster scheduler database tables..." - BASE_DIR=$basedir php $vardir/install/uninstall.php -c $config_file - ;; - 'kill') echo "Killing all Campcaster scheduler processes..." killall campcaster-scheduler @@ -105,7 +95,7 @@ case "$mode" in echo "Campcaster scheduler System V runlevel init script." echo "" echo "Usage:" - echo " $0 start|stop|restart|status|install|uninstall|kill" + echo " $0 start|stop|restart|status|kill" echo "" esac diff --git a/src/products/scheduler/bin/campcaster-scheduler_devenv.sh b/src/products/scheduler/bin/campcaster-scheduler_devenv.sh index 306047c27..a9204025c 100755 --- a/src/products/scheduler/bin/campcaster-scheduler_devenv.sh +++ b/src/products/scheduler/bin/campcaster-scheduler_devenv.sh @@ -100,16 +100,6 @@ case "$mode" in $scheduler_exe -c $config_file status ;; - 'install') - echo "Installing Campcaster scheduler database tables..." - BASE_DIR=$usrdir php $vardir/install/install.php -c $config_file - ;; - - 'uninstall') - echo "Uninstalling Campcaster scheduler database tables..." - BASE_DIR=$usrdir php $vardir/install/uninstall.php -c $config_file - ;; - 'kill') echo "Killing all Campcaster scheduler processes..." killall campcaster-scheduler @@ -121,7 +111,7 @@ case "$mode" in echo "Campcaster scheduler System V runlevel init script." echo "" echo "Usage:" - echo " $0 start|run|stop|restart|status|install|uninstall|kill" + echo " $0 start|run|stop|restart|status|kill" echo "" esac diff --git a/src/products/scheduler/etc/Makefile.in b/src/products/scheduler/etc/Makefile.in index 17fdba929..c7ab352c6 100644 --- a/src/products/scheduler/etc/Makefile.in +++ b/src/products/scheduler/etc/Makefile.in @@ -343,7 +343,6 @@ copy_files: ${MAKE} -C ${EVENT_SCHEDULER_DIR} install ${MKDIR} ${USR_BIN_DIR} ${MKDIR} ${USR_ETC_DIR} - ${MKDIR} ${USR_VAR_DIR}/install ${MKDIR} ${USR_TMP_DIR} ${CP} ${BIN_DIR}/campcaster-scheduler.sh ${USR_BIN_DIR} ${CP} ${SCHEDULER_EXE} ${USR_BIN_DIR} @@ -357,7 +356,6 @@ copy_files: ${CAT} ${ETC_DIR}/campcaster-scheduler.xml.template \ | ${SED} -e ${REPLACE_SED_STRING} \ > ${USR_ETC_DIR}/campcaster-scheduler.xml - ${CP} ${VAR_DIR}/install/*.php ${USR_VAR_DIR}/install/ create_database: ifeq (@CREATE_LS_DATABASE@,yes) @@ -373,20 +371,11 @@ ifeq (@CREATE_ODBC_DATA_SOURCE@,yes) --dbserver=${DB_SERVER} endif -init_database: -ifeq (@INIT_LS_DATABASE@,yes) - ${USR_BIN_DIR}/campcaster-scheduler.sh install -endif - - check_local: all ${TEST_RUNNER} kill start_local run_tests stop_local run_tests: ${TEST_RUNNER} ${TEST_RUNNER_SH} -o ${TEST_RESULTS} -s ${TEST_XSLT} -init: ${SCHEDULER_EXE} - -${SCHEDULER_SH} install - start: ${SCHEDULER_EXE} ${SCHEDULER_SH} start sleep 2 @@ -401,12 +390,6 @@ stop: ${SCHEDULER_EXE} status: ${SCHEDULER_EXE} ${SCHEDULER_SH} status -deinit: ${SCHEDULER_EXE} - -${SCHEDULER_SH} uninstall - -init_local: ${SCHEDULER_EXE} - ${SCHEDULER_EXE} -c ${SCHEDULER_LOCAL_CFG} install - start_local: ${SCHEDULER_EXE} ${SCHEDULER_EXE} -c ${SCHEDULER_LOCAL_CFG} start sleep 2 @@ -422,9 +405,6 @@ run_local: ${SCHEDULER_EXE} ${SCHEDULER_EXE} -c ${SCHEDULER_LOCAL_CFG} --debug start sleep 2 -deinit_local: ${SCHEDULER_EXE} - ${SCHEDULER_EXE} -c ${SCHEDULER_LOCAL_CFG} uninstall - storage_server_init: ${MAKE} -C ${STORAGE_SERVER_DIR} diff --git a/src/products/scheduler/var/install/install.php b/src/products/scheduler/var/install/install.php deleted file mode 100644 index 8e0c470f5..000000000 --- a/src/products/scheduler/var/install/install.php +++ /dev/null @@ -1,27 +0,0 @@ - diff --git a/src/products/scheduler/var/install/installInit.php b/src/products/scheduler/var/install/installInit.php deleted file mode 100644 index d7ab7421c..000000000 --- a/src/products/scheduler/var/install/installInit.php +++ /dev/null @@ -1,80 +0,0 @@ -GetOne($sql); - if (PEAR::isError($result)) { - return false; - } - return true; -} - -function camp_install_query($sql) -{ - global $CC_DBC; - $result = $CC_DBC->query($sql); - if (PEAR::isError($result)) { - echo "Error! ".$result->getMessage()."\n"; - echo " SQL statement was:\n"; - echo " ".$sql."\n\n"; - } else { - echo "done.\n"; - } -} - -$options = getopt("c:"); - -if (!$options) { - echo "\nYou must specific the config file with -c.\n\n"; - exit; -} - -$configFile = $options['c']; -if (!file_exists($configFile)) { - echo "\nThe config file '$configFile' does not exist.\n\n"; - exit; -} - -echo " * Using config file $configFile\n"; - -$xml = file_get_contents($configFile); -$parser = xml_parser_create(); -xml_parse_into_struct($parser, $xml, $vals, $index); -xml_parser_free($parser); - -$CC_CONFIG['dsn'] = array('hostspec' => 'localhost', - 'phptype' => 'pgsql'); - -// Get the user index -$userIndex = $index['SIMPLECONNECTIONMANAGER'][0]; -$CC_CONFIG['dsn']['username'] = $vals[$userIndex]['attributes']['USERNAME']; -$CC_CONFIG['dsn']['password'] = $vals[$userIndex]['attributes']['PASSWORD']; -$CC_CONFIG['dsn']['database'] = $vals[$userIndex]['attributes']['DSN']; - -$CC_CONFIG['playlogTable'] = 'playlog'; -$CC_CONFIG['scheduleTable'] = 'schedule'; -$CC_CONFIG['backupTable'] = 'backup'; - -$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"; -} - -$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC); - -?> \ No newline at end of file diff --git a/src/products/scheduler/var/install/installScheduler.php b/src/products/scheduler/var/install/installScheduler.php deleted file mode 100644 index cfdc70b39..000000000 --- a/src/products/scheduler/var/install/installScheduler.php +++ /dev/null @@ -1,51 +0,0 @@ - \ No newline at end of file diff --git a/src/products/scheduler/var/install/uninstall.php b/src/products/scheduler/var/install/uninstall.php deleted file mode 100644 index 511112d61..000000000 --- a/src/products/scheduler/var/install/uninstall.php +++ /dev/null @@ -1,24 +0,0 @@ - \ No newline at end of file diff --git a/src/products/scheduler/var/install/uninstallScheduler.php b/src/products/scheduler/var/install/uninstallScheduler.php deleted file mode 100644 index e395335c3..000000000 --- a/src/products/scheduler/var/install/uninstallScheduler.php +++ /dev/null @@ -1,34 +0,0 @@ - \ No newline at end of file