Files
Phraseanet/docker/phraseanet/install-plugins
Arthur de Moulins 19e6ba689c add install-plugin script,
add project name env
2020-03-12 21:04:37 +01:00

51 lines
1.4 KiB
PHP
Executable File

#!/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));
}