Skip to content

Commit c428c17

Browse files
committed
Merge branch 'develop'
2 parents 327121a + 6674b7d commit c428c17

12 files changed

+145
-11
lines changed

Entity/CapistranoFile.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
namespace DigipolisGent\Domainator9k\ServerTypes\CapistranoOpenmindsBundle\Entity;
55

66
use DigipolisGent\Domainator9k\CoreBundle\Entity\Traits\IdentifiableTrait;
7+
use DigipolisGent\Domainator9k\ServerTypes\CapistranoOpenmindsBundle\Validator\Constraints as CapistranoAssert;
78
use Doctrine\ORM\Mapping as ORM;
89
use Symfony\Component\Validator\Constraints as Assert;
910

@@ -32,13 +33,15 @@ class CapistranoFile
3233
* @var string
3334
*
3435
* @ORM\Column(type="string", nullable=true)
36+
* @Assert\NotBlank()
3537
*/
3638
protected $filename;
3739

3840
/**
3941
* @var string
4042
*
4143
* @ORM\Column(type="string", nullable=true)
44+
* @Assert\NotBlank()
4245
*/
4346
protected $extension;
4447

@@ -50,6 +53,15 @@ class CapistranoFile
5053
*/
5154
protected $location;
5255

56+
/**
57+
* @var int
58+
*
59+
* @ORM\Column(name="chmod",type="smallint",options={"unsigned":true, "default":644})
60+
* @Assert\NotBlank()
61+
* @CapistranoAssert\ChmodMode()
62+
*/
63+
protected $chmod = 644;
64+
5365
/**
5466
* @var string
5567
*
@@ -128,6 +140,22 @@ public function setLocation(string $location)
128140
$this->location = $location;
129141
}
130142

143+
/**
144+
* @return int
145+
*/
146+
public function getChmod()
147+
{
148+
return $this->chmod;
149+
}
150+
151+
/**
152+
* @param int $chmod
153+
*/
154+
public function setChmod($chmod)
155+
{
156+
$this->chmod = (int) $chmod;
157+
}
158+
131159
/**
132160
* @return string
133161
*/

Entity/CapistranoFolder.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
namespace DigipolisGent\Domainator9k\ServerTypes\CapistranoOpenmindsBundle\Entity;
55

66
use DigipolisGent\Domainator9k\CoreBundle\Entity\Traits\IdentifiableTrait;
7+
use DigipolisGent\Domainator9k\ServerTypes\CapistranoOpenmindsBundle\Validator\Constraints as CapistranoAssert;
78
use Doctrine\ORM\Mapping as ORM;
9+
use Symfony\Component\Validator\Constraints as Assert;
810

911
/**
1012
* Class CapistranoFile
@@ -22,16 +24,28 @@ class CapistranoFolder
2224
* @var string
2325
*
2426
* @ORM\Column(name="name",type="string")
27+
* @Assert\NotBlank()
28+
* @Assert\Length(min="2", max="255")
2529
*/
2630
protected $name;
2731

2832
/**
2933
* @var string
3034
*
3135
* @ORM\Column(name="filename",type="string")
36+
* @Assert\NotBlank()
3237
*/
3338
protected $location;
3439

40+
/**
41+
* @var int
42+
*
43+
* @ORM\Column(name="chmod",type="smallint",options={"unsigned":true, "default":750})
44+
* @Assert\NotBlank()
45+
* @CapistranoAssert\ChmodMode(user="7")
46+
*/
47+
protected $chmod = 750;
48+
3549
/**
3650
* @return string
3751
*/
@@ -64,6 +78,22 @@ public function setLocation(string $location)
6478
$this->location = $location;
6579
}
6680

81+
/**
82+
* @return int
83+
*/
84+
public function getChmod()
85+
{
86+
return $this->chmod;
87+
}
88+
89+
/**
90+
* @param int $chmod
91+
*/
92+
public function setChmod($chmod)
93+
{
94+
$this->chmod = (int) $chmod;
95+
}
96+
6797
public function __clone()
6898
{
6999
$this->id = null;

FieldType/AbstractCapistranoFieldType.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
22

3-
43
namespace DigipolisGent\Domainator9k\ServerTypes\CapistranoOpenmindsBundle\FieldType;
54

65
use DigipolisGent\Domainator9k\CoreBundle\Entity\ApplicationEnvironment;
@@ -14,7 +13,6 @@
1413

1514
abstract class AbstractCapistranoFieldType extends AbstractFieldType
1615
{
17-
1816
protected $entityManager;
1917

2018
/**

FieldType/CapistranoCrontabLineFieldType.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
22

3-
43
namespace DigipolisGent\Domainator9k\ServerTypes\CapistranoOpenmindsBundle\FieldType;
54

65
use DigipolisGent\Domainator9k\ServerTypes\CapistranoOpenmindsBundle\Entity\CapistranoCrontabLine;

FieldType/CapistranoFileFieldType.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
22

3-
43
namespace DigipolisGent\Domainator9k\ServerTypes\CapistranoOpenmindsBundle\FieldType;
54

65
use DigipolisGent\Domainator9k\ServerTypes\CapistranoOpenmindsBundle\Entity\CapistranoFile;

FieldType/CapistranoFolderFieldType.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
22

3-
43
namespace DigipolisGent\Domainator9k\ServerTypes\CapistranoOpenmindsBundle\FieldType;
54

65
use DigipolisGent\Domainator9k\ServerTypes\CapistranoOpenmindsBundle\Entity\CapistranoFolder;
@@ -12,7 +11,6 @@
1211
*/
1312
class CapistranoFolderFieldType extends AbstractCapistranoFieldType
1413
{
15-
1614
/**
1715
* @param $value
1816
* @return array

FieldType/CapistranoSymlinkFieldType.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
22

3-
43
namespace DigipolisGent\Domainator9k\ServerTypes\CapistranoOpenmindsBundle\FieldType;
54

65
use DigipolisGent\Domainator9k\ServerTypes\CapistranoOpenmindsBundle\Entity\CapistranoSymlink;
@@ -12,7 +11,6 @@
1211
*/
1312
class CapistranoSymlinkFieldType extends AbstractCapistranoFieldType
1413
{
15-
1614
/**
1715
* @param $value
1816
* @return array

Form/Type/CapistranoFileFormType.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
2525
$builder->add('filename');
2626
$builder->add('extension');
2727
$builder->add('location');
28+
$builder->add('chmod');
2829
$builder->add('content');
2930
}
3031

Form/Type/CapistranoFolderFormType.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
2323
parent::buildForm($builder, $options);
2424
$builder->add('name');
2525
$builder->add('location');
26+
$builder->add('chmod');
2627
}
2728

2829
/**

Provisioner/BuildProvisioner.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ protected function createFolders(SSH2 $ssh, ApplicationEnvironment $applicationE
8989
2
9090
);
9191

92-
$this->executeSshCommand($ssh, 'mkdir -p -m 750 ' . escapeshellarg($path), 3);
92+
$path = escapeshellarg($path);
93+
$cmd = 'mkdir -p ' . $path . ' && chmod ' . $capistranoFolder->getChmod() . ' ' . $path;
94+
$this->executeSshCommand($ssh, $cmd, 3);
9395
}
9496

9597
$this->taskLoggerService->addSuccessLogMessage($this->task, 'Directories created.', 2);
@@ -204,7 +206,7 @@ protected function createFiles(SSH2 $ssh, ApplicationEnvironment $applicationEnv
204206
$command = 'echo ' . ($i === $maxI ? '' : '-n ') . $part . ($i ? ' >> ' : ' > ') . $tmpPath;
205207

206208
if ($i === $maxI) {
207-
$command .= " && ([[ ! -f $path ]] || chmod \$(stat --format '%a' $path) $tmpPath)";
209+
$command .= ' && chmod ' . $capistranoFile->getChmod() . ' ' . $tmpPath;
208210
$command .= ' && mv -f ' . $tmpPath . ' ' . $path;
209211
}
210212

@@ -216,7 +218,7 @@ protected function createFiles(SSH2 $ssh, ApplicationEnvironment $applicationEnv
216218

217219
$content = escapeshellarg($content);
218220
$command = 'echo ' . $content . ' > ' . $tmpPath;
219-
$command .= " && ([[ ! -f $path ]] || chmod \$(stat --format '%a' $path) $tmpPath)";
221+
$command .= ' && chmod ' . $capistranoFile->getChmod() . ' ' . $tmpPath;
220222
$command .= ' && mv -f ' . $tmpPath . ' ' . $path;
221223

222224
$this->executeSshCommand($ssh, $command, 3);

0 commit comments

Comments
 (0)