# HG changeset patch # User Kim Alvefur # Date 1640092989 -3600 # Node ID fc297128c33a589c6eb5bbcfedec8c60aa5fb882 # Parent 949c2b52f51ed94999b92bdb7a8f6b60b89e847d prosodyctl: Hide process management commands when init system should be used instead diff -r 949c2b52f51e -r fc297128c33a prosodyctl --- 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