From 80ead123abb65ad98a6c240855c51484a4831452 Mon Sep 17 00:00:00 2001 From: Alexander Lutay Date: Thu, 19 Sep 2019 13:02:39 +0200 Subject: [PATCH] TT#65907 Convert EXTRA_CONFIG_FILES from string to array to make shellcheck happy here Otherwise: > warning: Brace expansions and globs are literal in assignments. Quote it or use an array. [SC2125] Change-Id: I5a209cc1b50cea37e13aef40dfbd86c6178b53dc --- functions/main | 2 +- helper/build_config | 2 +- scripts/build | 20 +++++++++----------- scripts/check | 2 +- scripts/values | 2 +- 5 files changed, 13 insertions(+), 15 deletions(-) diff --git a/functions/main b/functions/main index d615025c..d6d2b0d3 100644 --- a/functions/main +++ b/functions/main @@ -100,7 +100,7 @@ fi if [ -d "${EXTRA_CONFIG_DIR:-}" ] && ls "${EXTRA_CONFIG_DIR}"/*.yml &>/dev/null ; then log_debug "EXTRA_CONFIG_DIR is configured and *.yml files are present, setting EXTRA_CONFIG_FILES" - EXTRA_CONFIG_FILES="${EXTRA_CONFIG_DIR}"/*.yml + EXTRA_CONFIG_FILES=("${EXTRA_CONFIG_DIR}"/*.yml) fi ## }}} diff --git a/helper/build_config b/helper/build_config index e1c351af..a1721033 100755 --- a/helper/build_config +++ b/helper/build_config @@ -116,7 +116,7 @@ else fi log_info "NOTE: Check those files for valid syntax and encoding:" - for f in "${input_file}" ${host_conf:-} ${local_conf:-} "$NGCPCTL_CONFIG" "${NETWORK_CONFIG:-}" ${EXTRA_CONFIG_FILES:-} "$CONSTANTS_CONFIG" ; do + for f in "${input_file}" ${host_conf:-} ${local_conf:-} "$NGCPCTL_CONFIG" "${NETWORK_CONFIG:-}" "${EXTRA_CONFIG_FILES[@]}" "$CONSTANTS_CONFIG" ; do [ -r "$f" ] && log_info "$f" done log_info "Running /usr/share/ngcp-ngcpcfg/helper/tt2-wrapper " diff --git a/scripts/build b/scripts/build index 5557b929..05657bb7 100755 --- a/scripts/build +++ b/scripts/build @@ -50,7 +50,7 @@ rm -f "${NGCP_SOCKETFILE}" "${HELPER}"/tt2-daemon # Load all the configs in proper order and check their avialability and valid YAML syntax -for f in ${NGCPCTL_CONFIG:-} ${HOST_CONFIG:-} ${LOCAL_CONFIG:-} ${NETWORK_CONFIG:-} ${EXTRA_CONFIG_FILES:-} ${CONSTANTS_CONFIG:-} ; do +for f in ${NGCPCTL_CONFIG:-} ${HOST_CONFIG:-} ${LOCAL_CONFIG:-} ${NETWORK_CONFIG:-} "${EXTRA_CONFIG_FILES[@]}" ${CONSTANTS_CONFIG:-} ; do if [ -r "$f" ] ; then if ! "${HELPER}/tt2-wrapper" "/dev/null" "${f}" ; then log_error "tt2-daemon cannot load ${f}:" @@ -85,15 +85,13 @@ else trigger_rebuild=false - if [ -n "${EXTRA_CONFIG_FILES:-}" ] ; then - for file in $EXTRA_CONFIG_FILES ; do - if git diff-index --name-only HEAD | grep -qe -- "$(basename "$file")" ; then - log_debug "modification in EXTRA_CONFIG_FILES file $file found" - trigger_rebuild=true - break # no reason for further checks - fi - done - fi + for file in "${EXTRA_CONFIG_FILES[@]}" ; do + if git diff-index --name-only HEAD | grep -qe -- "$(basename "$file")" ; then + log_debug "modification in EXTRA_CONFIG_FILES file ${file} found" + trigger_rebuild=true + break # no reason for further checks + fi + done if git diff-index --name-only HEAD | grep -q \ -e "$(basename "$NGCPCTL_CONFIG")" \ @@ -151,7 +149,7 @@ killall tt2-daemon 2>/dev/null || true rm -f "${NGCP_SOCKETFILE}" # Apply configured file ownership and permissions -for f in ${NGCPCTL_CONFIG:-} ${HOST_CONFIG:-} ${LOCAL_CONFIG:-} ${EXTRA_CONFIG_FILES:-} ; do +for f in ${NGCPCTL_CONFIG:-} ${HOST_CONFIG:-} ${LOCAL_CONFIG:-} "${EXTRA_CONFIG_FILES[@]}" ; do if [ ! -f "${f}" ]; then continue fi diff --git a/scripts/check b/scripts/check index cae5628a..cf2badd9 100755 --- a/scripts/check +++ b/scripts/check @@ -229,7 +229,7 @@ check_shared_storage() { } if [ "$*" = "" ] ; then - config_files="${NGCPCTL_CONFIG:-} ${HOST_CONFIG:-} ${LOCAL_CONFIG:-} ${NETWORK_CONFIG:-} ${EXTRA_CONFIG_FILES:-} ${CONSTANTS_CONFIG:-}" + config_files="${NGCPCTL_CONFIG:-} ${HOST_CONFIG:-} ${LOCAL_CONFIG:-} ${NETWORK_CONFIG:-} ${EXTRA_CONFIG_FILES[*]} ${CONSTANTS_CONFIG:-}" else config_files="$*" fi diff --git a/scripts/values b/scripts/values index b976d777..010187b5 100755 --- a/scripts/values +++ b/scripts/values @@ -54,7 +54,7 @@ rm -f "${NGCP_SOCKETFILE}" "${HELPER}"/tt2-daemon --quiet # Load all the configs in proper order and check their avialability and valid YAML syntax -for f in ${NGCPCTL_CONFIG:-} ${HOST_CONFIG:-} ${LOCAL_CONFIG:-} ${NETWORK_CONFIG:-} ${EXTRA_CONFIG_FILES:-} ${CONSTANTS_CONFIG:-} ; do +for f in ${NGCPCTL_CONFIG:-} ${HOST_CONFIG:-} ${LOCAL_CONFIG:-} ${NETWORK_CONFIG:-} "${EXTRA_CONFIG_FILES[@]}" ${CONSTANTS_CONFIG:-} ; do if [ -r "$f" ] ; then if ! "${HELPER}/tt2-wrapper" "/dev/null" "${f}" ; then log_error "tt2-daemon cannot load ${f}:"