Fixing some issues in letsencrypt certificates creation.

This commit is contained in:
2021-07-01 15:00:00 +00:00
parent 101e40235a
commit 809538b138
2 changed files with 7 additions and 20 deletions

View File

@@ -11,7 +11,6 @@ service_exec="docker run --rm -v /etc/user/config/services/:/services/:ro -v /va
letsencrypt_certificates() { letsencrypt_certificates() {
$service_exec /services/letsencrypt.json start $service_exec /services/letsencrypt.json start
} }
create_self_signed_certificate() { create_self_signed_certificate() {
@@ -28,6 +27,11 @@ openssl req -x509 -newkey rsa:4096 -keyout $CERT_DIR/key.pem -out $CERT_DIR/full
if [[ "$(ls -A $CERT_DIR)" == "" ]]; then if [[ "$(ls -A $CERT_DIR)" == "" ]]; then
echo "$DOMAIN not contains certificates, creates new." echo "$DOMAIN not contains certificates, creates new."
mkdir -p $CERT_DIR; mkdir -p $CERT_DIR;
else
file="$CERT_DIR/letsencrypt"
{
echo "{ \"DOMAIN\": \"$DOMAIN\" }"
} >> "$file"
fi fi
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";

View File

@@ -170,8 +170,6 @@ fi
unset IFS unset IFS
NEW_CERT=0;
inotifywait --exclude .sw -m -e CREATE,CLOSE_WRITE,CLOSE,DELETE -r $DOMAIN_DIR $CERT_DIR $PROXY_CONFIG_DIR | \ inotifywait --exclude .sw -m -e CREATE,CLOSE_WRITE,CLOSE,DELETE -r $DOMAIN_DIR $CERT_DIR $PROXY_CONFIG_DIR | \
while read dir op file while read dir op file
@@ -180,18 +178,10 @@ do
parent="/"$(echo $dir|cut -d / -f2) parent="/"$(echo $dir|cut -d / -f2)
if [[ "${parent}" == "${CERT_DIR}" && "${op}" == "CREATE" ]]; then if [[ "${parent}" == "${CERT_DIR}" && "${op}" == "CREATE,CLOSE_WRITE,CLOSE" && "$(file)" == "new_certificate" ]]; then
NEW_CERT=1;
fi;
if [[ "${parent}" == "${CERT_DIR}" && "${op}" == "CLOSE_WRITE,CLOSE" ]]; then
DOMAIN=$(echo $dir|cut -d / -f3); DOMAIN=$(echo $dir|cut -d / -f3);
echo "New cert created: '$DOMAIN'"; echo "New cert created: '$DOMAIN'";
if [[ "$NEW_CERT" -eq 0 ]] ; then #check_proxy_state;
echo "newcert check proxy";
check_proxy_state;
fi
NEW_CERT=0;
elif [[ "${parent}" == "${PROXY_CONFIG_DIR}" && "${op}" == "CLOSE_WRITE,CLOSE" ]] || \ elif [[ "${parent}" == "${PROXY_CONFIG_DIR}" && "${op}" == "CLOSE_WRITE,CLOSE" ]] || \
[[ "${parent}" == "${PROXY_CONFIG_DIR}" && "${op}" == "DELETE" ]] ; then [[ "${parent}" == "${PROXY_CONFIG_DIR}" && "${op}" == "DELETE" ]] ; then
@@ -210,10 +200,3 @@ do
fi fi
done done
# Running containers from existing roles
# echo $CONTAINERS_BY_ROLE;
# echo $RUNNING_CONTAINERS;
#$service_exec $SERVICE_NAME.containers.$CONTAINER stop
#$service_exec $SERVICE_NAME.containers.$CONTAINER start