mirror of
https://github.com/netbirdio/plugins.git
synced 2026-05-22 18:44:07 -07:00
security/acme-client: switch plugin detection
This commit is contained in:
+1
-1
@@ -125,7 +125,7 @@ class SettingsController extends ApiMutableModelControllerBase
|
||||
$mdlAcme = $this->getModel();
|
||||
|
||||
// Check if the required plugin is installed
|
||||
if ((string)$mdlAcme->isPluginInstalled('os-haproxy') != "1") {
|
||||
if ((string)$mdlAcme->isPluginInstalled('haproxy') != "1") {
|
||||
$this->getLogger()->error("LE check: HAProxy plugin is NOT installed, skipping integration");
|
||||
return($result);
|
||||
}
|
||||
|
||||
+1
-39
@@ -96,45 +96,7 @@ class AcmeClient extends BaseModel
|
||||
*/
|
||||
public function isPluginInstalled($name)
|
||||
{
|
||||
// NOTE: Based on infoAction() from Core/Api/FirmwareController.php
|
||||
// FIXME: Should be replaced by a Core function sooner or later.
|
||||
|
||||
$backend = new Backend();
|
||||
$keys = array('name', 'version', 'comment', 'flatsize', 'locked', 'license');
|
||||
$plugins = array();
|
||||
|
||||
// Only check local package data for performance reasons
|
||||
$current = $backend->configdRun("firmware local");
|
||||
$current = explode("\n", trim($current));
|
||||
|
||||
foreach ($current as $line) {
|
||||
/* package infos are flat lists with 3 pipes as delimiter */
|
||||
$expanded = explode('|||', $line);
|
||||
$translated = array();
|
||||
$index = 0;
|
||||
if (count($expanded) != count($keys)) {
|
||||
continue;
|
||||
}
|
||||
foreach ($keys as $key) {
|
||||
$translated[$key] = $expanded[$index++];
|
||||
}
|
||||
|
||||
/* mark local packages as "installed" */
|
||||
$translated['installed'] = "1";
|
||||
|
||||
/* figure out local and remote plugins */
|
||||
$plugin = explode('-', $translated['name']);
|
||||
if (count($plugin)) {
|
||||
if ($plugin[0] == 'os' || $plugin[0] == 'ospriv') {
|
||||
$plugins[$translated['name']] = $translated;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($plugins[$name]) and $plugins[$name]['installed'] == "1") {
|
||||
return 1; // TRUE, is installed
|
||||
} else {
|
||||
return 0; // FALSE, is not installed
|
||||
}
|
||||
return trim($backend->configdRun('firmware plugin ' . escapeshellarg($name)));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user