diff --git a/helper/build_config b/helper/build_config index 10628bbe..b3e83d9a 100755 --- a/helper/build_config +++ b/helper/build_config @@ -76,9 +76,16 @@ umask 0077 TT_WRAPPER="${HELPER}/tt2-wrapper" +# generate in a temporary location, then move if successful +tt_tmp_output_file_base="$(basename "${output_file}")" +tt_tmp_output_file="$(mktemp ngcpcfg."${tt_tmp_output_file_base}".XXXXXXXXXX)" + log_debug "Output file ${output_file} based on ${input_file}" -log_debug "Executing: $TT_WRAPPER ${input_file} > ${output_file}" -if "$TT_WRAPPER" "${input_file}" > "${output_file}" 2>/dev/null ; then +log_debug "Executing: $TT_WRAPPER ${input_file} > ${tt_tmp_output_file}" +log_debug " and: cat ${tt_tmp_output_file} > ${output_file}" +if "$TT_WRAPPER" "${input_file}" > "${tt_tmp_output_file}" 2>/dev/null && + cat "${tt_tmp_output_file}" > "${output_file}" 2>/dev/null ; then + rm -f "${tt_tmp_output_file}" log_info "Generating ${output_file}: OK" RC=0 else @@ -89,8 +96,9 @@ else 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 should provide more details." - + log_info "Running /usr/share/ngcp-ngcpcfg/helper/tt2-wrapper " + log_info "or inspecting temporary ${tt_tmp_output_file}" + log_info "should provide more details." fi if [ -L "$output_file" ] ; then