浏览代码

Merge pull request #554 from tomasbedrich/jessie

Fixed LE renew options
Mike Ashley 8 年前
父节点
当前提交
d90d37d74e

+ 8
- 0
roles/common/files/etc_cron-daily_letsencrypt-renew 查看文件

@@ -0,0 +1,8 @@
1
+#!/bin/bash
2
+set -o errexit
3
+# Renew all live certificates with LetsEncrypt.  This needs to run at least
4
+# once every three months, but recommended frequency is once a day.
5
+
6
+/root/letsencrypt/letsencrypt-auto renew -c /etc/letsencrypt/cli.conf \
7
+--pre-hook="find /etc/letsencrypt/prerenew/ -maxdepth 1 -type f -executable -exec {} \;" \
8
+--post-hook="find /etc/letsencrypt/postrenew/ -maxdepth 1 -type f -executable -exec {} \;"

+ 0
- 25
roles/common/files/etc_cron-monthly_letsencrypt-renew 查看文件

@@ -1,25 +0,0 @@
1
-#!/bin/bash
2
-set -o errexit
3
-# Renew all live certificates with LetsEncrypt.  This needs to run at least
4
-# once every three months.
5
-
6
-# Given a certificate file returns "domain1,domain2"
7
-# https://community.letsencrypt.org/t/help-me-understand-renewal-config/7115
8
-function getDomains() {
9
-        openssl x509 -text -in "$1" |
10
-        grep -A1 "Subject Alternative Name:" | tail -n1 |
11
-        tr -d ' ' | tr -d 'DNS:'
12
-}
13
-
14
-service apache2 stop
15
-for c in $(find /etc/letsencrypt/live/ -mindepth 1  -type d); do
16
-  domains=$(getDomains "$c"/cert.pem)
17
-  /root/letsencrypt/letsencrypt-auto --renew certonly -c /etc/letsencrypt/cli.conf --domains=$domains
18
-done
19
-service apache2 start
20
-
21
-# Services that rely on LE certificates may need restarted and/or other actions.
22
-for script in $(find /etc/letsencrypt/postrenew/ -maxdepth 1 -type f -executable); do
23
-  echo "Executing ${script}."
24
-  $script
25
-done

+ 24
- 5
roles/common/tasks/letsencrypt.yml 查看文件

@@ -19,16 +19,35 @@
19 19
   register: le_deps_result
20 20
   changed_when: "'Bootstrapping dependencies' in le_deps_result.stdout"
21 21
 
22
+- name: Create directory for pre-renewal scripts
23
+  file: state=directory path=/etc/letsencrypt/prerenew group=root owner=root
24
+
22 25
 - name: Create directory for post-renewal scripts
23 26
   file: state=directory path=/etc/letsencrypt/postrenew group=root owner=root
24 27
 
28
+- name: Create pre-renew hook to stop apache
29
+  copy:
30
+    content: "#!/bin/bash\n\nservice apache2 stop\n"
31
+    dest: /etc/letsencrypt/prerenew/apache
32
+    owner: root
33
+    group: root
34
+    mode: 0755
35
+
36
+- name: Create post-renew hook to start apache
37
+  copy:
38
+    content: "#!/bin/bash\n\nservice apache2 start\n"
39
+    dest: /etc/letsencrypt/postrenew/apache
40
+    owner: root
41
+    group: root
42
+    mode: 0755
43
+
25 44
 - name: Install crontab entry for LetsEncrypt
26 45
   copy:
27
-    src=etc_cron-monthly_letsencrypt-renew
28
-    dest=/etc/cron.monthly/letsencrypt-renew
29
-    owner=root
30
-    group=root
31
-    mode=0755
46
+    src: etc_cron-daily_letsencrypt-renew
47
+    dest: /etc/cron.daily/letsencrypt-renew
48
+    owner: root
49
+    group: root
50
+    mode: 0755
32 51
 
33 52
 - name: Create live directory for LetsEncrypt cron job
34 53
   file: state=directory path=/etc/letsencrypt/live group=root owner=root

+ 1
- 1
roles/ircbouncer/templates/etc_letsencrypt_postrenew_znc.sh.j2 查看文件

@@ -1,5 +1,5 @@
1 1
 #!/bin/bash
2
-# Executed by /etc/cron.monthly/letsencrypt-renew
2
+# Executed by /etc/cron.daily/letsencrypt-renew
3 3
 
4 4
 cat /etc/letsencrypt/live/{{ domain }}/{privkey,fullchain}.pem > /usr/lib/znc/znc.pem
5 5
 chown znc.znc /usr/lib/znc/znc.pem

正在加载...
取消
保存