diff --git a/src/opnsense/service/conf/actions_service.conf b/src/opnsense/service/conf/actions_service.conf index a1fc19b86..ba985cf69 100644 --- a/src/opnsense/service/conf/actions_service.conf +++ b/src/opnsense/service/conf/actions_service.conf @@ -12,6 +12,6 @@ message:Reloading all [list] command:/usr/local/sbin/pluginctl -S -parameters: +parameters:%s %s type:script_output -message:Fetching service list +message:Fetching service list (%s %s) diff --git a/src/sbin/pluginctl b/src/sbin/pluginctl index 7aefcd6d2..16be8f65d 100755 --- a/src/sbin/pluginctl +++ b/src/sbin/pluginctl @@ -101,7 +101,22 @@ if (isset($opts['h'])) { } } } elseif (isset($opts['S'])) { - echo json_encode(plugins_services(), JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT) . PHP_EOL; + $services = []; + foreach (plugins_services() as $service) { + /* fail if name filter does not match */ + if (!empty($args[0]) && $service['name'] != $args[0]) { + continue; + } + /* fail if ID lookup is not possible or does not match */ + if (isset($args[1]) && $args[1] !== '' && (!array_key_exists('id', $service) || $service['id'] != $args[1])) { + continue; + } + /* fetch status so the caller does not have to */ + $service['status'] = service_status($service); + /* collect all matches contrary to what service_by_name() is doing */ + $services[] = $service; + } + echo json_encode($services, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT) . PHP_EOL; } elseif (isset($opts['s'])) { $name = !empty($args[0]) ? $args[0] : ''; $act = !empty($args[1]) ? $args[1] : '';