From 7ac5b33d3b474f98b74a8db97d5d1161c4917887 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Thu, 18 Feb 2010 23:59:00 -0700 Subject: [PATCH] Added run_task script from horde-support --- horde/bin/run_task | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100755 horde/bin/run_task diff --git a/horde/bin/run_task b/horde/bin/run_task new file mode 100755 index 000000000..67e70e767 --- /dev/null +++ b/horde/bin/run_task @@ -0,0 +1,77 @@ +#!/usr/bin/env php + + * @category Horde + */ + +require_once dirname(__FILE__) . '/lib/Application.php'; +Horde_Registry::appInit('horde', array('authentication' => 'none', 'cli' => true)); + +$c = new Console_Getopt(); +$argv = $c->readPHPArgv(); +array_shift($argv); +$options = $c->getopt2($argv, 'a:t:u:'); +if ($options instanceof PEAR_Error) { + $cli->fatal($options->getMessage()); + exit; +} + +foreach ($options[0] as $val) { + switch ($val[0]) { + case 'a': + $app = $val[1]; + break; + + case 't': + $taskname = $val[1]; + break; + + case 'u': + $username = $val[1]; + break; + } +} + +if (empty($app)) { + $cli->fatal('Missing argument to -a.'); + exit; +} + +if (empty($taskname)) { + $cli->fatal('Missing argument to -t.'); + exit; +} + +if (empty($username)) { + $cli->fatal('Missing argument to -u.'); + exit; +} + +Horde_Auth::setAuth($username, array()); +$registry->pushApp($app, array('check_perms' => false)); + +$class = $app . '_LoginTasks_SystemTask_' . $taskname; +if (!class_exists($class)) { + $class = $app . '_LoginTasks_Task_' . $taskname; + if (!class_exists($class)) { + $cli->fatal('Could not find task "' . $taskname . '".'); + } +} + + +$ob = new $class(); +$ob->execute(); + +$cli->message('Completed task.', 'cli.success'); -- 2.11.0