]> Frank Brehm's Git Trees - pixelpark/create-vmware-tpl.git/commitdiff
Adding and using snippets/tpl.100.clear_repos.sh
authorFrank Brehm <frank.brehm@pixelpark.com>
Tue, 16 Jun 2020 14:02:50 +0000 (16:02 +0200)
committerFrank Brehm <frank.brehm@pixelpark.com>
Tue, 16 Jun 2020 14:02:50 +0000 (16:02 +0200)
kickstart/template-centos8.ks
snippets/tpl.100.clear_repos.sh [new file with mode: 0644]

index 45255074aaee1e84c657209bd1f1ca7b8eee761a..c1e107642f2ff32fdf4b5884c1aa47e560e4966c 100644 (file)
@@ -179,4 +179,9 @@ echo
 echo "Using snippet $tweak_grub_snippet"
 $SNIPPET($tweak_grub_snippet)
 
+#set $clear_repos_snippet = "per_status/" + $SYSTEM_STATUS + "/tpl.100.clear_repos.sh"
+echo
+echo "Using snippet $clear_repos_snippet"
+$SNIPPET($clear_repos_snippet)
+
 %end
diff --git a/snippets/tpl.100.clear_repos.sh b/snippets/tpl.100.clear_repos.sh
new file mode 100644 (file)
index 0000000..f20c15e
--- /dev/null
@@ -0,0 +1,33 @@
+## !/bin/bash
+#raw
+
+#-----------------------------------------------------------
+clear_all_repo_files() {
+
+    echo
+    echo "${HASH_LINE}"
+    echo
+    log "Cleaning all exiting repo files ..."
+
+    local repo_dir="/etc/yum.repos.d"
+    local old_dir="${repo_dir}/.old"
+    local repo_file=
+    local bname=
+
+    mkdir -pv "${old_dir}"
+
+    for repo_file in "${repo_dir}"/*.repo ; do
+        if [[ ! -f "${repo_file}" ]] ; then
+            continue
+        fi
+        bname=$( echo "${repo_file}" | basename )
+        echo " - ${bname}"
+        cp -pv "${repo_file}" "${old_dir}"
+        cp -v /dev/null "${repo_file}"
+    done
+
+}
+clear_all_repo_files
+
+#end raw
+## vim: ts=4 et list