This repository has been archived by the owner on Oct 24, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
le2ispc_renewer
executable file
·46 lines (40 loc) · 1.79 KB
/
le2ispc_renewer
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env bash
#*************************************************************************************************************#
# #
# HERE BE DRAGONS #
# #
#*************************************************************************************************************#
# Get the period after which certs should be renewed
days=$(php "/root/.le2ispc/le2ispc.conf.php")
if [[ ! "${days}" -gt 0 ]]; then
echo "Couldn't get the correct amount of days after which certs should be renewed."
echo "Please check your config and retry."
exit 1
fi
# Check parameter input
while getopts ":thd:" opt; do
case $opt in
d) days="${OPTARG}"
;;
t) testrun="yes"
;;
h) echo "Usage: ${0} [-h|-d DAYS|-t]"
echo "-h: print help"
echo "-d: DAYS: Use this switch to specifiy a different renewal interval (only for one run)"
echo "-t: make dry-run, print the domains that would be renewed"
exit 0
;;
\?) echo "Invalid option: -$OPTARG" >&2
exit 1
;;
:) echo "Option -$OPTARG requires an argument (number of days)." >&2
exit 1
;;
esac
done
if [[ "${testrun}" = "yes" ]]; then
echo "The following domains would have been renewed since ${days} days have passed."
find "/etc/letsencrypt/live/"* -type d -mtime +"${days}" -exec bash -c 'domain=${1##*/}; echo "${domain}"' _ {} \;
else
find "/etc/letsencrypt/live/"* -type d -mtime +"${days}" -exec bash -c 'domain=${1##*/}; le2ispc "${domain}"' _ {} \;
fi