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