From 7c94734277bfdff22bb64f540ec69cbc523851a2 Mon Sep 17 00:00:00 2001 From: James Date: Fri, 16 Sep 2011 14:01:23 -0400 Subject: [PATCH] CC-2810: More chmnod fixes for scripts - removed shebang from .py files - removed cron folder and its content as we don't use them - .js files are from 3rd party(datatable) so we should leave them as they are --- airtime_mvc/application/models/cron/Cron.php | 214 ------------- .../application/models/cron/CronJob.php | 17 -- .../application/models/cron/Crontab.php | 284 ------------------ .../application/models/cron/croncall.php | 8 - .../install/media-monitor-install.py | 1 - .../install/media-monitor-uninstall.py | 1 - python_apps/pypo/install/pypo-install.py | 1 - python_apps/pypo/install/pypo-uninstall.py | 1 - python_apps/pypo/pypo-cli.py | 1 - python_apps/pypo/pypo-notify.py | 1 - python_apps/pypo/util/status.py | 1 - .../show-recorder/install/recorder-install.py | 1 - .../install/recorder-uninstall.py | 1 - utils/serbianLatinToCyrillicConverter.py | 1 - 14 files changed, 533 deletions(-) delete mode 100755 airtime_mvc/application/models/cron/Cron.php delete mode 100755 airtime_mvc/application/models/cron/CronJob.php delete mode 100755 airtime_mvc/application/models/cron/Crontab.php delete mode 100755 airtime_mvc/application/models/cron/croncall.php diff --git a/airtime_mvc/application/models/cron/Cron.php b/airtime_mvc/application/models/cron/Cron.php deleted file mode 100755 index 300fbc701..000000000 --- a/airtime_mvc/application/models/cron/Cron.php +++ /dev/null @@ -1,214 +0,0 @@ - - * $cron = new Cron(); - * $access = $cron->openCrontab('write'); - * if ($access != 'write') { - * do { - * $access = $cron->forceWriteable(); - * } while ($access != 'write'); - * } - * $cron->addCronJob('*','*','*','*','*', - * 'ClassName', - * array('first','secound','third') - * ); - * $cron->closeCrontab(); - * - * @package Airtime - * @subpackage StorageServer.Cron - */ -class Cron { - /** - * @var Crontab - */ - public $ct; - - /** - * @var array This array created with getCommand() function - */ - private $params; - - /** - * @var string available values: read | write - */ - private $ctAccess = 'read'; - - private $lockfile; - private $cronfile; - private $paramdir; - private $cronUserName; - - /** - * Constructor - */ - function Cron() { - global $CC_CONFIG; - $this->lockfile = $CC_CONFIG['lockfile']; - $this->cronfile = $CC_CONFIG['cronfile']; - $this->paramdir = $CC_CONFIG['paramdir']; - $this->cronUserName = $CC_CONFIG['cronUserName']; - } - - - /* ==================================================== Cronjob functions */ - /** - * Add a cronjob to the crontab - * - * @access public - * @param string $m minute - * @param string $h hour - * @param string $dom day of month - * @param string $mo month - * @param string $dow day of week - * @param string $className name of class, which's execute() is called by croncall.php - * @param string $params the parameter(s) - * @return bool true if success else PEAR error. - */ - function addCronJob($m, $h, $dom, $mo, $dow, $className, $params) - { - if ($this->ctAccess == 'write') { - $this->ct->addCron($m, $h, $dom, $mo, $dow, - $this->getCommand($className, $params)); - return true; - } else { - return PEAR::raiseError('CronJob::addCronJob : '. - 'The crontab is not writable'); - } - } - - /** - * This function return with the active cronjobs - * - * @access public - * @return array array of cronjob struct - */ - function listCronJob() - { - return $this->ct->getByType(CRON_CMD); - } - - /** - * Remove a cronjob. - * - * @access public - * @param int $index index of the cronjobs' array. - * @return bool true if success else PEAR error. - */ - function removeCronJob($index) - { - if ($this->ctAccess == 'write') { - $this->crontab->delEntry($index); - return true; - } else { - return PEAR::raiseError('CronJob::removeCronJob : '. - 'The crontab is not writable'); - } - } - - /* ==================================================== Crontab functions */ - /** - * Open the crontab - * - * @access public - * @param string $access only for listing 'read', for add and delete 'write' - * @return string sucessed access - available values read | write - */ - function openCrontab($access = 'read') - { - $access = strtolower($access); - $this->ct = new Crontab($this->cronUserName); - if ($access == 'write' && - $this->isCrontabWritable() && - $this->lockCrontab()) { - $this->ctAccess = $access; - } else { - $this->ctAccess = 'read'; - } - return $this->ctAccess; - } - - /** - * Close the crontab - * - * @access public - * @return bool true if everything is ok, false is the lock file can't delete - */ - function closeCrontab() - { - if ($this->ctAccess == 'write') { - $this->ct->writeCrontab(); - } - return $this->ctAccess == 'write' ? $this->unlockCrontab() : true; - } - - /** - * Check the crontab is writable - * - * @access private - * @return bool - */ - function isCrontabWritable() - { - return !is_file($this->lockfile); - } - - /** - * Try to lock the crontab - * - * @access private - * @return bool true if the locking is success - */ - function lockCrontab() - { - return @touch($this->lockfile); - } - - /** - * Try to unlock the crontab - * - * @access private - * @return bool true if the unlocking is success - */ - function unlockCrontab() - { - return unlink($this->lockfile); - } - - /** - * If the crontab opened with read access. This function force set - * the access to write. - * - * @access public - * @return bool true if the setting is success - */ - function forceWriteable() - { - if ($this->isCrontabWritable() && $this->lockCrontab()) { - $this->ctAccess = 'write'; - return true; - } - return false; - } - - /* ======================================================= Misc functions */ - /** - * Get the shell command for the cronjob - * - * @param string $className name of the class what is called by croncall.php - * @param mixed $params with this parameter could be called the execute() of class - * @return string shell command - */ - function getCommand($className, $params) - { - $this->params = array ( - 'class' => $className, - 'params' => $params - ); - return $this->cronfile.' "'.str_replace('"','\"',serialize($this->params)).'"'; - } -} - diff --git a/airtime_mvc/application/models/cron/CronJob.php b/airtime_mvc/application/models/cron/CronJob.php deleted file mode 100755 index a9e56adb0..000000000 --- a/airtime_mvc/application/models/cron/CronJob.php +++ /dev/null @@ -1,17 +0,0 @@ - "value" - * or a line can be a comment (string beginning with #) - * or it can be a special command (beginning with an @) - * @var array - */ - private $crontabs; - - /** - * The user for whom the crontab will be manipulated - * @var string - */ - private $user; - - /** - * Lists the type of line of each line in $crontabs. - * can be: any of the CRON_* constants. - * so $linetype[5] is the type of $crontabs[5]. - * @var string - */ - private $linetypes; - - // }}} - - /** - * Constructor - * - * Initialises $this->crontabs - * - * @param string $user the user for whom the crontab will be manipulated - */ - function Crontab($user) - { - $this->user = $user; - $this->readCrontab(); - } - - /** - * This reads the crontab of $this->user and parses it in $this->crontabs - * - */ - function readCrontab() - { - // return code is 0 or 1 if crontab was empty, elsewhere stop here - $cmd = "crontab -u {$this->user} -l"; - @exec("crontab -u {$this->user} -l", $crons, $return); - if ($return > 1) { - return PEAR::raiseError("*** Can't read crontab ***\n". - " Set crontab manually!\n"); - } - - foreach ($crons as $line) - { - $line = trim($line); // discarding all prepending spaces and tabs - - // empty lines.. - if (!$line) { - $this->crontabs[] = "empty line"; - $this->linetypes[] = CRON_EMPTY; - continue; - } - - // checking if this is a comment - if ($line[0] == "#") { - $this->crontabs[] = trim($line); - $this->linetypes[] = CRON_COMMENT; - continue; - } - - // Checking if this is an assignment - if (ereg("(.*)=(.*)", $line, $assign)) { - $this->crontabs[] = array ("name" => $assign[1], "value" => $assign[2]); - $this->linetypes[] = CRON_ASSIGN; - continue; - } - - // Checking if this is a special @-entry. check man 5 crontab for more info - if ($line[0] == '@') { - $this->crontabs[] = split("[ \t]", $line, 2); - $this->linetypes[] = CRON_SPECIAL; - continue; - } - - // 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]); - } - } - - /** - * Writes the current crontab - */ - function writeCrontab() - { - global $DEBUG, $PATH; - - if (empty($this->linetypes)) { - return; - } - $filename = ($DEBUG ? tempnam("$PATH/crons", "cron") : tempnam("/tmp", "cron")); - $file = fopen($filename, "w"); - - foreach($this->linetypes as $i => $line) { - switch ($this->linetypes[$i]) { - case CRON_COMMENT: - $line = $this->crontabs[$i]; - break; - case CRON_ASSIGN: - $line = $this->crontabs[$i][name]." = ".$this->crontabs[$i][value]; - break; - case CRON_CMD: - $line = implode(" ", $this->crontabs[$i]); - break; - case CRON_SPECIAL: - $line = implode(" ", $this->crontabs[$i]); - break; - case CRON_EMPTY: - $line = "\n"; // an empty line in the crontab-file - break; - default: - unset($line); - echo "Something very weird is going on. This line ($i) has an unknown type.\n"; - break; - } - - // echo "line $i : $line\n"; - - if ($line) { - $r = @fwrite($file, $line."\n"); - if($r === FALSE) { - return PEAR::raiseError("*** Can't write crontab ***\n". - " Set crontab manually!\n"); - } - } - } - fclose($file); - - if ($DEBUG) { - echo "DEBUGMODE: not updating crontab. writing to $filename instead.\n"; - } else { - exec("crontab -u {$this->user} $filename", $returnar, $return); - if ($return != 0) { - echo "Error running crontab ($return). $filename not deleted\n"; - } else { - unlink($filename); - } - } - } - - - /** - * Add a item of type CRON_CMD to the end of $this->crontabs - * - * @param string $m - * minute - * @param string $h - * hour - * @param string $dom - * day of month - * @param string $mo - * month - * @param string $dow - * day of week - * @param string $cmd - * command - * - */ - function addCron($m, $h, $dom, $mo, $dow, $cmd) - { - $this->crontabs[] = array ("minute" => $m, "hour" => $h, "dayofmonth" => $dom, "month" => $mo, "dayofweek" => $dow, "command" => $cmd); - $this->linetypes[] = CRON_CMD; - } - - - /** - * Add a comment to the cron to the end of $this->crontabs - * - * @param string $comment - */ - function addComment($comment) - { - $this->crontabs[] = "# $comment\n"; - $this->linetypes[] = CRON_COMMENT; - } - - - /** - * Add a special command (check man 5 crontab for more information) - * - * @param string $sdate special date - * string meaning - * ------ ------- - * @reboot Run once, at startup. - * @yearly Run once a year, "0 0 1 1 *". - * @annually (same as @yearly) - * @monthly Run once a month, "0 0 1 * *". - * @weekly Run once a week, "0 0 * * 0". - * @daily Run once a day, "0 0 * * *". - * @midnight (same as @daily) - * @hourly Run once an hour, "0 * * * *". - * @param string $cmd command - */ - function addSpecial($sdate, $cmd) - { - $this->crontabs[] = array ("special" => $sdate, "command" => $cmd); - $this->linetypes[] = CRON_SPECIAL; - } - - - /** - * Add an assignment (name = value) - * - * @param string $name - * @param string $value - */ - function addAssign($name, $value) - { - $this->crontabs[] = array ("name" => $name, "value" => $value); - $this->linetypes[] = CRON_ASSIGN; - } - - - /** - * Delete a line from the arrays. - * - * @param int $index the index in $this->crontabs - */ - function delEntry($index) - { - unset ($this->crontabs[$index]); - unset ($this->linetypes[$index]); - } - - - /** - * Get all the lines of a certain type in an array - * - * @param string $type - */ - function getByType($type) - { - if ($type < CRON_COMMENT || $type > CRON_EMPTY) - { - trigger_error("Wrong type: $type", E_USER_WARNING); - return 0; - } - - $returnar = array (); - for ($i = 0; $i < count($this->linetypes); $i ++) - if ($this->linetypes[$i] == $type) - $returnar[] = $this->crontabs[$i]; - - return $returnar; - } -} - diff --git a/airtime_mvc/application/models/cron/croncall.php b/airtime_mvc/application/models/cron/croncall.php deleted file mode 100755 index 1c46966ae..000000000 --- a/airtime_mvc/application/models/cron/croncall.php +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/php -execute($p['params']); -exit(0); diff --git a/python_apps/media-monitor/install/media-monitor-install.py b/python_apps/media-monitor/install/media-monitor-install.py index 929413c09..a9e7846b6 100644 --- a/python_apps/media-monitor/install/media-monitor-install.py +++ b/python_apps/media-monitor/install/media-monitor-install.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python2.6 # -*- coding: utf-8 -*- import time diff --git a/python_apps/media-monitor/install/media-monitor-uninstall.py b/python_apps/media-monitor/install/media-monitor-uninstall.py index 1d028afe6..a9b69399d 100644 --- a/python_apps/media-monitor/install/media-monitor-uninstall.py +++ b/python_apps/media-monitor/install/media-monitor-uninstall.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python2.6 # -*- coding: utf-8 -*- import os diff --git a/python_apps/pypo/install/pypo-install.py b/python_apps/pypo/install/pypo-install.py index 607816794..44dfe3077 100644 --- a/python_apps/pypo/install/pypo-install.py +++ b/python_apps/pypo/install/pypo-install.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python2.6 # -*- coding: utf-8 -*- import time diff --git a/python_apps/pypo/install/pypo-uninstall.py b/python_apps/pypo/install/pypo-uninstall.py index 9131a493c..cc39187ad 100644 --- a/python_apps/pypo/install/pypo-uninstall.py +++ b/python_apps/pypo/install/pypo-uninstall.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python2.6 # -*- coding: utf-8 -*- import os diff --git a/python_apps/pypo/pypo-cli.py b/python_apps/pypo/pypo-cli.py index 0ec569366..f53df5920 100644 --- a/python_apps/pypo/pypo-cli.py +++ b/python_apps/pypo/pypo-cli.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python2.6 # -*- coding: utf-8 -*- """ diff --git a/python_apps/pypo/pypo-notify.py b/python_apps/pypo/pypo-notify.py index 255d7429c..45461f8b3 100644 --- a/python_apps/pypo/pypo-notify.py +++ b/python_apps/pypo/pypo-notify.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python2.6 # -*- coding: utf-8 -*- """ diff --git a/python_apps/pypo/util/status.py b/python_apps/pypo/util/status.py index 8dd893457..1ea3f816a 100644 --- a/python_apps/pypo/util/status.py +++ b/python_apps/pypo/util/status.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python2.6 # -*- coding: utf-8 -*- import sys import time diff --git a/python_apps/show-recorder/install/recorder-install.py b/python_apps/show-recorder/install/recorder-install.py index 2417d38f0..f09e47755 100644 --- a/python_apps/show-recorder/install/recorder-install.py +++ b/python_apps/show-recorder/install/recorder-install.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python2.6 # -*- coding: utf-8 -*- import time diff --git a/python_apps/show-recorder/install/recorder-uninstall.py b/python_apps/show-recorder/install/recorder-uninstall.py index a4363680c..35e923dfb 100644 --- a/python_apps/show-recorder/install/recorder-uninstall.py +++ b/python_apps/show-recorder/install/recorder-uninstall.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python2.6 # -*- coding: utf-8 -*- import os diff --git a/utils/serbianLatinToCyrillicConverter.py b/utils/serbianLatinToCyrillicConverter.py index 809a2acf7..44c22cd32 100644 --- a/utils/serbianLatinToCyrillicConverter.py +++ b/utils/serbianLatinToCyrillicConverter.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python2.6 # -*- coding: utf-8 -*- #------------------------------------------------------------------------------- # Copyright (c) 2010 Sourcefabric O.P.S.