From 48e68830314b6c46927b731c02bc77b3de2d9d94 Mon Sep 17 00:00:00 2001 From: gyurix Date: Tue, 29 Jun 2021 11:41:49 +0000 Subject: [PATCH] Check whether any certificates exist via script. --- scripts/check_certificates.sh | 16 ++++++++++++++++ scripts/nginx_config_create.sh | 8 ++++++++ 2 files changed, 24 insertions(+) create mode 100755 scripts/check_certificates.sh diff --git a/scripts/check_certificates.sh b/scripts/check_certificates.sh new file mode 100755 index 0000000..d7559b2 --- /dev/null +++ b/scripts/check_certificates.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +# Set env variables + + DOMAIN_DIR=$DOMAIN_DIR + CERT_DIR=$CERT_DIR + +create_self_signed_certificate() { +# generate key +openssl req -x509 -newkey rsa:4096 -keyout $CERT_DIR/key.pem -out $CERT_DIR/cert.pem -days 365 -sha256 -nodes -subj '/CN=domain.tld' + +# generate dhparam file +openssl dhparam -out $CERT_DIR/dhparam.pem 4096 +} + + diff --git a/scripts/nginx_config_create.sh b/scripts/nginx_config_create.sh index 5edc118..1810a68 100755 --- a/scripts/nginx_config_create.sh +++ b/scripts/nginx_config_create.sh @@ -109,3 +109,11 @@ echo "location / { }" } >> "$file" + +# check whether certificates exist or not + +if [ $HTTPS_PORT != "" ]; then + ./check_certificates.sh; +fi + +