Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docker/phraseanet/setup/init-test-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ sleep 10
--lazaret-path=$PHRASEANET_LAZARET_DIR \
--caption-path=$PHRASEANET_CAPTION_DIR \
--worker-tmp-files=$PHRASEANET_WORKER_TMP \
--data-path=/var/alchemy/Phraseanet/datas -y
--data-path=/var/alchemy/Phraseanet/datas -f
done

/var/alchemy/Phraseanet/bin/setup system:config set workers.queue.worker-queue.registry alchemy_worker.queue_registry
Expand Down
56 changes: 24 additions & 32 deletions lib/Alchemy/Phrasea/Command/Setup/Install.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public function __construct($name, $structureTemplate)
->addOption('scheduler-locks-path', null, InputOption::VALUE_OPTIONAL, 'Path to scheduler-locks repository', __DIR__ . '/../../../../../tmp/locks')
->addOption('worker-tmp-files', null, InputOption::VALUE_OPTIONAL, 'Path to worker-tmp-files repository', __DIR__ . '/../../../../../tmp')
->addOption('yes', 'y', InputOption::VALUE_NONE, 'Answer yes to all questions')
->addOption('force', 'f', InputOption::VALUE_NONE, 'force to continue installation')
->setHelp("Phraseanet can only be installed on 64 bits PHP.");
;

Expand Down Expand Up @@ -93,32 +94,9 @@ protected function doExecute(InputInterface $input, OutputInterface $output)
/** @var DialogHelper $dialog */
$dialog = $this->getHelperSet()->get('dialog');

$output->writeln("<comment>
,-._.-._.-._.-._.-.
`-. ,-'
.----------------------------------------------. | |
| | | |
| Hello ! | | |
| | | |
| You are on your way to install Phraseanet, | ,';\".________.-.
| You will need access to 2 MySQL databases. | ;';_' )]
| | ; `-|
| `. `T- |
`----------------------------------------------._ \ | |
`-; | |
|..________..-|
/\/ |________..|
,'`./ >,( |
\_.-|_/,-/ ii | |
`.\"' `-/ .-\"\"\"|| |
/`^\"-; | ||____|
/ / `.__/ | ||
/ | ||
| ||
</comment>"
);

if (!$input->getOption('yes') && !$input->getOption('appbox')) {
$output->writeln("<comment> --- You are on your way to install Phraseanet, You will need access to 2 MySQL databases. --- </comment>");

if (!$input->getOption('yes') && !$input->getOption('force') && !$input->getOption('appbox')) {
$continue = $dialog->askConfirmation($output, 'Do you have these two DB handy ? (N/y)', false);

if (!$continue) {
Expand All @@ -130,16 +108,30 @@ protected function doExecute(InputInterface $input, OutputInterface $output)

$serverName = $this->getServerName($input, $output, $dialog);

/** @var Connection $abConn */
$abConn = $this->getABConn($input, $output, $dialog, $serverName);
if(!$abConn) {
return 1; // no ab is fatal
}

if (!$input->getOption('force') && $abConn->getSchemaManager()->tablesExist(['users'])) {
$output->writeln("<error>(*) Database table already exist in appbox! installation abort</error>");

return 1;
}

list($dbConn, $templateName) = $this->getDBConn($input, $output, $abConn, $dialog);

if (!$input->getOption('force') && $dbConn->getSchemaManager()->tablesExist(['record'])) {
$output->writeln("<error>(*) Database table already exist in databox! installation abort</error>");

return 1;
}

list($email, $password) = $this->getCredentials($input, $output, $dialog);
$dataPath = $this->getDataPath($input, $output, $dialog);

if (! $input->getOption('yes')) {
if (!$input->getOption('yes') && !$input->getOption('force')) {
$output->writeln("<info>--- ElasticSearch connection settings ---</info>");
}

Expand All @@ -154,7 +146,7 @@ protected function doExecute(InputInterface $input, OutputInterface $output)

$output->writeln('');

if (!$input->getOption('yes')) {
if (!$input->getOption('yes') && !$input->getOption('force')) {
$continue = $dialog->askConfirmation($output, "<question>Phraseanet is going to be installed, continue ? (N/y)</question>", false);

if (!$continue) {
Expand Down Expand Up @@ -341,7 +333,7 @@ private function getDataPath(InputInterface $input, OutputInterface $output, Dia
{
$dataPath = $input->getOption('data-path');

if (!$input->getOption('yes')) {
if (!$input->getOption('yes') && !$input->getOption('force')) {
$continue = $dialog->askConfirmation($output, 'Would you like to change default data-path ? (N/y)', false);

if ($continue) {
Expand All @@ -362,7 +354,7 @@ private function getServerName(InputInterface $input, OutputInterface $output, D
{
$serverName = $input->getOption('server-name');

if (!$serverName && !$input->getOption('yes')) {
if (!$serverName && !$input->getOption('yes') && !$input->getOption('force')) {
do {
$serverName = $dialog->ask($output, 'Please provide the server name : ', null);
} while (!$serverName);
Expand All @@ -380,7 +372,7 @@ private function getESHost(InputInterface $input, OutputInterface $output, Dialo
$host = $input->getOption('es-host');
$port = (int) $input->getOption('es-port');

if (! $input->getOption('yes')) {
if (! $input->getOption('yes') && !$input->getOption('force')) {
while (! $host) {
$host = $dialog->ask($output, 'ElasticSearch server host : ', null);
};
Expand All @@ -397,7 +389,7 @@ private function getESIndexName(InputInterface $input, OutputInterface $output,
{
$index = $input->getOption('es-index');

if (! $input->getOption('yes')) {
if (!$input->getOption('yes') && !$input->getOption('force')) {
$index = $dialog->ask($output, 'ElasticSearch server index name (blank to autogenerate) : ', null);
}

Expand Down
Loading