empty_line
info "Performing dist upgrade with ${GREEN}${tool}${NORMAL} ..."
- local found_ip_resolv="n"
- local awk_script=''
+ local found_ip_resolv=
+ local awk_script
local cleaned_old_repo="n"
local logfile=
local cmd=
empty_line
info "Tweaking '${CYAN}${YUM_CONF}${NORMAL}' ..."
+ found_ip_resolv=
if grep '^ip_resolve *= *4' "${YUM_CONF}" >/dev/null ; then
debug "Usage of IPv4 already configured"
found_ip_resolv="y"
fi
- if [[ "${found_ip_resolv}" == "y" ]] ; then
- awk_script='/^[main]/ {ok=1}
-ok==1 && /^ip_resolve/ {print "ip_resolve=4"; ok=0; next}
-{print $0} '
+ awk_script=$( mktemp /tmp/yum.dnf-resolv.XXXXXXXX.awk )
+ debug "AWK script: '${CYAN}${awk_script}${NORMAL}'"
+
+ if [[ "${found_ip_resolv}" ]] ; then
+ cat > "${awk_script}" <<-EOF
+ /^[main]/ {ok=1}
+ ok==1 && /^ip_resolve/ {print "ip_resolve=4"; ok=0; next}
+ {print \$0}
+ EOF
else
- awk_script='/^[main]/ {ok=1}
-ok==1 {print "ip_resolve=4"; ok=0}
-{print $0} '
+ cat > "${awk_script}" <<-EOF
+ /^[main]/ {ok=1}
+ ok==1 {print "ip_resolve=4"; ok=0}
+ {print \$0}
+ EOF
fi
+ debug "Content AWK script:\n$( cat "${awk_script}" )"
+ empty_line
CP -p "${YUM_CONF}" "${YUM_CONF}.$( date -r ${YUM_CONF} +'%Y-%m-%d_%H:%M:%S').bak"
- cmd="awk \"${awk_script}\" \"${YUM_CONF}\" > \"${YUM_CONF}.new\""
+ cmd="awk -f \"${awk_script}\" \"${YUM_CONF}\" > \"${YUM_CONF}.new\""
exec_cmd ${cmd}
if [[ -s "${YUM_CONF}.new" ]] ; then
MV "${YUM_CONF}.new" "${YUM_CONF}"
else
RM -f "${YUM_CONF}.new"
fi
+ RM_force "${awk_script}"
fi
- cmd="sed -i -e '/tsflags=/d' \"${YUM_CONF}\""
+ cmd="sed -i -e '/tsflags *=/d' \"${YUM_CONF}\""
exec_cmd ${cmd}
if [[ "${VERBOSE}" == "y" ]] ; then
exit 0
-# vim: list
+# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 list