-
Notifications
You must be signed in to change notification settings - Fork 3
/
gandi
executable file
·72 lines (61 loc) · 2.1 KB
/
gandi
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
#!/usr/bin/env php
<?php
/**
* @author Laurent Jouanneau
* @copyright 2019 Laurent Jouanneau
* @licence MIT
*/
if (file_exists(__DIR__.'/vendor/autoload.php')) {
require(__DIR__.'/vendor/autoload.php');
}
else if (file_exists(__DIR__.'/../autoload.php')) {
// gandi script is into vendor/bin/
require(__DIR__.'/../autoload.php');
}
else if (file_exists(__DIR__.'/../../autoload.php')) {
// gandi script is into vendor/jelix/gandi-v5/
require(__DIR__.'/../../autoload.php');
}
use Jelix\GandiApi\Configuration;
use Jelix\GandiApi\Command\Application;
use Jelix\GandiApi\Command\Status;
use Jelix\GandiApi\Command\OrganizationList;
use Jelix\GandiApi\Command\LiveDns;
if (getenv('GANDI_APIKEY_FILE')) {
$apiKeyFile = getenv('GANDI_APIKEY_FILE');
}
else {
$apiKeyFile = __DIR__.'/.gandi-apikey';
if (!file_exists($apiKeyFile)) {
if (isset($_SERVER['HOME'])) {
$home = $_SERVER['HOME'];
} elseif (isset($_ENV['HOME'])) {
$home = $_ENV['HOME'];
} elseif (isset($_SERVER['USERPROFILE'])) { // windows
$home = $_SERVER['USERPROFILE'];
} elseif (isset($_SERVER['HOMEDRIVE'], $_SERVER['HOMEPATH'])) { // windows
$home = $_SERVER['HOMEDRIVE'].$_SERVER['HOMEPATH'];
}
if ($home) {
if (file_exists($home.DIRECTORY_SEPARATOR.'.gandi-apikey')) {
$apiKeyFile = $home.DIRECTORY_SEPARATOR.'.gandi-apikey';
} else {
// windows users don't often use dot files.
$apiKeyFile = $home.DIRECTORY_SEPARATOR.'gandi-apikey';
}
}
}
}
if (!file_exists($apiKeyFile)) {
echo "Error: API key for Gandi is missing\n";
exit(1);
}
$configuration = new Configuration(file_get_contents($apiKeyFile));
$application = new Application($configuration);
$application->add(new Status());
$application->add(new OrganizationList());
$application->add(new LiveDns\DomainsList());
$application->add(new LiveDns\RecordsList());
$application->add(new LiveDns\RecordCreate());
$application->add(new LiveDns\RecordDelete());
$application->run();