* [ADD] CHeck whether sysPass is installed

Signed-off-by: Rubén D <nuxsmin@syspass.org>
This commit is contained in:
Rubén D
2021-01-19 08:39:22 +01:00
parent b1f76654cd
commit ff4e8df2e6
3 changed files with 35 additions and 3 deletions

View File

@@ -3,6 +3,8 @@
namespace SP\Modules\Cli\Commands;
use Psr\Log\LoggerInterface;
use SP\Config\Config;
use SP\Config\ConfigData;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Style\SymfonyStyle;
@@ -21,18 +23,32 @@ abstract class CommandBase extends Command
* @var SymfonyStyle
*/
protected $io;
/**
* @var Config
*/
protected $config;
/**
* @var ConfigData
*/
protected $configData;
/**
* CommandBase constructor.
*
* @param LoggerInterface $logger
* @param SymfonyStyle $io
* @param Config $config
*/
public function __construct(LoggerInterface $logger, SymfonyStyle $io)
public function __construct(
LoggerInterface $logger,
SymfonyStyle $io,
Config $config)
{
parent::__construct();
$this->logger = $logger;
$this->io = $io;
$this->config = $config;
$this->configData = $this->config->getConfigData();
}
}

View File

@@ -27,6 +27,7 @@ namespace SP\Modules\Cli\Commands;
use Exception;
use Psr\Log\LoggerInterface;
use RuntimeException;
use SP\Config\Config;
use SP\Core\Exceptions\InvalidArgumentException;
use SP\Core\Language;
use SP\Services\Install\InstallData;
@@ -52,9 +53,10 @@ final class InstallCommand extends CommandBase
public function __construct(LoggerInterface $logger,
SymfonyStyle $io,
Config $config,
Installer $installer)
{
parent::__construct($logger, $io);
parent::__construct($logger, $io, $config);
$this->installer = $installer;
}
@@ -95,7 +97,12 @@ final class InstallCommand extends CommandBase
->addOption('language',
null,
InputOption::VALUE_OPTIONAL,
__('Sets the global app language. You can set a per user language on preferences.'));
__('Sets the global app language. You can set a per user language on preferences.'))
->addOption('force',
null,
InputOption::VALUE_OPTIONAL,
__('Force sysPass installation.'),
false);
}
/**
@@ -106,6 +113,14 @@ final class InstallCommand extends CommandBase
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$force = (bool)$input->getOption('force');
if ($this->configData->isInstalled() && $force === false) {
$this->io->warning(__('sysPass is already installed. Use \'--force\' to install it again.'));
return self::FAILURE;
}
$adminPassword = $input->getOption('adminPassword');
$passNonEmptyValidator = function ($value) {

View File

@@ -113,6 +113,7 @@ final class Bootstrap
* Bootstrap constructor.
*
* @param Container $container
* @param bool $useRouter
*
* @throws DependencyException
* @throws NotFoundException