Line 0
Link Here
|
|
|
1 |
#!/bin/sh |
2 |
# |
3 |
# $FreeBSD$ |
4 |
# |
5 |
# Automatically renew Let's Encrypt certificates each week |
6 |
# |
7 |
# Add the following lines to /etc/periodic.conf: |
8 |
# |
9 |
# weekly_certbot_enable (bool): Set to "NO" by default |
10 |
# weekly_certbot_service (str): If defined, certbot will try to |
11 |
# shutdown this this service before |
12 |
# renewing the certificate, and restart |
13 |
# it afterwards. For example, set to |
14 |
# "nginx" or "apache24" |
15 |
|
16 |
# If there is a global system configuration file, suck it in. |
17 |
# |
18 |
if [ -r /etc/defaults/periodic.conf ] |
19 |
then |
20 |
. /etc/defaults/periodic.conf |
21 |
source_periodic_confs |
22 |
fi |
23 |
|
24 |
case "$weekly_certbot_enable" in |
25 |
[Yy][Ee][Ss]) |
26 |
echo |
27 |
echo "Renewing Let's Encrypt certificates:" |
28 |
|
29 |
PRE_HOOK="" |
30 |
POST_HOOK="" |
31 |
if [ -n "$weekly_certbot_service" ] |
32 |
then |
33 |
if service "$weekly_certbot_service" onestatus |
34 |
then |
35 |
PRE_HOOK="service $weekly_certbot_service onestop" |
36 |
POST_HOOK="service $weekly_certbot_service onestart" |
37 |
fi |
38 |
fi |
39 |
|
40 |
anticongestion |
41 |
if %%LOCALBASE%%/bin/certbot renew --pre-hook "$PRE_HOOK" \ |
42 |
--post-hook "$POST_HOOK" \ |
43 |
--no-random-sleep-on-renew |
44 |
then |
45 |
rc=0 |
46 |
else |
47 |
rc=1 |
48 |
fi |
49 |
;; |
50 |
*) rc=0;; |
51 |
esac |
52 |
|
53 |
exit $rc |