aboutsummaryrefslogtreecommitdiff
path: root/files/run_certbot.py
diff options
context:
space:
mode:
Diffstat (limited to 'files/run_certbot.py')
-rw-r--r--files/run_certbot.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/files/run_certbot.py b/files/run_certbot.py
new file mode 100644
index 0000000..f81f707
--- /dev/null
+++ b/files/run_certbot.py
@@ -0,0 +1,35 @@
+#!/usr/bin/env python
+
+"""
+Gathers domain names to give to certbot, and then execs
+certbot. "Required" to send multiple domain names
+
+File managed by Puppet
+"""
+
+# Script should be compatible with both Python2 and Python3
+
+from __future__ import print_function
+import sys
+import os
+
+if len(sys.argv) != 2:
+ print('Takes exactly one argument: the certificates name',
+ file=sys.stderr)
+ os.exit(1)
+
+
+cert_name = sys.argv[1]
+here = os.path.dirname(sys.argv[0])
+
+cmdline = ['certbot', '--config', os.path.join(here, cert_name + ".ini")]
+with open(os.path.join(here, cert_name + '.domains')) as f:
+ for line in f:
+ if not line:
+ continue
+ if line[0] == '#':
+ continue
+ cmdline += ['-d', line.strip()]
+cmdline += ['certonly']
+
+os.execvp('certbot', cmdline)