|
1
|
|
|
<?php |
|
2
|
|
|
namespace Kunstmaan\Skylab\Skeleton; |
|
3
|
|
|
|
|
4
|
|
|
use Kunstmaan\Skylab\Entity\PermissionDefinition; |
|
5
|
|
|
use Symfony\Component\Finder\Finder; |
|
6
|
|
|
use Symfony\Component\Process\Process; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* ApacheSkeleton |
|
10
|
|
|
*/ |
|
11
|
|
|
class SymfonySkeleton extends AbstractSkeleton |
|
12
|
|
|
{ |
|
13
|
|
|
|
|
14
|
|
|
const NAME = "symfony"; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* @return string |
|
18
|
|
|
*/ |
|
19
|
|
|
public function getName() |
|
20
|
|
|
{ |
|
21
|
|
|
return self::NAME; |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @param \ArrayObject $project |
|
26
|
|
|
* |
|
27
|
|
|
* @return mixed |
|
28
|
|
|
*/ |
|
29
|
|
|
public function create(\ArrayObject $project) |
|
30
|
|
|
{ |
|
31
|
|
|
$this->fileSystemProvider->createDirectory($project, 'data/' . $project["name"]); |
|
32
|
|
|
$this->fileSystemProvider->createDirectory($project, 'data'); |
|
33
|
|
|
{ |
|
34
|
|
|
$permissionDefinition = new PermissionDefinition(); |
|
35
|
|
|
$permissionDefinition->setPath("/data"); |
|
36
|
|
|
$permissionDefinition->setOwnership("-R @project.user@[email protected]@"); |
|
37
|
|
|
$permissionDefinition->addAcl("-R -m user::rwX"); |
|
38
|
|
|
$permissionDefinition->addAcl("-R -m group::r-X"); |
|
39
|
|
|
$permissionDefinition->addAcl("-R -m other::---"); |
|
40
|
|
|
$permissionDefinition->addAcl("-R -m u:@config.wwwuser@:r-X"); |
|
41
|
|
|
$project["permissions"]["/data"] = $permissionDefinition; |
|
42
|
|
|
} |
|
43
|
|
|
$project = $this->addReadWriteFolder("/data/" . $project["name"] . "/app/cache", $project); |
|
44
|
|
|
$project = $this->addReadWriteFolder("/data/" . $project["name"] . "/var/cache", $project); |
|
45
|
|
|
$project = $this->addReadWriteFolder("/data/" . $project["name"] . "/app/logs", $project); |
|
46
|
|
|
$project = $this->addReadWriteFolder("/data/" . $project["name"] . "/var/logs", $project); |
|
47
|
|
|
$project = $this->addReadWriteFolder("/data/" . $project["name"] . "/web/media", $project); |
|
48
|
|
|
$project = $this->addReadWriteFolder("/data/current/app/cache", $project); |
|
49
|
|
|
$project = $this->addReadWriteFolder("/data/current/var/cache", $project); |
|
50
|
|
|
$project = $this->addReadWriteFolder("/data/current/app/logs", $project); |
|
51
|
|
|
$project = $this->addReadWriteFolder("/data/current/var/logs", $project); |
|
52
|
|
|
$project = $this->addReadWriteFolder("/data/current/web/media", $project); |
|
53
|
|
|
|
|
54
|
|
|
$this->fileSystemProvider->renderDistConfig($this->fileSystemProvider->getConfigTemplateDir("symfony"),$this->fileSystemProvider->getConfigTemplateDir("symfony",true),$this->fileSystemProvider->getProjectConfigDirectory($project["name"]) . "/apache.d/"); |
|
55
|
|
|
|
|
56
|
|
|
$this->fileSystemProvider->render( |
|
57
|
|
|
"/symfony/nginx.d/01start.conf.twig", |
|
58
|
|
|
$this->fileSystemProvider->getProjectConfigDirectory($project["name"]) . "/nginx.d/01start", |
|
59
|
|
|
array() |
|
60
|
|
|
); |
|
61
|
|
|
$this->fileSystemProvider->render( |
|
62
|
|
|
"/symfony/nginx.d/10location.conf.twig", |
|
63
|
|
|
$this->fileSystemProvider->getProjectConfigDirectory($project["name"]) . "/nginx.d/10location", |
|
64
|
|
|
array() |
|
65
|
|
|
); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* @param $path |
|
70
|
|
|
* @param \ArrayObject $project |
|
71
|
|
|
* @return \ArrayObject |
|
72
|
|
|
*/ |
|
73
|
|
|
private function addReadWriteFolder($path, \ArrayObject $project) |
|
74
|
|
|
{ |
|
75
|
|
|
$permissionDefinition = new PermissionDefinition(); |
|
76
|
|
|
$permissionDefinition->setPath($path); |
|
77
|
|
|
$permissionDefinition->setOwnership("-R @project.user@[email protected]@"); |
|
78
|
|
|
$permissionDefinition->addAcl("-R -m user::rwX"); |
|
79
|
|
|
$permissionDefinition->addAcl("-R -m group::r-X"); |
|
80
|
|
|
$permissionDefinition->addAcl("-R -m other::---"); |
|
81
|
|
|
$permissionDefinition->addAcl("-R -m u:@config.wwwuser@:rwX"); |
|
82
|
|
|
$project["permissions"][$path] = $permissionDefinition; |
|
83
|
|
|
|
|
84
|
|
|
return $project; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* @return mixed |
|
89
|
|
|
*/ |
|
90
|
|
|
public function preMaintenance() |
|
91
|
|
|
{ |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
/** |
|
95
|
|
|
* @return mixed |
|
96
|
|
|
*/ |
|
97
|
|
|
public function postMaintenance() |
|
98
|
|
|
{ |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
/** |
|
102
|
|
|
* @param \ArrayObject $project |
|
103
|
|
|
* |
|
104
|
|
|
* @return mixed |
|
105
|
|
|
*/ |
|
106
|
|
|
public function maintenance(\ArrayObject $project) |
|
107
|
|
|
{ |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
/** |
|
111
|
|
|
* @param \ArrayObject $project |
|
112
|
|
|
* |
|
113
|
|
|
* @return mixed |
|
114
|
|
|
*/ |
|
115
|
|
|
public function preBackup(\ArrayObject $project) |
|
116
|
|
|
{ |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
/** |
|
120
|
|
|
* @param \ArrayObject $project |
|
121
|
|
|
* |
|
122
|
|
|
* @return mixed |
|
123
|
|
|
*/ |
|
124
|
|
|
public function postBackup(\ArrayObject $project) |
|
125
|
|
|
{ |
|
126
|
|
|
} |
|
127
|
|
|
|
|
128
|
|
|
/** |
|
129
|
|
|
* @param \ArrayObject $project |
|
130
|
|
|
* |
|
131
|
|
|
* @return mixed |
|
132
|
|
|
*/ |
|
133
|
|
|
public function preRemove(\ArrayObject $project) |
|
134
|
|
|
{ |
|
135
|
|
|
} |
|
136
|
|
|
|
|
137
|
|
|
/** |
|
138
|
|
|
* @param \ArrayObject $project |
|
139
|
|
|
* |
|
140
|
|
|
* @return mixed |
|
141
|
|
|
*/ |
|
142
|
|
|
public function postRemove(\ArrayObject $project) |
|
143
|
|
|
{ |
|
144
|
|
|
} |
|
145
|
|
|
|
|
146
|
|
|
/** |
|
147
|
|
|
* @return string[] |
|
148
|
|
|
*/ |
|
149
|
|
|
public function dependsOn() |
|
150
|
|
|
{ |
|
151
|
|
|
return array("base", "php5", "mysql", "anacron"); |
|
152
|
|
|
} |
|
153
|
|
|
|
|
154
|
|
|
} |
|
155
|
|
|
|