From 137733375178e2483ee5404a374ca5aec6c65291 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Thu, 6 Feb 2025 14:23:15 +0000 Subject: util.prosodyctl.shell: Export function to check for availability of admin socket --- util/prosodyctl/shell.lua | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'util/prosodyctl/shell.lua') diff --git a/util/prosodyctl/shell.lua b/util/prosodyctl/shell.lua index d6d885d8..a0fbb09c 100644 --- a/util/prosodyctl/shell.lua +++ b/util/prosodyctl/shell.lua @@ -64,6 +64,13 @@ local function printbanner() print("https://prosody.im/doc/console\n"); end +local function check() + local lfs = require "lfs"; + local socket_path = path.resolve_relative_path(prosody.paths.data, config.get("*", "admin_socket") or "prosody.sock"); + local state = lfs.attributes(socket_path, "mode"); + return state == "socket"; +end + local function start(arg) --luacheck: ignore 212/arg local client = adminstream.client(); local opts, err, where = parse_args(arg); @@ -180,4 +187,5 @@ end return { shell = start; + available = check; }; -- cgit v1.2.3