-
Notifications
You must be signed in to change notification settings - Fork 3
/
cron.sh
38 lines (30 loc) · 987 Bytes
/
cron.sh
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
#!/bin/bash
source ./init.sh
CreatePFX() {
echo "[AutoCert] Generating pfx for ${ACME_DOMAINS[0]}"
if [ -f "${ACME_DOMAINS[0]}.pfx" ]; then
rm -f "${ACME_DOMAINS[0]}.pfx"
fi
openssl pkcs12 -export -out "${ACME_DOMAINS[0]}.pfx" -inkey "${ACME_DOMAINS[0]}.key" -in fullchain.cer -passout pass:
}
if [ ! -f "./data/acme/${ACME_DOMAINS[0]}/fullchain.cer" ] || [ "$AUTOCERT_FORCE_REISSUE" == true ]; then
echo "[AutoCert] Certs not issued"
./issue.sh
CreatePFX
else
export ACME_MERGED_PARAMS="--cron "
RunACME
if [ $? -ne 0 ]; then
echo "[AutoCert] acme.sh failed with code $?"
exit $?
fi
echo "[AutoCert] acme.sh shell finished"
pushd "./data/acme/${ACME_DOMAINS[0]}"
currentTime=$(date +%s)
modifyTime=$(stat -c %Y "${ACME_DOMAINS[0]}.key")
timeDiff=$(($currentTime-$modifyTime))
if [ $timeDiff -lt 60 ] || [ ! -f "${ACME_DOMAINS[0]}.pfx" ]; then
CreatePFX
fi
popd
fi