76 lines
2.2 KiB
PHP
Executable File
76 lines
2.2 KiB
PHP
Executable File
#!/usr/bin/env php
|
|
<?php
|
|
/**
|
|
* Script to run a Horde_LoginTasks task and/or system task.
|
|
*
|
|
* Copyright 2010-2017 Horde LLC (http://www.horde.org/)
|
|
*
|
|
* See the enclosed file COPYING for license information (LGPL-2). If you
|
|
* did not receive this file, see http://www.horde.org/licenses/lgpl.
|
|
*
|
|
* @author Michael Slusarz <slusarz@horde.org>
|
|
* @category Horde
|
|
* @license http://www.horde.org/licenses/lgpl LGPL-2
|
|
* @package Horde
|
|
*/
|
|
|
|
$baseFile = __DIR__ . '/../lib/Application.php';
|
|
if (file_exists($baseFile)) {
|
|
require_once $baseFile;
|
|
} else {
|
|
require_once 'PEAR/Config.php';
|
|
require_once PEAR_Config::singleton()
|
|
->get('horde_dir', null, 'pear.horde.org') . '/lib/Application.php';
|
|
}
|
|
Horde_Registry::appInit('horde', array('cli' => true));
|
|
|
|
$parser = new Horde_Argv_Parser();
|
|
$parser->addOption('-a', '--app', array(
|
|
'dest' => 'app',
|
|
'help' => 'Application name'
|
|
));
|
|
$parser->addOption('-t', '--taskname', array(
|
|
'dest' => 'taskname',
|
|
'help' => 'Name of the file in the application\'s SystemTask/Task directory without the .php extension'
|
|
));
|
|
$parser->addOption('-u', '--username', array(
|
|
'dest' => 'username',
|
|
'help' => 'Username'
|
|
));
|
|
list($values,) = $parser->parseArgs();
|
|
|
|
if (!isset($values->app)) {
|
|
$cli->fatal('Missing application name.');
|
|
}
|
|
|
|
if (!isset($values->taskname)) {
|
|
$cli->fatal('Missing taskname.');
|
|
}
|
|
|
|
if (!isset($values->username)) {
|
|
$cli->fatal('Missing username.');
|
|
}
|
|
|
|
$registry->setAuth($values->username, array());
|
|
$registry->pushApp($values->app, array('check_perms' => false));
|
|
|
|
$class = $values->app . '_LoginTasks_SystemTask_' . $values->taskname;
|
|
if (!class_exists($class)) {
|
|
$class = $values->app . '_LoginTasks_Task_' . $values->taskname;
|
|
if (!class_exists($class)) {
|
|
$cli->fatal('Could not find task "' . $values->taskname . '".');
|
|
}
|
|
}
|
|
|
|
$ob = new $class();
|
|
if (($ob instanceof Horde_LoginTasks_SystemTask) && $ob->skip()) {
|
|
$cli->message('System task was skipped.', 'cli.warning');
|
|
} else{
|
|
if ($ob instanceof Horde_Core_LoginTasks_SystemTask_Upgrade) {
|
|
$ob->forceUpgrade();
|
|
} else {
|
|
$ob->execute();
|
|
}
|
|
$cli->message('Completed task.', 'cli.success');
|
|
}
|