add more options during install

This commit is contained in:
aynsix
2020-04-08 11:03:46 +03:00
parent 5a0c71e0d3
commit d8d7c7de51
6 changed files with 58 additions and 8 deletions

View File

@@ -111,7 +111,7 @@ main:
download: null
lazaret: null
caption: null
tmp_files: null
worker_tmp_files: null
border-manager:
enabled: true
extension-mapping:

View File

@@ -55,6 +55,11 @@ class Install extends Command
->addOption('es-host', null, InputOption::VALUE_OPTIONAL, 'ElasticSearch server HTTP host', 'localhost')
->addOption('es-port', null, InputOption::VALUE_OPTIONAL, 'ElasticSearch server HTTP port', 9200)
->addOption('es-index', null, InputOption::VALUE_OPTIONAL, 'ElasticSearch index name', null)
->addOption('download-path', null, InputOption::VALUE_OPTIONAL, 'Path to download repository', '/var/alchemy/Phraseanet/tmp/download')
->addOption('lazaret-path', null, InputOption::VALUE_OPTIONAL, 'Path to lazaret repository', '/var/alchemy/Phraseanet/tmp/lazaret')
->addOption('caption-path', null, InputOption::VALUE_OPTIONAL, 'Path to caption repository', '/var/alchemy/Phraseanet/tmp/caption')
->addOption('scheduler-locks-path', null, InputOption::VALUE_OPTIONAL, 'Path to scheduler-locks repository', '/var/alchemy/Phraseanet/tmp/locks')
->addOption('worker-tmp-files', null, InputOption::VALUE_OPTIONAL, 'Path to worker-tmp-files repository', '/var/alchemy/Phraseanet/tmp')
->addOption('yes', 'y', InputOption::VALUE_NONE, 'Answer yes to all questions');
return $this;
@@ -151,6 +156,7 @@ class Install extends Command
$this->container['phraseanet.installer']->install($email, $password, $abConn, $serverName, $dataPath, $dbConn, $templateName, $this->detectBinaries());
$this->container['conf']->set(['main', 'search-engine', 'options'], $esOptions->toArray());
$this->defineStorageTmpPath($input);
if (null !== $this->getApplication()) {
$command = $this->getApplication()->find('crossdomain:generate');
@@ -387,6 +393,53 @@ class Install extends Command
return $index;
}
private function defineStorageTmpPath(InputInterface $input)
{
$downloadPath = $input->getOption('download-path');
if (!is_dir($downloadPath)) {
mkdir($downloadPath, 0755, true);
}
$lazaretPath = $input->getOption('lazaret-path');
if (!is_dir($lazaretPath)) {
mkdir($lazaretPath, 0755, true);
}
$captionPath = $input->getOption('caption-path');
if (!is_dir($captionPath)) {
mkdir($captionPath, 0755, true);
}
$workerTmpFiles = $input->getOption('worker-tmp-files');
if (!is_dir($workerTmpFiles)) {
mkdir($workerTmpFiles, 0755, true);
}
$schedulerLocksPath = $input->getOption('scheduler-locks-path');
if (!is_dir($schedulerLocksPath)) {
mkdir($schedulerLocksPath, 0755, true);
}
if (($schedulerLocksPath = realpath($schedulerLocksPath)) === FALSE) {
throw new \InvalidArgumentException(sprintf('Path %s does not exist.', $schedulerLocksPath));
}
$config = $this->container['configuration.store']->initialize()->getConfig();
$config['main']['storage']['download'] = realpath($downloadPath);
$config['main']['storage']['lazaret'] = realpath($lazaretPath);
$config['main']['storage']['caption'] = realpath($captionPath);
$config['main']['storage']['worker_tmp_files'] = realpath($workerTmpFiles);
$this->container['configuration.store']->setConfig($config);
}
private function detectBinaries()
{
return [

View File

@@ -181,8 +181,8 @@ class UploadController extends Controller
$uploadedFilename = $file->getRealPath();
$renamedFilename = null;
if(!empty($this->app['conf']->get(['main', 'storage', 'tmp_files']))) {
$tmpStorage = \p4string::addEndSlash($this->app['conf']->get(['main', 'storage', 'tmp_files'])).'upload/';
if(!empty($this->app['conf']->get(['main', 'storage', 'worker_tmp_files']))) {
$tmpStorage = \p4string::addEndSlash($this->app['conf']->get(['main', 'storage', 'worker_tmp_files'])).'upload/';
if(!is_dir($tmpStorage)){
$this->getFilesystem()->mkdir($tmpStorage);

View File

@@ -57,7 +57,7 @@ class SubdefGenerator
$this->filesystem = $filesystem;
$this->logger = $logger;
$this->mediavorus = $mediavorus;
$this->tmpDirectory = $this->app['conf']->get(['main', 'storage', 'tmp_files']);;
$this->tmpDirectory = $this->app['conf']->get(['main', 'storage', 'worker_tmp_files']);;
}
public function generateSubdefs(\record_adapter $record, array $wanted_subdefs = null)

View File

@@ -211,9 +211,6 @@ class Installer
$config['main']['storage']['cache'] = realpath(__DIR__ . '/../../../../cache');
$config['main']['storage']['log'] = realpath(__DIR__ . '/../../../../logs');
$config['main']['storage']['download'] = realpath(__DIR__ . '/../../../../tmp/download');
$config['main']['storage']['lazaret'] = realpath(__DIR__ . '/../../../../tmp/lazaret');
$config['main']['storage']['caption'] = realpath(__DIR__ . '/../../../../tmp/caption');
$config['registry'] = $this->app['registry.manipulator']->getRegistryData();

View File

@@ -111,7 +111,7 @@ main:
download: null
lazaret: null
caption: null
tmp_files: null
worker_tmp_files: null
trusted-proxies: []
debugger: