|
|
- #!/bin/bash
-
- #Configuration variables
- certbot_bin="/usr/bin/certbot"
- haproxy_pem_path="/etc/haproxy/cert"
-
-
- if [ $# -ne 1 ] ; then
- echo "$(date +%c) Please give domain name as parameter"
- exit 1
- fi
-
- echo "$(date +%c) Generate certificat for ${1}"
-
- ${certbot_bin} certonly --domains $1 --renew-by-default --http-01-port 63443 --agree-tos
- if [ $? -eq 0 ]; then
- echo "$(date +%c) Success ! Now creating ${1}.pem"
- cat /etc/letsencrypt/live/$1/fullchain.pem /etc/letsencrypt/live/$1/privkey.pem > ${haproxy_pem_path}/$1.pem
- systemctl reload haproxy
- else
- echo "$(date +%c) Error creating certificate with error code $?, exit script..."
- exit 1
- fi
- exit 0
-
|