/
pirrot
executable file
·57 lines (48 loc) · 1.68 KB
/
pirrot
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
#!/usr/bin/env php
<?php
pcntl_async_signals(true);
use Ballen\Clip\Utilities\CommandRouter;
use Ballen\Clip\Exceptions\CommandNotFoundException;
use Ballen\Pirrot\Commands\ArchiveCommand;
use Ballen\Pirrot\Commands\IdentCommand;
use Ballen\Pirrot\Commands\SetAdminPwdCommand;
use Ballen\Pirrot\Commands\TripwireCommand;
use Ballen\Pirrot\Commands\VersionCommand;
use Ballen\Pirrot\Commands\VoiceCommand;
use Ballen\Pirrot\Commands\UpdateCommand;
use Ballen\Pirrot\Commands\HelpCommand;
use Ballen\Pirrot\Commands\TerminateCommand;
use Ballen\Pirrot\Commands\WebCommand;
use Ballen\Pirrot\Commands\PurgeCommand;
// Set the current directory of the CLI script.
$bindir = dirname(__FILE__);
// Initiate the Composer autoloader.
require_once $bindir . '/vendor/autoload.php';
$app = new CommandRouter($argv);
// Demonised commands
$app->add('ident', IdentCommand::class);
$app->add('voice', VoiceCommand::class);
$app->add('web', WebCommand::class);
// User CLI commands
$app->add('update', UpdateCommand::class);
$app->add('help', HelpCommand::class);
$app->add('version', VersionCommand::class);
$app->add('setwebpwd', SetAdminPwdCommand::class);
// System/BackgroundApp commands
$app->add('cleanup', TerminateCommand::class);
$app->add('tripwire', TripwireCommand::class);
$app->add('archive', ArchiveCommand::class);
$app->add('purge', PurgeCommand::class);
// Register process signal handlers
pcntl_signal(SIGINT, function ($signal) use ($app) {
$app->dispatch('cleanup');
});
pcntl_signal(SIGTERM, function ($signal) use ($app) {
$app->dispatch('cleanup');
});
// Boot the application/daemon
try {
$app->dispatch();
} catch (CommandNotFoundException $exception) {
$app->dispatch('help');
}