From c56bb65762e85b0654e2a637f53f0789fa16e3df Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Tue, 14 Mar 2023 15:45:49 +0100 Subject: [PATCH] system: small service list dump via pluginctl for #6376 We may have to fill out runtime information as well and filter correctly just in case the API ever requires it as it's not a lot of work. --- src/opnsense/service/conf/actions_service.conf | 6 ++++++ src/sbin/pluginctl | 9 ++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/opnsense/service/conf/actions_service.conf b/src/opnsense/service/conf/actions_service.conf index 21a167e31..a1fc19b86 100644 --- a/src/opnsense/service/conf/actions_service.conf +++ b/src/opnsense/service/conf/actions_service.conf @@ -9,3 +9,9 @@ command:/usr/local/etc/rc.reload_all parameters: type:script message:Reloading all + +[list] +command:/usr/local/sbin/pluginctl -S +parameters: +type:script_output +message:Fetching service list diff --git a/src/sbin/pluginctl b/src/sbin/pluginctl index f1080643a..7aefcd6d2 100755 --- a/src/sbin/pluginctl +++ b/src/sbin/pluginctl @@ -3,7 +3,7 @@ /* * Copyright (C) 2019 Deciso B.V. - * Copyright (C) 2019-2022 Franco Fichtner + * Copyright (C) 2019-2023 Franco Fichtner * Copyright (C) 2017 Alexander Shursha * All rights reserved. * @@ -63,17 +63,18 @@ function get_config_prop($path, $cnf = null) } } -$opts = getopt('cdghirs', [], $optind); +$opts = getopt('cdghirSs', [], $optind); $args = array_slice($argv, $optind); if (isset($opts['h'])) { - echo "Usage: pluginctl [-c | -d | -g | -h | -i | -r | -s] ...\n\n"; + echo "Usage: pluginctl [-c | -d | -g | -h | -i | -r | -S | -s] ...\n\n"; echo "\t-c configure mode (default), executes plugin [_configure] hook\n"; echo "\t-d device mode, lists registered devices\n"; echo "\t-g get config property (raw, e.g. system.firmware.plugins)\n"; echo "\t-h show this help text and exit\n"; echo "\t-i invoke dynamic interface registration\n"; echo "\t-r run mode (e.g. command)\n"; + echo "\t-S service dump\n"; echo "\t-s service mode (e.g. myservice restart)\n\n"; echo "Without arguments, a list of plugins of the requested type is shown.\n"; } elseif (isset($opts['d'])) { @@ -99,6 +100,8 @@ if (isset($opts['h'])) { } } } +} elseif (isset($opts['S'])) { + echo json_encode(plugins_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] : '';