prosodyctl: Delay reporting of successful certificate imports until all done
authorKim Alvefur <zash@zash.se>
Sat, 22 Apr 2017 19:11:26 +0200
changeset 8120 66d8f6b3c3ef
parent 8119 76ac8b617402
child 8121 f8c52010bd37
prosodyctl: Delay reporting of successful certificate imports until all done
prosodyctl
--- a/prosodyctl	Sat Apr 22 16:41:44 2017 +0200
+++ b/prosodyctl	Sat Apr 22 19:11:26 2017 +0200
@@ -873,18 +873,19 @@
 		owner = config.get("*", "prosody_user") or "prosody";
 		group = config.get("*", "prosody_group") or owner;
 	end
+	local imported = {};
 	for _, host in ipairs(hostnames) do
 		for _, dir in ipairs(arg) do
 			if lfs.attributes(dir .. "/" .. host .. "/fullchain.pem")
 			and lfs.attributes(dir .. "/" .. host .. "/privkey.pem") then
 				copy(dir .. "/" .. host .. "/fullchain.pem", cert_basedir .. "/" .. host .. ".crt", nil, owner, group);
 				copy(dir .. "/" .. host .. "/privkey.pem", cert_basedir .. "/" .. host .. ".key", "0377", owner, group);
-				show_message("Imported certificate and key for "..host);
+				table.insert(imported, host);
 			elseif lfs.attributes(dir .. "/" .. host .. ".crt")
 			and lfs.attributes(dir .. "/" .. host .. ".key") then
 				copy(dir .. "/" .. host .. ".crt", cert_basedir .. "/" .. host .. ".crt", nil, owner, group);
 				copy(dir .. "/" .. host .. ".key", cert_basedir .. "/" .. host .. ".key", "0377", owner, group);
-				show_message("Imported certificate and key for "..host);
+				table.insert(imported, host);
 			else
 				show_warning("No certificate for host "..host.." found :(");
 			end
@@ -893,6 +894,9 @@
 			-- Private key matches public key in certificate
 		end
 	end
+	if imported[1] then
+		show_message("Imported certificate and key for hosts "..table.concat(imported, ", "));
+	end
 end
 
 function commands.cert(arg)