refactor: only execute chown on files that the user do not already own

Signed-off-by: Dominik Willner th33xitus@gmail.com
This commit is contained in:
th33xitus
2022-04-21 13:07:52 +02:00
parent f46b1e7981
commit e32f618a6c

View File

@@ -49,7 +49,10 @@ function set_upstream_nginx_cfg(){
local files local files
files=$(find "${BACKUP_DIR}/nginx_cfg") files=$(find "${BACKUP_DIR}/nginx_cfg")
for file in ${files}; do for file in ${files}; do
if [ "$(stat -c "%U" "${file}" )" != "${USER}" ]; then
log_info "chown for user: ${USER} on file: ${file}"
sudo chown "${USER}" "${file}" sudo chown "${USER}" "${file}"
fi
done done
### copy nginx configs to target destination ### copy nginx configs to target destination
if [ ! -f "${NGINX_CONFD}/upstreams.conf" ]; then if [ ! -f "${NGINX_CONFD}/upstreams.conf" ]; then