diff --git a/scripts/check_proxy_state.sh b/scripts/check_proxy_state.sh index 9fe2906..e5973fc 100755 --- a/scripts/check_proxy_state.sh +++ b/scripts/check_proxy_state.sh @@ -35,6 +35,7 @@ do_proxy_restart() { $service_exec $SERVICE_NAME.containers.$PROXY_NAME start if docker ps | grep $PROXY_NAME ; then echo "$PROXY_NAME restarted successful"; + break ; else echo "Restarting number is only: "$retries" so try again" sleep $TIMEOUT; @@ -46,6 +47,8 @@ do_proxy_restart() { done fi done +cat $PROXY_CONFIG_DIR/new_config >> $PROXY_CONFIG_DIR/configs +rm $PROXY_CONFIG_DIR/new_config } check_domain() { diff --git a/scripts/nginx_config_create.sh b/scripts/nginx_config_create.sh index 8a84ead..2a0df7b 100755 --- a/scripts/nginx_config_create.sh +++ b/scripts/nginx_config_create.sh @@ -130,4 +130,5 @@ fi } >> "$file" -mv /tmp/$DOMAIN.conf $DOMAIN.conf +mv /tmp/$DOMAIN.conf $DOMAIN.conf; +echo "$DOMAIN" >> new_config diff --git a/scripts/scheduler.sh b/scripts/scheduler.sh index 1e8cff6..8cb9489 100755 --- a/scripts/scheduler.sh +++ b/scripts/scheduler.sh @@ -13,7 +13,7 @@ PROXY_CONFIG_DIR=$PROXY_CONFIG_DIR unset IFS -inotifywait --exclude .sw -m -e CREATE,CLOSE_WRITE,DELETE -r $DOMAIN_DIR $CERT_DIR $PROXY_CONFIG_DIR | \ +inotifywait --exclude .sw -m -e CREATE,CLOSE_WRITE,DELETE -r $DOMAIN_DIR $CERT_DIR | \ while read dir op file do @@ -22,34 +22,30 @@ do if [[ "${parent}" == "${CERT_DIR}" && "${op}" == "CLOSE_WRITE,CLOSE" ]] ; then DOMAIN=$(echo $dir|cut -d / -f3); - if [ -f "$CERT_DIR/$DOMAIN/new_certificate" ]; then + if [[ -f $CERT_DIR/$DOMAIN/renew_certificate && ! -f $PROXY_CONFIG_DIR/new_config ]]; then + rm $CERT_DIR/$DOMAIN/renew_certificate; echo "New cert created: '$DOMAIN'"; echo "newcert check proxy"; - /scripts/check_proxy_state.sh; + /scripts/check_proxy_state.sh $DOMAIN; fi - - elif [[ "${parent}" == "${PROXY_CONFIG_DIR}" && "${op}" == "CLOSE_WRITE,CLOSE" ]]; then - echo "proxy config created, changed "; - /scripts/check_proxy_state.sh; - - elif [[ "${parent}" == "${PROXY_CONFIG_DIR}" && "${op}" == "DELETE" ]] ; then - echo "proxy config deleted"; - FILE=$(echo $file) - if [ ! -f "$PROXY_CONFIG_DIR/$FILE" ]; then - /scripts/check_proxy_state.sh; - fi elif [[ "${parent}" == "${DOMAIN_DIR}" && "${op}" == "CLOSE_WRITE,CLOSE" ]]; then DOMAIN=$(echo $file); echo "domain config created, changed"; /scripts/nginx_config_create.sh "$DOMAIN"; - + + if [ -f "$PROXY_CONFIG_DIR/new_config" ] ; then + /scripts/check_proxy_state.sh "$DOMAIN"; + fi + elif [[ "${parent}" == "${DOMAIN_DIR}" && "${op}" == "DELETE" ]] ; then DOMAIN=$(echo $file); echo "domain deleted"; if [ ! -f "$DOMAIN_DIR/$DOMAIN" ]; then /scripts/nginx_config_create.sh "$DOMAIN" "DEL"; + /scripts/check_proxy_state.sh "$DOMAIN" "DEL"; fi + fi