-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathInit.php
More file actions
83 lines (54 loc) · 1.42 KB
/
Init.php
File metadata and controls
83 lines (54 loc) · 1.42 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
74
75
76
77
78
79
80
81
82
83
<?php
namespace Madeny\lhttps;
use Madeny\lhttps\Path;
use Madeny\lhttps\Config;
use Symfony\Component\Dotenv\Dotenv;
// Init the necessary file and folder
class Init {
public $dirs = ['cnf', 'config', 'csr', 'keys', 'live', 'logs'];
function __construct($domain) {
$i = 0;
$path = Config::path();
foreach ($this->dirs as $value) {
if (!file_exists($path."/".$value)) {
while ($i < 6) {
mkdir($path."/".$this->dirs[$i]);
$i++;
}
return;
}
}
}
public function keygen($path) : Int
{
exec(__DIR__."/../scripts/keygen.sh $path", $output, $error);
return $error;
}
public function ca($path)
{
exec(__DIR__."/../scripts/ca.sh $path", $output, $error);
return $error;
}
public function domain($path, $domain)
{
exec(__DIR__."/../scripts/domain.sh $path $domain", $output, $error);
return $error;
}
public function sign($path, $domain)
{
exec(__DIR__."/../scripts/sign.sh $path $domain", $output, $error);
return $error;
}
public function make($domain)
{
$path = Config::path();
$rootkey = $path."/keys/root.key";
$ca = $path."/csr/root.pem";
$dom = $path."/live/$domain.ssl.key";
$sign = $path."/live/$domain.ssl.crt";
!file_exists($rootkey) ? $this->keygen($path) : 1;
!file_exists($ca) ? $this->ca($path) : 1;
!file_exists($dom) ? $this->domain($path, $domain) : 1;
return !file_exists($sign) ? $this->sign($path, $domain) : 1;
}
}