mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 18:03:17 +00:00
Merge branch 'master' into PHRAS-3021_add-volumes-custom-cache
This commit is contained in:
@@ -111,7 +111,7 @@ main:
|
|||||||
download: null
|
download: null
|
||||||
lazaret: null
|
lazaret: null
|
||||||
caption: null
|
caption: null
|
||||||
tmp_files: null
|
worker_tmp_files: null
|
||||||
border-manager:
|
border-manager:
|
||||||
enabled: true
|
enabled: true
|
||||||
extension-mapping:
|
extension-mapping:
|
||||||
|
@@ -55,6 +55,11 @@ class Install extends Command
|
|||||||
->addOption('es-host', null, InputOption::VALUE_OPTIONAL, 'ElasticSearch server HTTP host', 'localhost')
|
->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-port', null, InputOption::VALUE_OPTIONAL, 'ElasticSearch server HTTP port', 9200)
|
||||||
->addOption('es-index', null, InputOption::VALUE_OPTIONAL, 'ElasticSearch index name', null)
|
->addOption('es-index', null, InputOption::VALUE_OPTIONAL, 'ElasticSearch index name', null)
|
||||||
|
->addOption('download-path', null, InputOption::VALUE_OPTIONAL, 'Path to download repository', __DIR__ . '/../../../../../tmp/download')
|
||||||
|
->addOption('lazaret-path', null, InputOption::VALUE_OPTIONAL, 'Path to lazaret repository', __DIR__ . '/../../../../../tmp/lazaret')
|
||||||
|
->addOption('caption-path', null, InputOption::VALUE_OPTIONAL, 'Path to caption repository', __DIR__ . '/../../../../../tmp/caption')
|
||||||
|
->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('yes', 'y', InputOption::VALUE_NONE, 'Answer yes to all questions')
|
||||||
->setHelp("Phraseanet can only be installed on 64 bits PHP.");
|
->setHelp("Phraseanet can only be installed on 64 bits PHP.");
|
||||||
;
|
;
|
||||||
@@ -159,7 +164,9 @@ class Install extends Command
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->container['phraseanet.installer']->install($email, $password, $abConn, $serverName, $dataPath, $dbConn, $templateName, $this->detectBinaries());
|
$storagePaths = $this->getStoragePaths($input, $dataPath);
|
||||||
|
|
||||||
|
$this->container['phraseanet.installer']->install($email, $password, $abConn, $serverName, $storagePaths, $dbConn, $templateName, $this->detectBinaries());
|
||||||
$this->container['conf']->set(['main', 'search-engine', 'options'], $esOptions->toArray());
|
$this->container['conf']->set(['main', 'search-engine', 'options'], $esOptions->toArray());
|
||||||
|
|
||||||
if (null !== $this->getApplication()) {
|
if (null !== $this->getApplication()) {
|
||||||
@@ -397,6 +404,27 @@ class Install extends Command
|
|||||||
return $index;
|
return $index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getStoragePaths(InputInterface $input, $dataPath)
|
||||||
|
{
|
||||||
|
$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));
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'subdefs' => $dataPath,
|
||||||
|
'download' => $input->getOption('download-path'),
|
||||||
|
'lazaret' => $input->getOption('lazaret-path'),
|
||||||
|
'caption' => $input->getOption('caption-path'),
|
||||||
|
'worker_tmp_files' => $input->getOption('worker-tmp-files')
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
private function detectBinaries()
|
private function detectBinaries()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
@@ -181,8 +181,8 @@ class UploadController extends Controller
|
|||||||
$uploadedFilename = $file->getRealPath();
|
$uploadedFilename = $file->getRealPath();
|
||||||
$renamedFilename = null;
|
$renamedFilename = null;
|
||||||
|
|
||||||
if(!empty($this->app['conf']->get(['main', 'storage', 'tmp_files']))) {
|
if(!empty($this->app['conf']->get(['main', 'storage', 'worker_tmp_files']))) {
|
||||||
$tmpStorage = \p4string::addEndSlash($this->app['conf']->get(['main', 'storage', 'tmp_files'])).'upload/';
|
$tmpStorage = \p4string::addEndSlash($this->app['conf']->get(['main', 'storage', 'worker_tmp_files'])).'upload/';
|
||||||
|
|
||||||
if(!is_dir($tmpStorage)){
|
if(!is_dir($tmpStorage)){
|
||||||
$this->getFilesystem()->mkdir($tmpStorage);
|
$this->getFilesystem()->mkdir($tmpStorage);
|
||||||
|
@@ -174,7 +174,9 @@ class SetupController extends Controller
|
|||||||
$email = $request->request->get('email');
|
$email = $request->request->get('email');
|
||||||
$password = $request->request->get('password');
|
$password = $request->request->get('password');
|
||||||
$template = $request->request->get('db_template');
|
$template = $request->request->get('db_template');
|
||||||
$dataPath = $request->request->get('datapath_noweb');
|
$storagePath = [
|
||||||
|
'subdefs' => $request->request->get('datapath_noweb')
|
||||||
|
];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$installer = $this->app['phraseanet.installer'];
|
$installer = $this->app['phraseanet.installer'];
|
||||||
@@ -193,7 +195,7 @@ class SetupController extends Controller
|
|||||||
$binaryData[$key] = $path;
|
$binaryData[$key] = $path;
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = $installer->install($email, $password, $abConn, $servername, $dataPath, $dbConn, $template, $binaryData);
|
$user = $installer->install($email, $password, $abConn, $servername, $storagePath, $dbConn, $template, $binaryData);
|
||||||
|
|
||||||
$this->app->getAuthenticator()->openAccount($user);
|
$this->app->getAuthenticator()->openAccount($user);
|
||||||
|
|
||||||
|
@@ -57,7 +57,7 @@ class SubdefGenerator
|
|||||||
$this->filesystem = $filesystem;
|
$this->filesystem = $filesystem;
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
$this->mediavorus = $mediavorus;
|
$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)
|
public function generateSubdefs(\record_adapter $record, array $wanted_subdefs = null)
|
||||||
|
@@ -33,6 +33,11 @@ class ComposerInstaller
|
|||||||
$this->composer = $pluginsDirectory . DIRECTORY_SEPARATOR . 'composer.phar';
|
$this->composer = $pluginsDirectory . DIRECTORY_SEPARATOR . 'composer.phar';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function __destruct()
|
||||||
|
{
|
||||||
|
@unlink($this->composer);
|
||||||
|
}
|
||||||
|
|
||||||
public function install($directory)
|
public function install($directory)
|
||||||
{
|
{
|
||||||
$process = $this->createProcessBuilder()
|
$process = $this->createProcessBuilder()
|
||||||
|
@@ -30,11 +30,11 @@ class Installer
|
|||||||
$this->app = $app;
|
$this->app = $app;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function install($email, $password, Connection $abConn, $serverName, $dataPath, Connection $dbConn = null, $templateName = null, array $binaryData = [])
|
public function install($email, $password, Connection $abConn, $serverName, array $storagePaths, Connection $dbConn = null, $templateName = null, array $binaryData = [])
|
||||||
{
|
{
|
||||||
$this->rollbackInstall($abConn, $dbConn);
|
$this->rollbackInstall($abConn, $dbConn);
|
||||||
|
|
||||||
$this->createConfigFile($abConn, $serverName, $binaryData, $dataPath);
|
$this->createConfigFile($abConn, $serverName, $binaryData, $storagePaths);
|
||||||
try {
|
try {
|
||||||
$this->createAB($abConn);
|
$this->createAB($abConn);
|
||||||
$user = $this->createUser($email, $password);
|
$user = $this->createUser($email, $password);
|
||||||
@@ -185,7 +185,7 @@ class Installer
|
|||||||
$this->app->getApplicationBox()->insert_datas($this->app);
|
$this->app->getApplicationBox()->insert_datas($this->app);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function createConfigFile(Connection $abConn, $serverName, $binaryData, $dataPath)
|
private function createConfigFile(Connection $abConn, $serverName, $binaryData, array $storagePaths)
|
||||||
{
|
{
|
||||||
$config = $this->app['configuration.store']->initialize()->getConfig();
|
$config = $this->app['configuration.store']->initialize()->getConfig();
|
||||||
|
|
||||||
@@ -203,17 +203,28 @@ class Installer
|
|||||||
$config['servername'] = $serverName;
|
$config['servername'] = $serverName;
|
||||||
$config['main']['key'] = $this->app['random.medium']->generateString(16);
|
$config['main']['key'] = $this->app['random.medium']->generateString(16);
|
||||||
|
|
||||||
if (null === $dataPath = realpath($dataPath)) {
|
// define storage config
|
||||||
throw new \InvalidArgumentException(sprintf('Path %s does not exist.', $dataPath));
|
$defaultStoragePaths = [
|
||||||
|
'subdefs' => __DIR__ . '/../../../../datas',
|
||||||
|
'cache' => __DIR__ . '/../../../../cache',
|
||||||
|
'log' => __DIR__ . '/../../../../logs',
|
||||||
|
'download' => __DIR__ . '/../../../../tmp/download',
|
||||||
|
'lazaret' => __DIR__ . '/../../../../tmp/lazaret',
|
||||||
|
'caption' => __DIR__ . '/../../../../tmp/caption',
|
||||||
|
'worker_tmp_files' => __DIR__ . '/../../../../tmp'
|
||||||
|
];
|
||||||
|
|
||||||
|
$storagePaths = array_merge($defaultStoragePaths, $storagePaths);
|
||||||
|
|
||||||
|
foreach ($storagePaths as $key => $path) {
|
||||||
|
if (!is_dir($path)) {
|
||||||
|
mkdir($path, 0755, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
$storagePaths[$key] = realpath($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
$config['main']['storage']['subdefs'] = $dataPath;
|
$config['main']['storage'] = $storagePaths;
|
||||||
|
|
||||||
$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();
|
$config['registry'] = $this->app['registry.manipulator']->getRegistryData();
|
||||||
|
|
||||||
|
@@ -111,7 +111,7 @@ main:
|
|||||||
download: null
|
download: null
|
||||||
lazaret: null
|
lazaret: null
|
||||||
caption: null
|
caption: null
|
||||||
tmp_files: null
|
worker_tmp_files: null
|
||||||
|
|
||||||
trusted-proxies: []
|
trusted-proxies: []
|
||||||
debugger:
|
debugger:
|
||||||
|
@@ -36,6 +36,13 @@ class InstallTest extends \PhraseanetTestCase
|
|||||||
$password = 'sup4ssw0rd';
|
$password = 'sup4ssw0rd';
|
||||||
$serverName = 'http://phrasea.io';
|
$serverName = 'http://phrasea.io';
|
||||||
$dataPath = '/tmp';
|
$dataPath = '/tmp';
|
||||||
|
$storagePaths = [
|
||||||
|
'subdefs' => $dataPath,
|
||||||
|
'download' => $dataPath,
|
||||||
|
'lazaret' => $dataPath,
|
||||||
|
'caption' => $dataPath,
|
||||||
|
'worker_tmp_files' => $dataPath
|
||||||
|
];
|
||||||
$template = 'fr-simple';
|
$template = 'fr-simple';
|
||||||
|
|
||||||
$infoDb = Yaml::parse(file_get_contents(__DIR__ . '/../../../../../../resources/hudson/InstallDBs.yml'));
|
$infoDb = Yaml::parse(file_get_contents(__DIR__ . '/../../../../../../resources/hudson/InstallDBs.yml'));
|
||||||
@@ -72,6 +79,11 @@ class InstallTest extends \PhraseanetTestCase
|
|||||||
case 'password':
|
case 'password':
|
||||||
return $password;
|
return $password;
|
||||||
break;
|
break;
|
||||||
|
case 'download-path':
|
||||||
|
case 'lazaret-path':
|
||||||
|
case 'caption-path':
|
||||||
|
case 'scheduler-locks-path':
|
||||||
|
case 'worker-tmp-files':
|
||||||
case 'data-path':
|
case 'data-path':
|
||||||
return $dataPath;
|
return $dataPath;
|
||||||
break;
|
break;
|
||||||
@@ -110,7 +122,7 @@ class InstallTest extends \PhraseanetTestCase
|
|||||||
|
|
||||||
self::$DI['cli']['phraseanet.installer']->expects($this->once())
|
self::$DI['cli']['phraseanet.installer']->expects($this->once())
|
||||||
->method('install')
|
->method('install')
|
||||||
->with($email, $password, $this->isInstanceOf('Doctrine\DBAL\Driver\Connection'), $serverName, $dataPath, $this->isInstanceOf('Doctrine\DBAL\Driver\Connection'), $template, $this->anything());
|
->with($email, $password, $this->isInstanceOf('Doctrine\DBAL\Driver\Connection'), $serverName, $storagePaths, $this->isInstanceOf('Doctrine\DBAL\Driver\Connection'), $template, $this->anything());
|
||||||
|
|
||||||
$structureTemplate = self::$DI['cli']['phraseanet.structure-template'];
|
$structureTemplate = self::$DI['cli']['phraseanet.structure-template'];
|
||||||
|
|
||||||
|
@@ -75,7 +75,7 @@ class InstallerTest extends \PhraseanetTestCase
|
|||||||
$dataPath = __DIR__ . '/../../../../../datas/';
|
$dataPath = __DIR__ . '/../../../../../datas/';
|
||||||
|
|
||||||
$installer = new Installer($app);
|
$installer = new Installer($app);
|
||||||
$installer->install(uniqid('admin') . '@example.com', 'sdfsdsd', $abConn, 'http://local.phrasea.test.installer/', $dataPath, $dbConn, 'en-simple');
|
$installer->install(uniqid('admin') . '@example.com', 'sdfsdsd', $abConn, 'http://local.phrasea.test.installer/', ['subdefs' => $dataPath], $dbConn, 'en-simple');
|
||||||
|
|
||||||
$this->assertTrue($app['configuration.store']->isSetup());
|
$this->assertTrue($app['configuration.store']->isSetup());
|
||||||
$this->assertTrue($app['phraseanet.configuration-tester']->isUpToDate());
|
$this->assertTrue($app['phraseanet.configuration-tester']->isUpToDate());
|
||||||
|
Reference in New Issue
Block a user