TT#142950 ngcpcfg: Use proper file metadata when creating config with set

When we are creating a new file with set, for a known config.yml
variation, we need to apply the correct owner/group and mode or the next
build will modify them and that will change spurious commits that have
no relation to the action being taken at the time.

Change-Id: I93017cdcdcf22fa1c5ef8e103d215aa7bc110b9a
mr10.1
Guillem Jover 4 years ago
parent 88dfe811d0
commit 79ed4aa594

@ -52,6 +52,21 @@ fi
[ -f "${file}" ] || (log_error "missing ${file}. Exiting." ; exit 1) [ -f "${file}" ] || (log_error "missing ${file}. Exiting." ; exit 1)
[ -z "${data}" ] && (log_error "missing data to set. Exiting." ; exit 1) [ -z "${data}" ] && (log_error "missing data to set. Exiting." ; exit 1)
# Check whether we should use different permissions when creating the file.
CREATEFILE=no
if [ ! -f "${file}" ]; then
CREATEFILE=yes
if [ "${file}" = "${NETWORK_CONFIG:-}" ]; then
MODE="${NETWORK_CONFIG_CHMOD}"
USER="${NETWORK_CONFIG_USER}"
GROUP="${NETWORK_CONFIG_GROUP}"
else
MODE="${CONFIG_CHMOD}"
USER="${CONFIG_USER}"
GROUP="${CONFIG_GROUP}"
fi
fi
log_debug "Received data: ${data}" log_debug "Received data: ${data}"
option="${data%%=*}" option="${data%%=*}"
value="${data#*=}" value="${data#*=}"
@ -125,6 +140,12 @@ EOF
log_debug "perl -wCSD \"${tmp}\" || RC=$?" log_debug "perl -wCSD \"${tmp}\" || RC=$?"
perl -wCSD "${tmp}" || RC=$? perl -wCSD "${tmp}" || RC=$?
if [ "${CREATEFILE}" = "yes" ]; then
chmod "${MODE}" "${file}"
chown "${USER}" "${file}"
chgrp "${GROUP}" "${file}"
fi
if [ "${RC}" = "0" ] && "${b_show_diff:-false}"; then if [ "${RC}" = "0" ] && "${b_show_diff:-false}"; then
log_debug "${SCRIPTS}/diff || true" log_debug "${SCRIPTS}/diff || true"
"${SCRIPTS}"/diff || true "${SCRIPTS}"/diff || true

Loading…
Cancel
Save