Changeset

13643:e5f62871e6a5

util.prosodyctl.shell: Export function to check for availability of admin socket
author Matthew Wild <mwild1@gmail.com>
date Thu, 06 Feb 2025 14:23:15 +0000
parents 13642:1b2de94f0580
children 13644:263ae995bc86
files util/prosodyctl/shell.lua
diffstat 1 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/util/prosodyctl/shell.lua	Thu Feb 06 12:40:11 2025 +0000
+++ b/util/prosodyctl/shell.lua	Thu Feb 06 14:23:15 2025 +0000
@@ -64,6 +64,13 @@
 	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 @@
 
 return {
 	shell = start;
+	available = check;
 };