forked from getchabooks/getchabooks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgb
executable file
·42 lines (35 loc) · 1018 Bytes
/
gb
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
#!/usr/bin/php
<?php
/**
* Single point of entry for command-line scripts.
*/
$wd = exec('pwd');
if (!preg_match("/^(.+\/gb(\/production)?)/", $wd, $matches)) {
echo "$wd is not a GetchaBooks installation.\n";
exit();
}
$scriptPath = "{$matches[1]}/scripts/";
if ($argc == 1) {
echo "Available commands:\n\n";
foreach (scandir($scriptPath) as $file) {
if ($file != "." && $file != "..") {
$parts = explode('.', $file);
echo " " . $parts[0] . "\n";
}
}
} else {
$script = $argv[1];
$argv = array_slice($argv, 1);
$argc--;
if (file_exists("$scriptPath$script.php")) {
require_once 'init.php';
define('BASE_URL', null);
define('MOBILE_DEVICE', null);
$debug = $verbose = true;
require "$scriptPath$script.php";
} else if (file_exists("$scriptPath$script.sh")) {
system("$scriptPath$script.sh " . implode(' ', $argv));
} else {
echo "Unknown command: $script\n";
}
}