1 | <?php |
||
10 | class NoSudo extends InstallerTask implements DependentChainProcessInterface |
||
11 | { |
||
12 | /** |
||
13 | * @var ProcessRunner |
||
14 | */ |
||
15 | private $processRunner; |
||
16 | /** |
||
17 | * @var UserInteraction |
||
18 | */ |
||
19 | private $userInteraction; |
||
20 | |||
21 | /** |
||
22 | * @param UserInteraction $userInteraction |
||
23 | * @param ProcessRunner $processRunner |
||
24 | */ |
||
25 | public function __construct(UserInteraction $userInteraction, ProcessRunner $processRunner) |
||
26 | { |
||
27 | $this->userInteraction = $userInteraction; |
||
28 | $this->processRunner = $processRunner; |
||
29 | } |
||
30 | |||
31 | /** |
||
32 | * {@inheritdoc} |
||
33 | */ |
||
34 | public function dependsOn() |
||
38 | |||
39 | /** |
||
40 | * {@inheritdoc} |
||
41 | */ |
||
42 | public function getName() |
||
46 | |||
47 | public function run() |
||
48 | { |
||
49 | if (!$this->isCurrentUserInDockerGroup()) { |
||
50 | $this->userInteraction->writeTitle('Making docker work without sudo'); |
||
51 | $this->processRunner->run('sudo usermod -a -G docker $USER'); |
||
52 | } |
||
53 | } |
||
54 | |||
55 | private function isCurrentUserInDockerGroup() |
||
59 | } |
||
60 |