spcd_os_sed

This commit is contained in:
Marc Beninca 2024-08-25 23:16:19 +02:00
parent 281bb2bf37
commit 2e913e4d31
Signed by: marc.beninca
GPG key ID: 9C7613450C80C24F

View file

@ -900,7 +900,7 @@ spcd_set_packages_repositories() {
"9") spcd_spr__file="/etc/yum.repos.d/almalinux-baseos.repo" ;; "9") spcd_spr__file="/etc/yum.repos.d/almalinux-baseos.repo" ;;
*) ;; *) ;;
esac esac
spcd_sed "${spcd_spr__file}" \ spcd_os_sed "${spcd_spr__file}" \
"|^mirrorlist|# mirrorlist|" \ "|^mirrorlist|# mirrorlist|" \
"|${SPCD_URL_DEFAULT}|${SPCD_URL_CHOSEN}|" \ "|${SPCD_URL_DEFAULT}|${SPCD_URL_CHOSEN}|" \
"|^# baseurl|baseurl|" "|^# baseurl|baseurl|"
@ -930,7 +930,7 @@ deb ${SPCD_URL_CHOSEN}-security ${SPCD_OS_VERSION}-security main
"update-non-oss" \ "update-non-oss" \
"update" \ "update" \
"openh264"; do "openh264"; do
spcd_sed "/etc/zypp/repos.d/repo-${spcd_spr__file}.repo" \ spcd_os_sed "/etc/zypp/repos.d/repo-${spcd_spr__file}.repo" \
"|${SPCD_URL_DEFAULT}|${SPCD_URL_CHOSEN}|" "|${SPCD_URL_DEFAULT}|${SPCD_URL_CHOSEN}|"
done done
;; ;;
@ -940,7 +940,7 @@ deb ${SPCD_URL_CHOSEN}-security ${SPCD_OS_VERSION}-security main
"9") spcd_spr__file="/etc/yum.repos.d/rocky.repo" ;; "9") spcd_spr__file="/etc/yum.repos.d/rocky.repo" ;;
*) ;; *) ;;
esac esac
spcd_sed "${spcd_spr__file}" \ spcd_os_sed "${spcd_spr__file}" \
"|^mirrorlist|# mirrorlist|" \ "|^mirrorlist|# mirrorlist|" \
"|${SPCD_URL_DEFAULT}|${SPCD_URL_CHOSEN}|" \ "|${SPCD_URL_DEFAULT}|${SPCD_URL_CHOSEN}|" \
"|^#baseurl|baseurl|" "|^#baseurl|baseurl|"
@ -1123,7 +1123,7 @@ spcd_install_packages() {
spcd_install_package "epel-release" spcd_install_package "epel-release"
[ -n "${SPCD_URL_EPEL}" ] && spcd_ip__epel="${SPCD_URL_EPEL}" || [ -n "${SPCD_URL_EPEL}" ] && spcd_ip__epel="${SPCD_URL_EPEL}" ||
spcd_ip__epel="https://dl.fedoraproject.org" spcd_ip__epel="https://dl.fedoraproject.org"
spcd_sed "/etc/yum.repos.d/epel.repo" \ spcd_os_sed "/etc/yum.repos.d/epel.repo" \
"|^metalink|# metalink|" \ "|^metalink|# metalink|" \
"|https://download.example|${spcd_ip__epel}|" \ "|https://download.example|${spcd_ip__epel}|" \
"|^#baseurl|baseurl|" "|^#baseurl|baseurl|"
@ -1230,14 +1230,14 @@ spcd_openssl() {
fi fi
} }
spcd_sed() { spcd_os_sed() {
spcd_sed__file="${1}" spcd_os_sed__file="${1}"
shift shift
if [ -f "${spcd_sed__file}" ]; then if [ -f "${spcd_os_sed__file}" ]; then
spcd_os_cat "${spcd_sed__file}" spcd_os_cat "${spcd_os_sed__file}"
for spcd_sed__regex in "${@}"; do for spcd_os_sed__regex in "${@}"; do
sed --in-place "s${spcd_sed__regex}g" "${spcd_sed__file}" && sed --in-place "s${spcd_os_sed__regex}g" "${spcd_os_sed__file}" &&
spcd_os_cat "${spcd_sed__file}" || exit spcd_os_cat "${spcd_os_sed__file}"
done done
fi fi
} }