adding scripts

This commit is contained in:
Maksim 2019-12-06 23:29:05 +11:00
parent 87ee375642
commit 8eb0f01e14
7 changed files with 46 additions and 0 deletions

0
Dockerfile Normal file → Executable file
View file

0
LICENSE Normal file → Executable file
View file

0
README.md Normal file → Executable file
View file

3
scripts/auth.sh Executable file
View file

@ -0,0 +1,3 @@
#!/bin/sh
[[ "$(curl -s "https://www.duckdns.org/update?domains=${CERTBOT_DOMAIN%.duckdns.org}&token=${DUCKDNS_TOKEN}&txt=${CERTBOT_VALIDATION}")" = "OK" ]]

16
scripts/cert.sh Executable file
View file

@ -0,0 +1,16 @@
#!/bin/sh
# Initial check for certificates
#TODO check if `certbot certonly` can automatically skip renewal (eliminated need for document here operator)
certbot certonly --manual --preferred-challenges dns --manual-auth-hook /scripts/auth \
--manual-cleanup-hook /scripts/cleanup -m "${LETSENCRYPT_EMAIL}" --no-eff-email \
-d "${LETSENCRYPT_DOMAIN}" --agree-tos --manual-public-ip-logging-ok << EOF
1
EOF
# Loop generation at a random time every 12 hours
while :; do
# Generate random delay within 12 hours of seconds
# sleep the required time
# Run renew command
done

2
scripts/cleanup.sh Executable file
View file

@ -0,0 +1,2 @@
#!/bin/sh
[[ "$(curl -s "https://www.duckdns.org/update?domains=${CERTBOT_DOMAIN%.duckdns.org}&token=${DUCKDNS_TOKEN}&txt=${CERTBOT_VALIDATION}&clear=true")" = "OK" ]]

25
scripts/start.sh Executable file
View file

@ -0,0 +1,25 @@
#!/bin/sh
# Check variables DUCKDNS_TOKEN, DUCKDNS_DOMAIN, LETSENCRYPT_EMAIL
if [ -z "$DUCKDNS_TOKEN" ]; then
echo ERROR: Variable DUCKDNS_TOKEN is unset
exit 1
fi
if [ -z "$DUCKDNS_DOMAIN" ]; then
echo ERROR: Variable DUCKDNS_DOMAIN is unset
exit 1
fi
if [ -z "$LETSENCRYPT_EMAIL" ]; then
echo ERROR: Variable LETSENCRYPT_EMAIL is unset
exit 1
fi
# Print variables
echo DUCKDNS_TOKEN: $DUCKDNS_TOKEN
echo DUCKDNS_DOMAIN: $DUCKDNS_DOMAIN
echo LETSENCRYPT_EMAIL: $LETSENCRYPT_EMAIL
# Start automatic ssl certificate generation
/bin/sh /scripts/cert.sh