]> git.wh0rd.org - home.git/blobdiff - .bin/le-renew
test.cc: new C++ test
[home.git] / .bin / le-renew
index 6c2354ceb29896510446aff738bfc9805fef6230..58e687b0b7a34ca56356ed60efcbe3fc283515ce 100755 (executable)
@@ -107,7 +107,12 @@ def process_domain(domain, dry_run=False):
     logging.info('%s: checking', domain)
 
     conf = load_conf(domain)
-    webroot_path = conf.get('[webroot_map', domain)
+    try:
+        webroot_path = conf.get('[webroot_map', domain)
+    except configparser.NoOptionError:
+        webroot_path = conf.get('renewalparams', 'webroot_path')
+        # The conf writing has a bug here where it appends a comma.
+        webroot_path = webroot_path.rstrip(',')
 
     cert_path = os.path.realpath(conf.get('globals', 'cert'))
 
@@ -132,16 +137,24 @@ def process_domain(domain, dry_run=False):
         cmd += ['-d', d]
     if delta.days < 30:
         logging.info('%s: renewing', domain)
-        logging.info('%s: %s', domain, cmd)
+        logging.info('%s: %s', domain, ' '.join(cmd))
         if not dry_run:
-            subprocess.check_call(cmd)
+            try:
+                subprocess.check_call(cmd)
+            except subprocess.CalledProcessError:
+                logging.error('failed', exc_info=True)
+                return 0
             ret = 1
         # Try to revoke the old one.
-        cmd = ['certbot', 'revoke', '--cert-path', cert_path]
+        cmd = ['certbot', 'revoke', '--no-delete-after-revoke', '--cert-path',
+               cert_path]
         logging.info('%s: revoking old cert', domain)
-        logging.info('%s: %s', domain, cmd)
+        logging.info('%s: %s', domain, ' '.join(cmd))
         if not dry_run:
-            subprocess.check_call(cmd)
+            try:
+                subprocess.check_call(cmd, stdin=open('/dev/null', 'r'))
+            except subprocess.CalledProcessError:
+                logging.error('failed', exc_info=True)
     else:
         logging.info('%s: up-to-date!', domain)