From 0eff637b979223630dc041cd4263574ccd1515f9 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Tue, 16 Jun 2020 16:02:50 +0200 Subject: [PATCH] Adding and using snippets/tpl.100.clear_repos.sh --- kickstart/template-centos8.ks | 5 +++++ snippets/tpl.100.clear_repos.sh | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 snippets/tpl.100.clear_repos.sh diff --git a/kickstart/template-centos8.ks b/kickstart/template-centos8.ks index 4525507..c1e1076 100644 --- a/kickstart/template-centos8.ks +++ b/kickstart/template-centos8.ks @@ -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 index 0000000..f20c15e --- /dev/null +++ b/snippets/tpl.100.clear_repos.sh @@ -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 -- 2.39.5