Software /
code /
prosody
Changeset
12103:fc297128c33a
prosodyctl: Hide process management commands when init system should be used instead
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 21 Dec 2021 14:23:09 +0100 |
parents | 12102:949c2b52f51e |
children | 12104:29765ac7f72f |
files | prosodyctl |
diffstat | 1 files changed, 19 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/prosodyctl Tue Dec 21 13:11:41 2021 +0100 +++ b/prosodyctl Tue Dec 21 14:23:09 2021 +0100 @@ -226,14 +226,23 @@ return 1; end +local function has_init_system() --> which + lfs = lfs or require"lfs"; + if lfs.attributes("/etc/systemd") then + return "systemd"; + elseif lfs.attributes("/etc/init.d/prosody") then + return "rc.d"; + end +end + local function service_command_warning(service_command) if prosody.installed and configmanager.get("*", "prosodyctl_service_warnings") ~= false then show_warning("WARNING: Use of prosodyctl start/stop/restart/reload is not recommended"); show_warning(" if Prosody is managed by an init system - use that directly instead."); - lfs = lfs or require"lfs"; - if lfs.attributes("/etc/systemd") then + local init = has_init_system() + if init == "systemd" then show_warning(" e.g. systemctl %s prosody", service_command); - elseif lfs.attributes("/etc/init.d/prosody") then + elseif init == "rc.d" then show_warning(" e.g. /etc/init.d/prosody %s", service_command); end show_warning(""); @@ -676,6 +685,13 @@ local done = {}; + if prosody.installed and has_init_system() then + -- Hide start, stop, restart + done[table.remove(commands_order, 2)] = true; + done[table.remove(commands_order, 2)] = true; + done[table.remove(commands_order, 2)] = true; + end + for _, command_name in ipairs(commands_order) do local command_func = commands[command_name]; if command_func then