From 7b22d9da203749bea715bfed3863a44c1fe97b6e Mon Sep 17 00:00:00 2001 From: sebastian Date: Wed, 17 Feb 2010 13:59:37 +0000 Subject: [PATCH] #2367 transport cron install/uninstall --- .../var/install/installStorage.php | 25 ++++++++++++------- .../var/install/uninstallStorage.php | 25 +++++++++++++++++++ 2 files changed, 41 insertions(+), 9 deletions(-) diff --git a/campcaster/src/modules/storageServer/var/install/installStorage.php b/campcaster/src/modules/storageServer/var/install/installStorage.php index 1aec96614..e4e352b2a 100644 --- a/campcaster/src/modules/storageServer/var/install/installStorage.php +++ b/campcaster/src/modules/storageServer/var/install/installStorage.php @@ -85,6 +85,14 @@ 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'); @@ -93,16 +101,15 @@ if ($access != 'write') { $r = $cron->forceWriteable(); } while ($r); } -foreach ($cron->ct->getByType(CRON_CMD) as $line) { - if (preg_match('/transportCron\.php/', $line['command'])) { - $cron->closeCrontab(); - echo " * Storage cron job already exists.\n"; - exit; + +foreach ($cron->ct->getByType(CRON_CMD) as $id => $line) { + if (preg_match($old_regex, $line['command'])) { + echo " removing old entry\n"; + $cron->ct->delEntry($id); } } -echo " * Adding transport cron job..."; -$cron->ct->addCron('*/2', '*', '*', '*', '*', realpath("{$CC_CONFIG['cronDir']}/transportCron.php")); +echo " adding new entry\n"; +$cron->ct->addCron($m, $h, $dom, $mon, $dow, $command); $cron->closeCrontab(); -echo "done.\n"; - +echo " Done.\n"; ?> diff --git a/campcaster/src/modules/storageServer/var/install/uninstallStorage.php b/campcaster/src/modules/storageServer/var/install/uninstallStorage.php index 4a99506ff..c1f26f17c 100644 --- a/campcaster/src/modules/storageServer/var/install/uninstallStorage.php +++ b/campcaster/src/modules/storageServer/var/install/uninstallStorage.php @@ -48,6 +48,31 @@ if (!PEAR::isError($CC_DBC)) { } } +//------------------------------------------------------------------------ +// 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']);