Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env php
<?php
require_once "modules/class.module.php";
class Manager extends Module {
var $prologue =
"Manage one or more osTicket installations";
var $arguments = array(
'action' => "Action to be managed"
);
var $usage = '$script action [options] [arguments]';
var $autohelp = false;
function showHelp() {
foreach (glob(dirname(__file__).'/modules/*.php') as $script)
include_once $script;
global $registered_modules;
$this->epilog =
"Currently available modules follow. Use 'manage.php <module>
--help' for usage regarding each respective module:";
parent::showHelp();
echo "\n";
foreach ($registered_modules as $name=>$mod)
echo str_pad($name, 20) . $mod->prologue . "\n";
}
function run() {
if ($this->getOption('help') && !$this->getArgument('action'))
$this->showHelp();
else {
$action = $this->getArgument('action');
global $argv;
foreach ($argv as $idx=>$val)
if ($val == $action)
unset($argv[$idx]);
include_once dirname(__file__) . '/modules/' . $action . '.php';
$module = Module::getInstance($action);
$module->run();
}
}
}
if (php_sapi_name() != "cli")
die("Management only supported from command-line\n");
$manager = new Manager();
$manager->parseOptions();
$manager->run();
?>