Browse Source

use configuration variables at the beginning of the script

master
LecygneNoir 7 years ago
parent
commit
6c20cd561c
1 changed files with 7 additions and 2 deletions
  1. +7
    -2
      create-certificat

+ 7
- 2
create-certificat View File

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

Loading…
Cancel
Save