|
13 | 13 | abstract class RoboFileBase extends \Robo\Tasks { |
14 | 14 |
|
15 | 15 | protected $drush_cmd; |
16 | | - protected $local_user; |
17 | 16 |
|
18 | 17 | protected $drush_bin = "bin/drush"; |
19 | 18 | protected $composer_bin = "composer"; |
@@ -42,14 +41,11 @@ abstract class RoboFileBase extends \Robo\Tasks { |
42 | 41 | protected $php_enable_module_command = 'phpenmod -v ALL'; |
43 | 42 | protected $php_disable_module_command = 'phpdismod -v ALL'; |
44 | 43 |
|
45 | | - protected $web_server_user = 'www-data'; |
46 | | - |
47 | 44 | protected $application_root = "/code/web"; |
48 | 45 | protected $file_public_path = '/shared/public'; |
49 | 46 | protected $file_private_path = '/shared/private'; |
50 | 47 | protected $file_temp_path = '/shared/tmp'; |
51 | 48 | protected $services_yml = "web/sites/default/services.yml"; |
52 | | - protected $settings_php = "web/sites/default/settings.php"; |
53 | 49 |
|
54 | 50 | protected $config = []; |
55 | 51 |
|
@@ -89,7 +85,6 @@ abstract class RoboFileBase extends \Robo\Tasks { |
89 | 85 | */ |
90 | 86 | public function __construct() { |
91 | 87 | $this->drush_cmd = $this->drush_bin; |
92 | | - $this->local_user = $this->getLocalUser(); |
93 | 88 |
|
94 | 89 | // Read config from env vars. |
95 | 90 | $environment_config = $this->readConfigFromEnv(); |
@@ -153,11 +148,11 @@ public function build() { |
153 | 148 | $this->devXdebugDisable(); |
154 | 149 | $this->devComposerValidate(); |
155 | 150 | $this->buildMake(); |
156 | | - $this->buildSetFilesOwner(); |
| 151 | + $this->ensureDirectories(); |
157 | 152 | $this->buildInstall(); |
158 | 153 | $this->configImportPlus(); |
159 | 154 | $this->devCacheRebuild(); |
160 | | - $this->buildSetFilesOwner(); |
| 155 | + $this->ensureDirectories(); |
161 | 156 | $this->devXdebugEnable(); |
162 | 157 | $this->say('Total build duration: ' . date_diff(new DateTime(), $start)->format('%im %Ss')); |
163 | 158 | } |
@@ -198,20 +193,27 @@ public function buildMake($flags = '') { |
198 | 193 | /** |
199 | 194 | * Set the owner and group of all files in the files dir to the web user. |
200 | 195 | */ |
201 | | - public function buildSetFilesOwner() { |
| 196 | + public function ensureDirectories() { |
202 | 197 | $publicDir = getenv('PUBLIC_DIR') ?: $this->file_public_path; |
203 | 198 | $privateDir = getenv('PRIVATE_DIR') ?: $this->file_private_path; |
204 | 199 | $tmpDir = getenv('TMP_DIR') ?: $this->file_temp_path; |
205 | 200 | foreach ([$publicDir, $privateDir, $tmpDir] as $path) { |
206 | 201 | $this->say("Ensuring all directories exist."); |
207 | 202 | $this->_exec("mkdir -p $path"); |
208 | | - $this->say("Setting files directory owner."); |
209 | | - $this->_exec("chown $this->web_server_user:$this->local_user -R $path"); |
210 | 203 | $this->say("Setting directory permissions."); |
211 | 204 | $this->setPermissions($path, '0775'); |
212 | 205 | } |
213 | 206 | } |
214 | 207 |
|
| 208 | + /** |
| 209 | + * Set the owner and group of all files in the files dir to the web user. |
| 210 | + * |
| 211 | + * @deprecated Use ::ensureDirectories instead. |
| 212 | + */ |
| 213 | + public function buildSetFilesOwner() { |
| 214 | + $this->ensureDirectories(); |
| 215 | + } |
| 216 | + |
215 | 217 | /** |
216 | 218 | * Clean config and files, then install Drupal and module dependencies. |
217 | 219 | */ |
@@ -652,17 +654,6 @@ protected function setPermissions($file, $permission) { |
652 | 654 | } |
653 | 655 | } |
654 | 656 |
|
655 | | - /** |
656 | | - * Return the name of the local user. |
657 | | - * |
658 | | - * @return string |
659 | | - * Returns the current user. |
660 | | - */ |
661 | | - protected function getLocalUser() { |
662 | | - $user = posix_getpwuid(posix_getuid()); |
663 | | - return $user['name']; |
664 | | - } |
665 | | - |
666 | 657 | /** |
667 | 658 | * Helper function to check whether a task has completed successfully. |
668 | 659 | * |
|
0 commit comments