Skip to content

Commit

Permalink
Merge pull request #110 from joomlatools/feature/109-restarts
Browse files Browse the repository at this point in the history
Merge feature/109-restarts
  • Loading branch information
Steven Rombauts authored Jul 10, 2019
2 parents e8cabf2 + a6cb292 commit 2e6f0ab
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
16 changes: 11 additions & 5 deletions src/Joomlatools/Console/Command/Vhost/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
throw new \RuntimeException(sprintf('Site not found: %s', $this->site));
}

$port = $input->getOption('http-port');
$path = realpath(__DIR__.'/../../../../../bin/.files/');

$tmp = '/tmp/vhost.tmp';

$variables = $this->_getVariables($input);
Expand All @@ -107,7 +104,8 @@ protected function execute(InputInterface $input, OutputInterface $output)

`sudo tee /etc/apache2/sites-available/1-$site.conf < $tmp`;
`sudo a2ensite 1-$site.conf`;
`sudo /etc/init.d/apache2 restart > /dev/null 2>&1`;

$restart[] = 'apache';

@unlink($tmp);
}
Expand All @@ -130,10 +128,18 @@ protected function execute(InputInterface $input, OutputInterface $output)

`sudo tee /etc/nginx/sites-available/1-$site.conf < $tmp`;
`sudo ln -fs /etc/nginx/sites-available/1-$site.conf /etc/nginx/sites-enabled/1-$site.conf`;
`sudo /etc/init.d/nginx restart > /dev/null 2>&1`;

$restart[] = 'nginx';

@unlink($tmp);
}

if (Util::isJoomlatoolsBox() && $restart)
{
$arguments = implode(' ', $restart);

`box server:restart $arguments`;
}
}

protected function _getVariables(InputInterface $input)
Expand Down
20 changes: 15 additions & 5 deletions src/Joomlatools/Console/Command/Vhost/Remove.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

namespace Joomlatools\Console\Command\Vhost;

use Joomlatools\Console\Joomla\Util;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

class Remove extends Command
Expand All @@ -32,14 +32,16 @@ protected function configure()

protected function execute(InputInterface $input, OutputInterface $output)
{
$site = $input->getArgument('site');
$file = '/etc/apache2/sites-available/1-' . $site . '.conf';
$site = $input->getArgument('site');
$restart = [];
$file = '/etc/apache2/sites-available/1-' . $site . '.conf';

if (is_file($file))
{
`sudo a2dissite 1-$site.conf`;
`sudo rm $file`;
`sudo /etc/init.d/apache2 restart > /dev/null 2>&1`;

$restart[] = 'apache';
}

$file = '/etc/nginx/sites-available/1-' . $site . '.conf';
Expand All @@ -48,7 +50,15 @@ protected function execute(InputInterface $input, OutputInterface $output)
{
`sudo rm -f $file`;
`sudo rm -f /etc/nginx/sites-enabled/1-$site.conf`;
`sudo /etc/init.d/nginx restart > /dev/null 2>&1`;

$restart[] = 'nginx';
}

if (Util::isJoomlatoolsBox() && $restart)
{
$arguments = implode(' ', $restart);

`box server:restart $arguments`;
}
}
}

0 comments on commit 2e6f0ab

Please sign in to comment.