From: Frank Brehm Date: Wed, 15 Nov 2023 11:14:55 +0000 (+0100) Subject: Adding snippets/tpl.120.config_yum.sh X-Git-Tag: 3.2.1~14 X-Git-Url: https://git.uhu-banane.org/?a=commitdiff_plain;h=041c397ceef7541e50efb81b8f49565e4a4bfdd1;p=pixelpark%2Fcreate-vmware-tpl.git Adding snippets/tpl.120.config_yum.sh --- diff --git a/snippets/tpl.120.config_yum.sh b/snippets/tpl.120.config_yum.sh new file mode 100644 index 0000000..cdb9841 --- /dev/null +++ b/snippets/tpl.120.config_yum.sh @@ -0,0 +1,69 @@ +## !/bin/bash +#raw + +#----------------------------------------------------------- +config_yum() { + + echo -e "\e[0Ksection_start:$( date +%s ):ks_config_yum[collapsed=true]\r\e[0KConfiguring Yum and/or Dnf config ..." + echo + echo "${HASH_LINE}" + echo + log "Configuring Yum and/or Dnf config ..." + + local cfg_file= + local target= + local changed= + + for cfg_file in /etc/dnf/dnf.conf /etc/yum.conf ; do + if [[ ! -f "${cfg_file}" ]] ; then + continue + fi + + echo + printf "Checking '%s': " "${cfg_file}" + if [[ -h "${cfg_file}" ]] ; then + target=$( readlink -f "${cfg_file}" ) + if [[ "${target}" == '/etc/dnf/dnf.conf' ]] ; then + echo "is a symlink to '/etc/dnf/dnf.conf'." + continue + fi + fi + echo + changed= + + echo "Checking '${cfg_file}' ..." + echo "Old content:" + echo "---------- snip ----------" + cat "${cfg_file}" + echo "---------- snip ----------" + + if grep --perl-regexp -i --quiet '^\s*install_weak_deps\s*=' "${cfg_file}" ; then + if grep --perl-regexp -i --quiet '^\s*install_weak_deps\s*=\s*True' "${cfg_file}" ; then + echo + echo "Modifying install_weak_deps in '${cfg_file}' ..." + sed -i -e 's/^\s*install_weak_deps\s*=.*/install_weak_deps=False/i' "${cfg_file}" + changed="y" + fi + else + echo + echo "Adding 'install_weak_deps=False' to '${cfg_file}' ..." + echo 'install_weak_deps=False' >> "${cfg_file}" + changed="y" + fi + + if [[ "${changed}" ]] ; then + echo + echo "New content:" + echo "---------- snip ----------" + cat "${cfg_file}" + echo "---------- snip ----------" + fi + done + + + echo -e "\e[0Ksection_end:$( date +%s ):ks_config_yum\r\e[0K" +} +config_yum + +#end raw +## vim: ts=4 et list