Update 'scripts/check_certificates.sh'

Added exit rule once self signed certificate created at first time and added self sign certificate create when no any backend proxies found
This commit is contained in:
Gyorgy Berenyi
2023-06-08 07:38:10 +00:00
parent a744f92f9f
commit 9fc8949429

View File

@@ -54,6 +54,8 @@ letsencrypt_certificates() {
# In case of no running proxies found, try to start the service # In case of no running proxies found, try to start the service
if [[ "$RUNNING_CONTAINERS" -eq 0 ]] ; then if [[ "$RUNNING_CONTAINERS" -eq 0 ]] ; then
echo "No running proxies found, create self signed cetificate"; echo "No running proxies found, create self signed cetificate";
create_self_signed_certificate;
exit;
fi; fi;
for retries in $(seq 0 $((RESTART + 1))); do for retries in $(seq 0 $((RESTART + 1))); do
@@ -80,7 +82,7 @@ letsencrypt_certificates() {
create_self_signed_certificate() { create_self_signed_certificate() {
# Check any certificate exxits # Check any certificate exists
if [[ ! -f $DOMAIN_CERT_DIR/key.pem && ! -f $DOMAIN_CERT_DIR/fullchain.pem && ! -f $DOMAIN_CERT_DIR/cert.pem ]] ; then if [[ ! -f $DOMAIN_CERT_DIR/key.pem && ! -f $DOMAIN_CERT_DIR/fullchain.pem && ! -f $DOMAIN_CERT_DIR/cert.pem ]] ; then
@@ -102,13 +104,12 @@ fi
if [ ! -f "$DOMAIN_CERT_DIR/dhparam.pem" ]; then if [ ! -f "$DOMAIN_CERT_DIR/dhparam.pem" ]; then
# generate dhparam file # generate dhparam file
openssl dhparam -dsaparam -out $DOMAIN_CERT_DIR/dhparam.pem 4096; openssl dhparam -dsaparam -out $DOMAIN_CERT_DIR/dhparam.pem 4096;
create_self_signed_certificate;
exit;
fi fi
if [ "$GENERATE_CERTIFICATE" == "true" ]; then if [ "$GENERATE_CERTIFICATE" == "true" ]; then
create_self_signed_certificate;
sleep 10;
CURL_CHECK="curl -s -o /dev/null -w "%{http_code}" https://$LETSENCRYPT_URL"; CURL_CHECK="curl -s -o /dev/null -w "%{http_code}" https://$LETSENCRYPT_URL";
if [[ "$(eval $CURL_CHECK)" == "200" ]] ; then if [[ "$(eval $CURL_CHECK)" == "200" ]] ; then