|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Sunnysideup\UpgradeToSilverstripe4\Tasks\IndividualTasks; |
|
4
|
|
|
|
|
5
|
|
|
use Sunnysideup\UpgradeToSilverstripe4\Tasks\Task; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* Checks that all the directories needed to run this tool exist and are writable. |
|
9
|
|
|
*/ |
|
10
|
|
|
class CheckThatFoldersAreReady extends Task |
|
11
|
|
|
{ |
|
12
|
|
|
protected $taskStep = 's10'; |
|
13
|
|
|
|
|
14
|
|
|
public function getTitle() |
|
15
|
|
|
{ |
|
16
|
|
|
return 'Check Folders Are Ready'; |
|
17
|
|
|
} |
|
18
|
|
|
|
|
19
|
|
|
public function getDescription() |
|
20
|
|
|
{ |
|
21
|
|
|
return ' |
|
22
|
|
|
Checks that all the directories needed to run this tool exist and are writable. |
|
23
|
|
|
'; |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* Checks that the required folder variables link to folders that file_exists |
|
28
|
|
|
* and which are writable. |
|
29
|
|
|
*/ |
|
30
|
|
|
public function runActualTask($params = []) |
|
31
|
|
|
{ |
|
32
|
|
|
$abovewebdir = $this->mu()->getAboveWebRootDirLocation(); |
|
|
|
|
|
|
33
|
|
|
//check dir above web dir exists |
|
34
|
|
|
if (! file_exists($abovewebdir)) { |
|
35
|
|
|
$this->mu()->colourPrint('Above web dir does not exists: ' . $abovewebdir, 'red'); |
|
36
|
|
|
return 'No point in running tool with directory not ready'; |
|
37
|
|
|
} |
|
38
|
|
|
//Directory exists, now check if writable. |
|
39
|
|
|
if (! is_writable($abovewebdir)) { |
|
40
|
|
|
//Not writable send warning |
|
41
|
|
|
$this->mu()->colourPrint('Above web dir is not writable: ' . $abovewebdir, 'red'); |
|
42
|
|
|
return 'No point in running tool with directory not ready'; |
|
43
|
|
|
} |
|
44
|
|
|
//It has been found and is writable; Success! |
|
45
|
|
|
$this->mu()->colourPrint('Found and checked above web dir ✔', 'green'); |
|
46
|
|
|
|
|
47
|
|
|
//LogFileLocation |
|
48
|
|
|
$logDir = $this->mu()->getLogFolderDirLocation(); |
|
|
|
|
|
|
49
|
|
|
if ($logDir) { |
|
50
|
|
|
//check that log dir is exists |
|
51
|
|
|
if (! file_exists($logDir)) { |
|
52
|
|
|
return 'Log dir not exists: ' . $logDir . ' set your log dir to an empty string if you prefer to continue without a log.'; |
|
53
|
|
|
} |
|
54
|
|
|
//Directory exists, now check if writable. |
|
55
|
|
|
if (! is_writable($logDir)) { |
|
56
|
|
|
return $logDir . ' is not writable' . '. Set the log dir to an empty string or provide a writable directory. '; |
|
57
|
|
|
} |
|
58
|
|
|
//all ok |
|
59
|
|
|
} |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
protected function hasCommitAndPush() |
|
63
|
|
|
{ |
|
64
|
|
|
return false; |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|