41 lines
860 B
Bash
41 lines
860 B
Bash
|
#!/bin/sh
|
||
|
|
||
|
|
||
|
if [ $# -lt 2 ]
|
||
|
then
|
||
|
echo "------------- Syntax -------------"
|
||
|
echo "./genscripts.sh DOMAIN.de CF-TOKEN"
|
||
|
exit 2
|
||
|
fi
|
||
|
|
||
|
|
||
|
# Generate hook for certbot
|
||
|
|
||
|
echo """#!/bin/sh
|
||
|
cp -Lr /etc/letsencrypt/live/$1 /storage/certs/
|
||
|
cat /etc/letsencrypt/live/$1/fullchain.pem /etc/letsencrypt/live/$1/privkey.pem > /etc/haproxy/ssl/$1.pem
|
||
|
service haproxy reload
|
||
|
""" >> /storage/hooks/$1.sh
|
||
|
|
||
|
# Make it runable
|
||
|
|
||
|
chmod +x /storage/hooks/$1.sh
|
||
|
|
||
|
|
||
|
# CF-TOKEN ini File
|
||
|
|
||
|
echo "dns_cloudflare_api_token = $2" >> /storage/cf-tokens/$1.ini
|
||
|
chmod 777 /storage/cf-tokens/$1.ini
|
||
|
|
||
|
|
||
|
# Generate the SSL cert and restart haproxy
|
||
|
certbot certonly \
|
||
|
--dns-cloudflare \
|
||
|
--dns-cloudflare-credentials /storage/cf-tokens/$1.ini \
|
||
|
--dns-cloudflare-propagation-seconds 30 \
|
||
|
--deploy-hook /storage/hooks/$1.sh \
|
||
|
-d $1 \
|
||
|
-d *.$1
|
||
|
|
||
|
# Restart haproxy
|
||
|
service haproxy restart
|