From e32f618a6cc282e3ec2ffffa161a4dedc775533c Mon Sep 17 00:00:00 2001 From: th33xitus Date: Thu, 21 Apr 2022 13:07:52 +0200 Subject: [PATCH] refactor: only execute chown on files that the user do not already own Signed-off-by: Dominik Willner th33xitus@gmail.com --- scripts/nginx.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/nginx.sh b/scripts/nginx.sh index 2a474a8..5998680 100644 --- a/scripts/nginx.sh +++ b/scripts/nginx.sh @@ -49,7 +49,10 @@ function set_upstream_nginx_cfg(){ local files files=$(find "${BACKUP_DIR}/nginx_cfg") for file in ${files}; do - sudo chown "${USER}" "${file}" + if [ "$(stat -c "%U" "${file}" )" != "${USER}" ]; then + log_info "chown for user: ${USER} on file: ${file}" + sudo chown "${USER}" "${file}" + fi done ### copy nginx configs to target destination if [ ! -f "${NGINX_CONFD}/upstreams.conf" ]; then