forked from schorschii/OCO-Server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconsole.php
executable file
·52 lines (42 loc) · 1.24 KB
/
console.php
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
#!/usr/bin/env php
<?php
if(php_sapi_name() != 'cli')
die('This script must be executed from command line.'."\n");
if(!isset($argv[1]))
die('Please specify an action as first parameter.'."\n");
require_once(__DIR__.'/loader.inc.php');
$extensionMethods = $ext->getAggregatedConf('console-methods');
try {
switch($argv[1]) {
case 'housekeeping':
$houseKeeping = new HouseKeeping($db, $ext, true);
$houseKeeping->cleanup();
break;
case 'ldapsync':
$ldapSync = new LdapSync($db, true);
echo '<===== Syncing System Users =====>'."\n";
$ldapSync->syncSystemUsers();
echo '<===== Syncing Domain Users =====>'."\n";
$ldapSync->syncDomainUsers();
break;
case 'upgradeschema':
$migrator = new DatabaseMigrationController($db->getDbHandle(), true);
if($migrator->upgrade()) {
echo 'Database schema upgraded successfully.'."\n";
} else {
echo 'Database schema is already up to date.'."\n";
}
break;
default:
if(array_key_exists($argv[1], $extensionMethods)) {
call_user_func($extensionMethods[$argv[1]], $db);
die();
}
throw new Exception('unknown command');
}
} catch(Exception $e) {
echo $argv[1].' ERROR: '.$e->getMessage()."\n";
echo $e->getTraceAsString();
echo "\n";
exit(1);
}