-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
50 lines (41 loc) · 1.31 KB
/
index.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
<?php
$time_start = microtime(true);
require_once('vendor/autoload.php');
try {
$options = getopt('c:k:', ['cert:', 'key:', 'certId:', 'conf:']);
$cert = $options['c'] ?? $options['cert'] ?? null;
$key = $options['k'] ?? $options['key'] ?? null;
$certId = $options['certId'] ?? null;
$conf = $options['conf'] ?? 'config.php';
if ((($cert ?? $key ?? null) ?? $certId) === null) {
echo <<<USAGE
Usage:
-c, --cert full chain cert
-k, --key cert key
--certId certId on Tencent Cloud, will skip to deployment
--conf config to use (default: config.php)
USAGE;
exit;
}
require_once('lib.php');
init();
if ($certId === null) {
$cert = file_get_contents($cert);
$key = file_get_contents($key);
$certId = uploadCert($cert, $key);
echo "New cert " . $certId . ".\n";
} else {
echo "Existing cert " . $certId . ".\n";
}
if ($config['CDN']['enable']) {
foreach ($config['CDN']['domains'] as $domain => $parameters) {
deployToCDN($domain, $certId, $parameters);
}
}
$time_end = microtime(true);
$execution_time = $time_end - $time_start;
echo "Finished in " . $execution_time . "s.\n";
} catch (Exception $e) {
echo $e->getMessage();
exit(1);
}