Add option to execute "install" part of the plugin

This commit is contained in:
slawkens
2023-11-25 10:10:15 +01:00
parent 19c06df300
commit 36ec2e1e56
2 changed files with 70 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
<?php
if(PHP_SAPI !== 'cli') {
echo 'This script can be run only in command line mode.';
exit(1);
}
require_once __DIR__ . '/../../common.php';
require_once SYSTEM . 'functions.php';
require_once SYSTEM . 'init.php';
require_once SYSTEM . 'hooks.php';
require_once LIBS . 'plugins.php';
if($argc !== 2) {
echo 'This command expects one parameter: plugin name' . PHP_EOL;
exit(2);
}
$pluginName = $argv[1];
if(Plugins::executeInstall($pluginName)) {
foreach(Plugins::getWarnings() as $warning) {
echo 'WARNING: ' . $warning;
}
$info = Plugins::getPluginJson();
echo 'Script for install ' . (isset($info['name']) ? $info['name'] . ' p' : 'P') . 'lugin has been successfully executed.' . PHP_EOL;
}
else {
echo 'ERROR: ' . Plugins::getError() . PHP_EOL;
exit(3);
}