aboutsummaryrefslogtreecommitdiffstats
path: root/prosodyctl
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-12-21 14:23:09 +0100
committerKim Alvefur <zash@zash.se>2021-12-21 14:23:09 +0100
commita7f535e0cf44a188207ad49b88831f449812c8bf (patch)
tree35bd4fe22fc34dd55b11a219126339c321c3f8a8 /prosodyctl
parentff688f28ea5336b0df87b932316544329eccb037 (diff)
downloadprosody-a7f535e0cf44a188207ad49b88831f449812c8bf.tar.gz
prosody-a7f535e0cf44a188207ad49b88831f449812c8bf.zip
prosodyctl: Hide process management commands when init system should be used instead
Diffstat (limited to 'prosodyctl')
-rwxr-xr-xprosodyctl22
1 files changed, 19 insertions, 3 deletions
diff --git a/prosodyctl b/prosodyctl
index 461344d3..cb809b99 100755
--- a/prosodyctl
+++ b/prosodyctl
@@ -226,14 +226,23 @@ function commands.deluser(arg)
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 command_runner = async.runner(function ()
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