prosodyctl
changeset 8256 3a6f5b0f56f0
parent 8206 a7863f4aae65
parent 8252 cc664a3917e2
child 8271 e21d82551e05
--- a/prosodyctl	Sun Sep 17 13:33:38 2017 -0400
+++ b/prosodyctl	Thu Sep 21 02:36:28 2017 +0200
@@ -868,8 +868,22 @@
 	while arg[1] and prosody.hosts[ arg[1] ] do
 		table.insert(hostnames, table.remove(arg, 1));
 	end
+	if hostnames[1] == nil then
+		local domains = os.getenv"RENEWED_DOMAINS"; -- Set if invoked via certbot
+		if domains then
+			for host in domains:gmatch("%S+") do
+				table.insert(hostnames, host);
+			end
+		else
+			for host in pairs(prosody.hosts) do
+				if host ~= "*" and config.get(host, "enabled") ~= false then
+					table.insert(hostnames, host);
+				end
+			end
+		end
+	end
 	if not arg[1] or arg[1] == "--help" then -- Probably forgot the path
-		show_usage("cert import HOSTNAME [HOSTNAME+] /path/to/certs [/other/paths/]+",
+		show_usage("cert import [HOSTNAME+] /path/to/certs [/other/paths/]+",
 			"Copies certificates to "..cert_basedir);
 		return 1;
 	end
@@ -930,13 +944,15 @@
 		end
 		local subcmd = table.remove(arg, 1);
 		if type(cert_commands[subcmd]) == "function" then
-			if not arg[1] then
-				show_message"You need to supply at least one hostname"
-				arg = { "--help" };
-			end
-			if arg[1] ~= "--help" and not hosts[arg[1]] then
-				show_message(error_messages["no-such-host"]);
-				return 1;
+			if subcmd ~= "import" then -- hostnames are optional for import
+				if not arg[1] then
+					show_message"You need to supply at least one hostname"
+					arg = { "--help" };
+				end
+				if arg[1] ~= "--help" and not hosts[arg[1]] then
+					show_message(error_messages["no-such-host"]);
+					return 1;
+				end
 			end
 			return cert_commands[subcmd](arg);
 		elseif subcmd == "check" then