From 51cfd5b4c7b485ad72c8aa9950b3403a14f67a89 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 18 Sep 2017 17:06:35 +0200 Subject: prosodyctl: Use all enabled hosts if no hostnames passed to cert import --- prosodyctl | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'prosodyctl') diff --git a/prosodyctl b/prosodyctl index ce81877d..353253ec 100755 --- a/prosodyctl +++ b/prosodyctl @@ -870,8 +870,15 @@ function cert_commands.import(arg) while arg[1] and prosody.hosts[ arg[1] ] do table.insert(hostnames, table.remove(arg, 1)); end + if hostnames[1] == nil then + for host in pairs(prosody.hosts) do + if host ~= "*" and config.get(host, "enabled") ~= false then + table.insert(hostnames, host); + 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 -- cgit v1.2.3 From 188a2f9b5cdcdb3ac79cda19d84ea6735c6d27f5 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 18 Sep 2017 17:08:31 +0200 Subject: prosodyctl: Only demand a hostname argument to cert commands other than import --- prosodyctl | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'prosodyctl') diff --git a/prosodyctl b/prosodyctl index 353253ec..74bb2ad8 100755 --- a/prosodyctl +++ b/prosodyctl @@ -939,13 +939,15 @@ function commands.cert(arg) 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 -- cgit v1.2.3 From ba6413cac8786186b1487a15058cf105da0b92c5 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 18 Sep 2017 18:28:29 +0200 Subject: prosodyctl: cert import: Use env variable set by certbot if invoked as post-renew hook --- prosodyctl | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'prosodyctl') diff --git a/prosodyctl b/prosodyctl index 74bb2ad8..cdcd25d9 100755 --- a/prosodyctl +++ b/prosodyctl @@ -871,10 +871,17 @@ function cert_commands.import(arg) table.insert(hostnames, table.remove(arg, 1)); end if hostnames[1] == nil then - for host in pairs(prosody.hosts) do - if host ~= "*" and config.get(host, "enabled") ~= false 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 -- cgit v1.2.3