From e8e2761cff041f06b0b1de815847b3c952ad9b05 Mon Sep 17 00:00:00 2001 From: redxef Date: Fri, 26 Jan 2024 00:27:04 +0100 Subject: [PATCH] Improve startup command inotifywait. --- start-nginx.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/start-nginx.sh b/start-nginx.sh index c01c38a..d86f25a 100755 --- a/start-nginx.sh +++ b/start-nginx.sh @@ -38,12 +38,12 @@ run_nginx() { run_inotifywait() { while :; do wait_files="$(find "$dstdir" -type f -exec \ - sed -En '/ssl_certificate/ s/^\s*ssl_certificate(_key)? (.*);.*$/\2/p' {} \; | sort | uniq)" - wait_directories="$(echo "$wait_files" | xargs -0 dirname | sort | uniq)" + sed -En '/ssl_certificate/ s/^\s*ssl_certificate(_key)? (.*);.*$/\2/p' {} \; | sort -u)" + wait_directories="$(echo "$wait_files" | xargs -n 1 dirname | sort -u)" echo "monitoring the following files:" echo "$wait_files" matched_files="$(echo "$wait_directories" | inotifywait --fromfile=- -e close_write -e modify -e create)" - if [[ -n "$(comm -12 <(sort <<< "$matched_files") <(echo "$wait_files"))" ]]; then + if [[ -n "$(comm -12 <(sort -u <<< "$matched_files") <(echo "$wait_files"))" ]]; then nginx -s reload fi done