mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-17 15:03:25 +00:00
add install-plugin script,
add project name env
This commit is contained in:
50
docker/phraseanet/install-plugins
Executable file
50
docker/phraseanet/install-plugins
Executable file
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
function setupStreaming() {
|
||||
// Turn off output buffering
|
||||
ini_set('output_buffering', 'off');
|
||||
// Turn off PHP output compression
|
||||
ini_set('zlib.output_compression', false);
|
||||
// Disable Apache output buffering/compression
|
||||
if (function_exists('apache_setenv')) {
|
||||
apache_setenv('no-gzip', '1');
|
||||
apache_setenv('dont-vary', '1');
|
||||
}
|
||||
}
|
||||
function runCommand($cmd){
|
||||
echo "+ $cmd\n";
|
||||
system($cmd, $return);
|
||||
if (0 !== $return) {
|
||||
throw new \Exception(sprintf('Error %d: %s', $return, $cmd));
|
||||
}
|
||||
}
|
||||
setupStreaming();
|
||||
|
||||
$plugins = trim(getenv('PHRASEANET_PLUGINS'));
|
||||
if (empty($plugins)) {
|
||||
echo "No plugin to install... SKIP\n";
|
||||
exit(0);
|
||||
}
|
||||
|
||||
foreach (explode(' ', $plugins) as $key => $plugin) {
|
||||
$plugin = trim($plugin);
|
||||
$repo = $plugin;
|
||||
$branch = 'master';
|
||||
if (1 === preg_match('#^(.+)\(([^)]+)\)$#', $plugin, $matches)) {
|
||||
$repo = $matches[1];
|
||||
$branch = $matches[2];
|
||||
}
|
||||
|
||||
$pluginTmpName = 'plugin' . $key;
|
||||
$pluginPath = './plugin' . $key;
|
||||
if (is_dir($pluginPath)) {
|
||||
echo shell_exec(sprintf('rm -rf %s', $pluginPath));
|
||||
}
|
||||
|
||||
echo sprintf("Installing %s (branch: %s)\n", $repo, $branch);
|
||||
runCommand(sprintf('git clone --single-branch --branch %s %s %s', $branch, $repo, $pluginPath));
|
||||
|
||||
runCommand(sprintf('bin/setup plugins:add %s', $pluginPath));
|
||||
|
||||
echo shell_exec(sprintf('rm -rf %s', $pluginPath));
|
||||
}
|
Reference in New Issue
Block a user