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/htmlUI/var/ui_base.inc.php b/src/modules/htmlUI/var/ui_base.inc.php index bf4c26efd..c5fbaa53a 100644 --- a/src/modules/htmlUI/var/ui_base.inc.php +++ b/src/modules/htmlUI/var/ui_base.inc.php @@ -311,17 +311,18 @@ class uiBase */ public function loadStationPrefs(&$mask, $reload=FALSE) { + global $CC_CONFIG; if (!is_array($this->STATIONPREFS) || ($reload === TRUE) ) { $this->STATIONPREFS = array(); foreach ($mask as $key => $val) { if (isset($val['isPref']) && $val['isPref']) { - $setting = $this->gb->loadGroupPref(NULL, 'StationPrefs', $val['element']); + $setting = $this->gb->loadGroupPref($CC_CONFIG['StationPrefsGr'], $val['element']); if (is_string($setting)) { $this->STATIONPREFS[$val['element']] = $setting; } elseif ($val['required']) { // set default values on first login $default = isset($val['default'])?$val['default']:null; - $this->gb->saveGroupPref($this->sessid, 'StationPrefs', $val['element'], $default); + $this->gb->saveGroupPref($this->sessid, $CC_CONFIG['StationPrefsGr'], $val['element'], $default); $this->STATIONPREFS[$val['element']] = $default; } } @@ -529,24 +530,24 @@ class uiBase public function getMetaInfo($id) { $type = strtolower(GreenBox::getFileType($id)); - + if($type == 'playlist') { require_once("../../../storageServer/var/Playlist.php"); - + $playList = new Playlist(GreenBox::GunidFromId($id)); $playListData = $playList->export(); - + for ($i = 1; $i < count($playListData); $i++) { - - $entry = StoredFile::RecallByGunid($playListData["".$i]["gunid"]); + + $entry = StoredFile::RecallByGunid($playListData["".$i]["gunid"]); $playListEntries[] = $entry->getName(); - + } - + $_SESSION['mdata'] = $playListEntries; - + } - + $data = array('id' => $id, 'gunid' => BasicStor::GunidFromId($id), 'title' => $this->getMetadataValue($id, UI_MDATA_KEY_TITLE), diff --git a/src/modules/htmlUI/var/ui_browser.class.php b/src/modules/htmlUI/var/ui_browser.class.php index c889f81b9..02bd35642 100644 --- a/src/modules/htmlUI/var/ui_browser.class.php +++ b/src/modules/htmlUI/var/ui_browser.class.php @@ -296,10 +296,11 @@ class uiBrowser extends uiBase { function changeStationPrefs(&$mask) { + global $CC_CONFIG; $form = new HTML_QuickForm('changeStationPrefs', UI_STANDARD_FORM_METHOD, UI_HANDLER); foreach($mask as $key => $val) { $element = isset($val['element']) ? $val['element'] : null; - $p = $this->gb->loadGroupPref($this->sessid, 'StationPrefs', $element); + $p = $this->gb->loadGroupPref($CC_CONFIG['StationPrefsGr'], $element); if (is_string($p)) { $mask[$key]['default'] = $p; } diff --git a/src/modules/htmlUI/var/ui_handler.class.php b/src/modules/htmlUI/var/ui_handler.class.php index 6f57425ce..fb6b9e9df 100644 --- a/src/modules/htmlUI/var/ui_handler.class.php +++ b/src/modules/htmlUI/var/ui_handler.class.php @@ -696,6 +696,7 @@ class uiHandler extends uiBase { */ function changeStationPrefs($formdata, $mask) { + global $CC_CONFIG; $this->redirUrl = UI_BROWSER; if ($this->_validateForm($formdata, $mask) == FALSE) { @@ -705,18 +706,18 @@ class uiHandler extends uiBase { foreach ($mask as $key => $val) { if (isset($val['isPref']) && $val['isPref']) { if (!empty($formdata[$val['element']])) { - $result = $this->gb->saveGroupPref($this->sessid, 'StationPrefs', $val['element'], $formdata[$val['element']]); + $result = $this->gb->saveGroupPref($this->sessid, $CC_CONFIG['StationPrefsGr'], $val['element'], $formdata[$val['element']]); if (PEAR::isError($result)) $this->_retMsg('Error while saving settings.'); } else { - $this->gb->delGroupPref($this->sessid, 'StationPrefs', $val['element']); + $this->gb->delGroupPref($this->sessid, $CC_CONFIG['StationPrefsGr'], $val['element']); } } if (isset($val['type']) && ($val['type'] == 'file') && ($val['element'] == "stationlogo") && !empty($formdata[$val['element']]['name'])) { - $stationLogoPath = $this->gb->loadGroupPref($this->sessid, 'StationPrefs', 'stationLogoPath'); + $stationLogoPath = $this->gb->loadGroupPref($CC_CONFIG['StationPrefsGr'], 'stationLogoPath'); $filePath = $formdata[$val['element']]['tmp_name']; if (function_exists("getimagesize")) { $size = @getimagesize($filePath); diff --git a/src/modules/htmlUI/var/ui_twitter.class.php b/src/modules/htmlUI/var/ui_twitter.class.php index c3c16a256..506fc5cf9 100644 --- a/src/modules/htmlUI/var/ui_twitter.class.php +++ b/src/modules/htmlUI/var/ui_twitter.class.php @@ -1,12 +1,12 @@ 'campcaster', - 'bitly-apikey' => 'R_2f812152bfc21035468350273ec8ff43' + 'bitly-apikey' => 'R_2f812152bfc21035468350273ec8ff43' ); - + /** * Time in sec * @@ -19,7 +19,7 @@ class uiTwitter { $this->Base =& $uiBase; $this->loadSettings(); } - + private static function getSettingFormMask() { $formmask = array( @@ -182,7 +182,7 @@ class uiTwitter { 'label' => 'Provider', 'options' => array( 'bit.ly' => 'bit.ly', - 'tinyurl.com' => 'tinyurl.com', + 'tinyurl.com' => 'tinyurl.com', ), 'isPref' => true ), @@ -209,29 +209,30 @@ class uiTwitter { 'label' => 'Submit', ) ); - return $formmask; + return $formmask; } - + private function loadSettings() { + global $CC_CONFIG; $mask = uiTwitter::getSettingFormMask(); - + foreach($mask as $key => $val) { if (isset($val['isPref']) && $val['isPref']) { $element = preg_replace('/^twitter-/', '', $val['element'], 1); - $p = $this->Base->gb->loadGroupPref($this->Base->sessid, 'StationPrefs', $val['element']); + $p = $this->Base->gb->loadGroupPref($CC_CONFIG['StationPrefsGr'], $val['element']); if (is_string($p)) { $this->settings[$element] = $p; } } } } - + public function getSettingsForm() { $mask = uiTwitter::getSettingFormMask(); $form = new HTML_QuickForm('twitter', UI_STANDARD_FORM_METHOD, UI_HANDLER);# - + foreach($mask as $key => $val) { if (isset($val['isPref']) && $val['isPref'] && !$val['hiddenPref']) { $element = preg_replace('/^twitter-/', '', $val['element']); @@ -246,48 +247,49 @@ class uiTwitter { $form->accept($renderer); return $renderer->toArray(); } - + public function saveSettings() { + global $CC_CONFIG; if ($this->Base->_validateForm($_REQUEST, uiTwitter::getSettingFormMask()) !== TRUE) { $this->Base->_retMsg('An error has occured on validating the form.'); return FALSE; } - + $mask = uiTwitter::getSettingFormMask(); $form = new HTML_QuickForm('twitter', UI_STANDARD_FORM_METHOD, UI_HANDLER); uiBase::parseArrayToForm($form, $mask); $formdata = $form->exportValues(); - + foreach ($mask as $key => $val) { if (isset($val['isPref']) && $val['isPref']) { if (!empty($formdata[$val['element']])) { - $result = $this->Base->gb->saveGroupPref($this->Base->sessid, 'StationPrefs', $val['element'], $formdata[$val['element']]); + $result = $this->Base->gb->saveGroupPref($this->Base->sessid, $CC_CONFIG['StationPrefsGr'], $val['element'], $formdata[$val['element']]); if (PEAR::isError($result)) $this->Base->_retMsg('Error while saving twitter settings.'); } elseif (!$val['hiddenPref']) { - $this->Base->gb->delGroupPref($this->Base->sessid, 'StationPrefs', $val['element']); + $this->Base->gb->delGroupPref($this->Base->sessid, $CC_CONFIG['StationPrefsGr'], $val['element']); } } } - + $this->Base->_retMsg('Twitter settings saved.'); } - + public function getFeed($p_useSampledata = false) - { + { if ($p_useSampledata) { $whatsplaying = array( "tracktitle" => "Gimme Shelter", "trackartist" => "The Rolling Stones", "playlisttitle" => "The Blues Hour" - ); + ); } else { $whatsplaying = $this->getWhatsplaying($this->settings['offset']); } - + if (!$whatsplaying) { - return; + return; } //////////////////////////////////////////////////////////////////////// @@ -313,35 +315,35 @@ class uiTwitter { if ($this->settings['has_trackartist']) { $tweetbody[] = $whatsplaying['trackartist']; } if ($this->settings['has_playlisttitle']) { $tweetbody[] = $whatsplaying['playlisttitle']; } if ($this->settings['has_stationname']) { $tweetbody[] = $this->Base->STATIONPREFS['stationName']; } - + $tweetbody = implode (". ",$tweetbody); - + // chop body to fit if necessary if ((strlen($tweetprefix) + strlen($tweetbody) + strlen($tweetsuffix)) > 140) { $tweetbody = substr($tweetbody, 0, (140 - (strlen($tweetprefix) + strlen($tweetsuffix) + 3))) . "..."; } - + $tweet = $tweetprefix . $tweetbody . $tweetsuffix; - + return $tweet; } - + public function shortUrl($p_url) { switch ($this->settings['shortener-provider']) { case 'tinyurl.com': $short = file_get_contents('http://tinyurl.com/api-create.php?url='.$p_url); break; - + case 'bit.ly': $short = file_get_contents("http://api.bit.ly/shorten?version=2.0.1&longUrl={$p_url}&format=text&login={$this->settings['bitly-login']}&apiKey={$this->settings['bitly-apikey']}"); break; } - + return $short; } - + public function getWhatsplaying($p_offset) { $timestamp = time() + $p_offset; @@ -362,47 +364,48 @@ class uiTwitter { if (!$clip['gunid']) { return FALSE; } - + return array( 'tracktitle' => $this->Base->gb->getMetadataValue(BasicStor::IdFromGunid($clip['gunid']), UI_MDATA_KEY_TITLE, $this->Base->sessid), 'trackartist' => $this->Base->gb->getMetadataValue(BasicStor::IdFromGunid($clip['gunid']), UI_MDATA_KEY_CREATOR, $this->Base->sessid), 'playlisttitle' => $this->Base->gb->getMetadataValue(BasicStor::IdFromGunid($pl['playlistId']), UI_MDATA_KEY_TITLE, $this->Base->sessid), ); } - + public function sendFeed($p_feed) { + global $CC_CONFIG; $twitter = new twitter(); $twitter->username = $this->settings['login']; $twitter->password = $this->settings['password']; - + if ($res = $twitter->update($p_feed)) { - $this->Base->gb->saveGroupPref($this->Base->sessid, 'StationPrefs', 'twitter-lastupdate', time()); + $this->Base->gb->saveGroupPref($this->Base->sessid, $CC_CONFIG['StationPrefsGr'], 'twitter-lastupdate', time()); return $res; } return false; } - + public function needsUpdate() { - if (time() - $this->Base->gb->loadGroupPref($this->Base->sessid, 'StationPrefs', 'twitter-lastupdate') + $this->runtime > $this->settings['interval']) { + if (time() - $this->Base->gb->loadGroupPref($CC_CONFIG['StationPrefsGr'], 'twitter-lastupdate') + $this->runtime > $this->settings['interval']) { return true; } return false; } - + public function twitterify($p_string) { $string = preg_replace("#(^|[\n ])([\w]+?://[\w]+[^ \"\n\r\t< ]*)#", "\\1\\2", $p_string); $string = preg_replace("#(^|[\n ])((www|ftp)\.[^ \"\t\n\r< ]*)#", "\\1\\2", $string); $string = preg_replace("/@(\w+)/", "@\\1", $string); $string = preg_replace("/#(\w+)/", "#\\1", $string); - + return $string; } - + public function isActive() { - return $this->settings['is_active']; + return $this->settings['is_active']; } } diff --git a/src/modules/storageServer/bin/setupDirs.sh b/src/modules/storageServer/bin/setupDirs.sh index e2ff568d4..2b7d1e3c8 100755 --- a/src/modules/storageServer/bin/setupDirs.sh +++ b/src/modules/storageServer/bin/setupDirs.sh @@ -27,7 +27,7 @@ WWW_ROOT=`cd var/install; php -q getWwwRoot.php` || exit $? echo " *** StorageServer bin/setupDirs.sh BEGIN" -echo " *** Root URL: $WWW_ROOT" +echo " * Root URL: $WWW_ROOT" PHP_PWD_COMMAND=`bin/getUrl.sh $WWW_ROOT/install/getPwd.php` || \ { errno=$? @@ -37,6 +37,7 @@ PHP_PWD_COMMAND=`bin/getUrl.sh $WWW_ROOT/install/getPwd.php` || \ fi exit $errno } + PHP_PWD=$PHP_PWD_COMMAND # MOD_PHP may not be working, this command will tell us if [ ${PHP_PWD_COMMAND:0:5} == ' Probably wrong setting in var/conf.php: URL configuration"; exit $ERN; } -echo " *** The system group that is running the http daemon: '$HTTP_GROUP'" +echo " ** The system group that is running the http daemon: '$HTTP_GROUP'" for i in $* do - echo " *** chown :$HTTP_GROUP $i" + echo " * chown :$HTTP_GROUP $i" if [ -G $i ]; then chown :$HTTP_GROUP $i || \ { @@ -73,7 +79,7 @@ do 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" + echo " * chmod g+sw $i" chmod g+sw $i || exit $? fi done diff --git a/src/modules/storageServer/var/BasicStor.php b/src/modules/storageServer/var/BasicStor.php index f9a54edb5..1fdc8de22 100644 --- a/src/modules/storageServer/var/BasicStor.php +++ b/src/modules/storageServer/var/BasicStor.php @@ -1413,20 +1413,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; } @@ -1811,10 +1809,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; @@ -1939,42 +1935,42 @@ 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'])) { @@ -2001,10 +1997,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"; @@ -2013,12 +2009,12 @@ 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"; 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 @@ loadGroupPref($sessid, $group, $key); + $res = $pr->loadGroupPref($group, $key); return $res; } // fn loadGroupPref diff --git a/src/modules/storageServer/var/Prefs.php b/src/modules/storageServer/var/Prefs.php index 0fb0a7363..7c9039510 100644 --- a/src/modules/storageServer/var/Prefs.php +++ b/src/modules/storageServer/var/Prefs.php @@ -132,16 +132,16 @@ class Prefs { /** * Read group preference record * - * @param string $sessid - * session id * @param string $group * group name * @param string $key * preference key + * @param boolean $returnErrorIfKeyNotExists + * If set to true and the key doesnt exist, return a PEAR error. * @return string * preference value */ - function loadGroupPref($sessid, $group, $key) + function loadGroupPref($group, $key, $returnErrorIfKeyNotExists = true) { // if sessid is would be used here fix Transport::cronCallMethod ! $subjid = Subjects::GetSubjId($group); @@ -157,8 +157,12 @@ class Prefs { return $val; } if ($val === FALSE) { - return PEAR::raiseError( - "Prefs::loadGroupPref: invalid preference key", GBERR_PREF); + if ($returnErrorIfKeyNotExists) { + return PEAR::raiseError( + "Prefs::loadGroupPref: invalid preference key", GBERR_PREF); + } else { + return ''; + } } return $val; } @@ -437,59 +441,5 @@ class Prefs { return TRUE; } - - /** - * Install database table for preference storage - * - * @return boolean - */ -// function install() -// { -// global $CC_CONFIG, $CC_DBC; -// $CC_DBC->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 828201391..1a8df3f0b 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/Transport.php b/src/modules/storageServer/var/Transport.php index 08ab2f0ac..5ea961d7b 100644 --- a/src/modules/storageServer/var/Transport.php +++ b/src/modules/storageServer/var/Transport.php @@ -199,9 +199,9 @@ class Transport { require_once('Prefs.php'); $pr = new Prefs($this->gb); - $group = 'StationPrefs'; + $group = $CC_CONFIG['StationPrefsGr']; $key = 'TransportsDenied'; - $res = $pr->loadGroupPref($sessid, $group, $key); + $res = $pr->loadGroupPref($group, $key); if (PEAR::isError($res)) { if ($res->getCode() !== GBERR_PREF) { return $res; @@ -863,6 +863,7 @@ class Transport */ function cronCallMethod($trtok) { + global $CC_CONFIG; $trec = TransportRecord::recall($this, $trtok); if (PEAR::isError($trec)) { return $trec; @@ -903,9 +904,9 @@ class Transport case 'waiting': require_once('Prefs.php'); $pr = new Prefs($this->gb); - $group = 'StationPrefs'; + $group = $CC_CONFIG['StationPrefsGr']; $key = 'TransportsDenied'; - $res = $pr->loadGroupPref(NULL/*sessid*/, $group, $key); + $res = $pr->loadGroupPref($group, $key); if (PEAR::isError($res)) { if ($res->getCode() !== GBERR_PREF) { return $res; @@ -1668,32 +1669,31 @@ class Transport { global $CC_CONFIG; $xrp = XML_RPC_encode($pars); - - $group = 'StationPrefs'; + + $pr = new Prefs($this->gb); + $group = $CC_CONFIG["StationPrefsGr"]; $key = 'archiveServerLocation'; - $archiveUrl = $pr->loadGroupPref(NULL/*sessid*/, $group, $key); - - if($archiveUrl){ - + $archiveUrl = $pr->loadGroupPref($group, $key, false); + + echo "Archive URL: $archiveUrl\n"; + if ($archiveUrl) { $archiveUrlInfo = parse_url($archiveUrl); - - if($archiveUrlInfo['port']){ + if ($archiveUrlInfo['port']) { $port = $archiveUrlInfo['port']; } else { $port = 80; } - - - $c = new XML_RPC_Client($archiveUrlInfo['path'], $archiveUrlInfo['host'], $port); + + $c = new XML_RPC_Client($archiveUrlInfo['path'], $archiveUrlInfo['host'], $port); } else { $c = new XML_RPC_Client( $CC_CONFIG['archiveUrlPath']."/".$CC_CONFIG['archiveXMLRPC'], $CC_CONFIG['archiveUrlHost'], $CC_CONFIG['archiveUrlPort'] - ); + ); } - + $f = new XML_RPC_Message($method, array($xrp)); $r = $c->send($f); if (!$r) { diff --git a/src/modules/storageServer/var/conf.php b/src/modules/storageServer/var/conf.php index 2182911fd..b17e648af 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', + //'AdminsGr' => 'Admins', 'StationPrefsGr'=> 'StationPrefs', - 'AllGr' => 'All', + //'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/conf.php.template b/src/modules/storageServer/var/conf.php.template index 66ab23f8a..7f94c7fb1 100644 --- a/src/modules/storageServer/var/conf.php.template +++ b/src/modules/storageServer/var/conf.php.template @@ -70,8 +70,8 @@ $CC_CONFIG = array( 'storageUrlPort' => ls_php_port, /* ================================================ archive configuration */ - 'archiveUrlPath' => 'ls_archiveUrlPath', - 'archiveXMLRPC' => 'xmlrpc/xrArchive.php', + 'archiveUrlPath' => 'ls_storageUrlPath', + 'archiveXMLRPC' => 'xmlrpc/xrLocStor.php', 'archiveUrlHost' => 'ls_php_host', 'archiveUrlPort' => ls_php_port, 'archiveAccountLogin' => 'root', diff --git a/src/modules/storageServer/var/conf_only.php.template b/src/modules/storageServer/var/conf_only.php.template index edd49f490..b1a8db3ab 100644 --- a/src/modules/storageServer/var/conf_only.php.template +++ b/src/modules/storageServer/var/conf_only.php.template @@ -43,8 +43,8 @@ $CC_CONFIG = array( 'storageUrlPort' => ls_php_port, /* ================================================ archive configuration */ - 'archiveUrlPath' => 'ls_archiveUrlPath', - 'archiveXMLRPC' => 'xmlrpc/xrArchive.php', + 'archiveUrlPath' => 'ls_storageUrlPath', + 'archiveXMLRPC' => 'xmlrpc/xrLocStor.php', 'archiveUrlHost' => 'ls_php_host', 'archiveUrlPort' => ls_php_port, 'archiveAccountLogin' => 'root', 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/getGname.php b/src/modules/storageServer/var/install/getGname.php index 7a02033d5..75051942c 100644 --- a/src/modules/storageServer/var/install/getGname.php +++ b/src/modules/storageServer/var/install/getGname.php @@ -6,7 +6,9 @@ header("Content-type: text/plain"); $egid = posix_getegid(); $info = posix_getgrgid($egid); -if ($_SERVER["REMOTE_ADDR"] == "127.0.0.1") { +if ( (isset($_SERVER["REMOTE_ADDR"]) && ($_SERVER["REMOTE_ADDR"] == "127.0.0.1")) + || (isset($_SERVER["HTTP_HOST"]) && ($_SERVER["HTTP_HOST"] == "localhost")) + || (isset($_SERVER["SHELL"])) ) { echo $info['name']; } ?> \ No newline at end of file diff --git a/src/modules/storageServer/var/install/getPwd.php b/src/modules/storageServer/var/install/getPwd.php index 67123dd31..f416e57f1 100644 --- a/src/modules/storageServer/var/install/getPwd.php +++ b/src/modules/storageServer/var/install/getPwd.php @@ -4,7 +4,10 @@ *----------------------------------------------------------------------------*/ header("Content-type: text/plain"); -if ($_SERVER["REMOTE_ADDR"] == "127.0.0.1") { +//var_dump($_SERVER); +if ( (isset($_SERVER["REMOTE_ADDR"]) && ($_SERVER["REMOTE_ADDR"] == "127.0.0.1")) + || (isset($_SERVER["HTTP_HOST"]) && ($_SERVER["HTTP_HOST"] == "localhost")) + || (isset($_SERVER["SHELL"])) ) { echo `pwd`; } ?> \ No newline at end of file diff --git a/src/modules/storageServer/var/install/install.php b/src/modules/storageServer/var/install/install.php index 702f95733..d17674204 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: - * - * 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 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..f8df60978 100644 --- a/src/modules/storageServer/var/xmlrpc/XR_LocStor.php +++ b/src/modules/storageServer/var/xmlrpc/XR_LocStor.php @@ -2742,7 +2742,7 @@ class XR_LocStor extends LocStor { } require_once(dirname(__FILE__).'/../Prefs.php'); $pr = new Prefs($this); - $res = $pr->loadGroupPref($r['sessid'], $r['group'], $r['key']); + $res = $pr->loadGroupPref($r['group'], $r['key']); if (PEAR::isError($res)) { $ec0 = intval($res->getCode()); $ec = ( @@ -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