-
Notifications
You must be signed in to change notification settings - Fork 701
Expand file tree
/
Copy pathpack.php
More file actions
executable file
·77 lines (58 loc) · 1.88 KB
/
pack.php
File metadata and controls
executable file
·77 lines (58 loc) · 1.88 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env php
<?php
/* This is the base directory of the simpleSAMLphp installation. */
$baseDir = dirname(dirname(__FILE__));
/* Add library autoloader. */
require_once($baseDir . '/lib/_autoload.php');
if (count($argv) < 1) {
echo "Wrong number of parameters. Run: " . $argv[0] . " [install,show] url [branch]\n"; exit;
}
// Needed in order to make session_start to be called before output is printed.
$session = SimpleSAML_Session::getInstance();
$config = SimpleSAML_Configuration::getConfig('config.php');
$action = $argv[1];
function getModinfo() {
global $argv;
if (count($argv) < 2)
throw new Exception('Missing second parameter: URL/ID');
return sspmod_core_ModuleDefinition::load($argv[2]);
}
function getBranch() {
global $argv;
if (isset($argv[3])) return $argv[3];
return NULL;
}
switch($action) {
case 'install':
$mod = getModinfo();
$installer = new sspmod_core_ModuleInstaller($mod);
$installer->install(getBranch());
break;
case 'remove':
$mod = getModinfo();
$installer = new sspmod_core_ModuleInstaller($mod);
$installer->remove(getBranch());
break;
case 'upgrade':
$mod = getModinfo();
$installer = new sspmod_core_ModuleInstaller($mod);
$installer->upgrade(getBranch());
break;
case 'upgrade-all' :
$mdir = scandir($config->getBaseDir() . 'modules/');
foreach($mdir AS $md) {
if (!sspmod_core_ModuleDefinition::validId($md)) continue;
if (!sspmod_core_ModuleDefinition::isDefined($md)) continue;
$moduledef = sspmod_core_ModuleDefinition::load($md, 'remote');
$installer = new sspmod_core_ModuleInstaller($moduledef);
if ($moduledef->updateExists() || $moduledef->alwaysUpdate()) {
echo "Upgrading [" . $md . "]\n";
$installer->upgrade();
} else {
echo "No updates available for [" . $md . "]\n";
}
}
break;
default:
throw new Exception('Unknown action [' . $action . ']');
}