#2367 transport cron install/uninstall

This commit is contained in:
sebastian 2010-02-17 13:59:37 +00:00
parent ce0ee8dfb6
commit 7b22d9da20
2 changed files with 41 additions and 9 deletions

View File

@ -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";
?>

View File

@ -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']);