]> Frank Brehm's Git Trees - pixelpark/create-vmware-tpl.git/commitdiff
Adding snippets/tpl.120.config_yum.sh
authorFrank Brehm <frank.brehm@pixelpark.com>
Wed, 15 Nov 2023 11:14:55 +0000 (12:14 +0100)
committerFrank Brehm <frank.brehm@pixelpark.com>
Wed, 15 Nov 2023 11:14:55 +0000 (12:14 +0100)
snippets/tpl.120.config_yum.sh [new file with mode: 0644]

diff --git a/snippets/tpl.120.config_yum.sh b/snippets/tpl.120.config_yum.sh
new file mode 100644 (file)
index 0000000..cdb9841
--- /dev/null
@@ -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