Checking generate certificate and create dhparam file if proxy dir not exists and finalize recovering process with domain delete from domain dir if any error happened

This commit is contained in:
2022-10-26 12:22:29 +00:00
parent 6801a7b83c
commit 8bf5736043
3 changed files with 29 additions and 15 deletions

View File

@@ -2,6 +2,7 @@
# Set env variables
GENERATE_CERTIFICATE=$GENERATE_CERTIFICATE
DOCKER_REGISTRY_URL=$DOCKER_REGISTRY_URL
LETSENCRYPT_URL=$LETSENCRYPT_URL
LETSENCRYPT_SERVICE_NAME=$LETSENCRYPT_SERVICE_NAME
@@ -90,11 +91,13 @@ if [ ! -f "$DOMAIN_CERT_DIR/dhparam.pem" ]; then
openssl dhparam -dsaparam -out $DOMAIN_CERT_DIR/dhparam.pem 4096;
fi
CURL_CHECK="curl -s -o /dev/null -w "%{http_code}" https://$LETSENCRYPT_URL";
if [ "$GENERATE_CERTIFICATE" == "true" ]; then
if [[ "$(eval $CURL_CHECK)" != "200" ]] ; then
CURL_CHECK="curl -s -o /dev/null -w "%{http_code}" https://$LETSENCRYPT_URL";
if [[ "$(eval $CURL_CHECK)" != "200" ]] ; then
create_self_signed_certificate;
else
else
file="$DOMAIN_CERT_DIR/letsencrypt"
{
echo "{ \"DOMAIN\": \"$DOMAIN\" }"
@@ -104,6 +107,6 @@ else
if [[ ! -f /$DOMAIN_CERT_DIR/key.pem && ! -f /$DOMAIN_CERT_DIR/fullchain.pem && ! -f /$DOMAIN_CERT_DIR/cert.pem ]] ; then
create_self_signed_certificate;
fi
fi
fi

View File

@@ -8,6 +8,7 @@ REGISTRY_URL=$DOCKER_REGISTRY_URL
# Set env variables
DOMAIN="$1"
DOMAIN_DIR=$DOMAIN_DIR
PROXY_SERVICE_FILE=$PROXY_SERVICE_FILE
ROLE=$ROLE
SERVICE_NAME=$SERVICE_NAME
@@ -65,6 +66,8 @@ do_proxy_restart() {
else
echo "Reached retrying limit: "$RESTART" ,giving up, starting recocer previous state"
recover_process;
fi
done
fi
@@ -82,7 +85,15 @@ check_domain() {
fi
}
recover_process() { echo "Recovering previous state"
recover_process() {
echo "Recovering previous state";
rm $DOMAIN_DIR/$DOMAIN;
echo "#############################################################################"
echo "######## DOMAIN ##### $DOMAIN #### DELETED ################"
echo "#############################################################################"
exit;
}
send_error_msg () { echo "Sending error messages"

View File

@@ -27,7 +27,7 @@ ALLOWED_NETWORK=$(jq -r '.ALLOWED_NETWORK | select(.!="null") | join(" ")' $DOMA
ALTERNATE_LOCATION_PATH=$(jq -r .ALTERNATE_LOCATION_PATH $DOMAIN_SOURCE)
# check whether certificates exist or not
if [[ "$HTTPS_PORT" != "" && "$GENERATE_CERTIFICATE" == "true" ]]; then
if [ "$HTTPS_PORT" != "" ]; then
/scripts/check_certificates.sh "$DOMAIN";
fi