genscripts.sh hinzugefügt

This commit is contained in:
Phil 2024-02-19 20:01:05 +01:00
parent 46120b4021
commit 5b2264b6a2

41
genscripts.sh Normal file
View file

@ -0,0 +1,41 @@
#!/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