From ade538dc14238a4f87fb377682dc979e8f74436b Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 25 Aug 2024 23:12:21 +0200 Subject: [PATCH] spcd_os_write --- spcd/main.sh | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/spcd/main.sh b/spcd/main.sh index eb380d7..0ec836b 100644 --- a/spcd/main.sh +++ b/spcd/main.sh @@ -895,14 +895,14 @@ spcd_set_packages_repositories() { ;; "${SPCD_OS_ALPINE}") spcd_spr__file="/etc/apk/repositories" - spcd_write "${spcd_spr__file}" "\ + spcd_os_write "${spcd_spr__file}" "\ ${SPCD_URL_CHOSEN}/v${SPCD_OS_VERSION}/main ${SPCD_URL_CHOSEN}/v${SPCD_OS_VERSION}/community " ;; "${SPCD_OS_DEBIAN}") spcd_spr__file="/etc/apt/sources.list" - spcd_write "${spcd_spr__file}" "\ + spcd_os_write "${spcd_spr__file}" "\ deb ${SPCD_URL_CHOSEN} ${SPCD_OS_VERSION} main deb ${SPCD_URL_CHOSEN} ${SPCD_OS_VERSION}-backports main deb ${SPCD_URL_CHOSEN} ${SPCD_OS_VERSION}-updates main @@ -935,7 +935,7 @@ deb ${SPCD_URL_CHOSEN}-security ${SPCD_OS_VERSION}-security main ;; "${SPCD_OS_UBUNTU}") spcd_spr__file="/etc/apt/sources.list" - spcd_write "${spcd_spr__file}" "\ + spcd_os_write "${spcd_spr__file}" "\ deb ${SPCD_URL_CHOSEN} ${SPCD_OS_VERSION} main universe deb ${SPCD_URL_CHOSEN} ${SPCD_OS_VERSION}-backports main universe deb ${SPCD_URL_CHOSEN} ${SPCD_OS_VERSION}-updates main universe @@ -948,7 +948,7 @@ deb ${SPCD_URL_CHOSEN} ${SPCD_OS_VERSION}-security main universe spcd_set_packages_configuration() { spcd_step "Set packages configuration" - spcd_write "${SPCD_PM_CONF_PATH}" "${SPCD_PM_CONF_TEXT}" + spcd_os_write "${SPCD_PM_CONF_PATH}" "${SPCD_PM_CONF_TEXT}" case "${SPCD_OS_ID}" in "${SPCD_OS_ARCH}") pacman-key --init @@ -966,7 +966,7 @@ spcd_set_https_verification_off() { if [ -n "${SPCD_CA}" ] || [ "${SPCD_PM}" = "${SPCD_PM_APT}" ]; then spcd_step "Set HTTPS verification off" spcd_os_mkdir "$(dirname "${SPCD_PM_HTTPS_PATH}")" - spcd_write "${SPCD_PM_HTTPS_PATH}" "${SPCD_PM_HTTPS_TEXT}" + spcd_os_write "${SPCD_PM_HTTPS_PATH}" "${SPCD_PM_HTTPS_TEXT}" fi } @@ -980,7 +980,7 @@ spcd_set_dns_resolving() { nameserver ${spcd_sdr__value} " done - spcd_write "${SPCD_DNS_FILE}" "${spcd_sdr__text}" + spcd_os_write "${SPCD_DNS_FILE}" "${spcd_sdr__text}" } spcd_update_packages_catalog() { @@ -1011,7 +1011,7 @@ spcd_write_ca_certificates() { [ -n "${spcd_wcc__text}" ] || break spcd_wcc__path="${SPCD_CA_ROOT}/${spcd_wcc__index}.crt" spcd_split - spcd_write "${spcd_wcc__path}" "${spcd_wcc__text}" + spcd_os_write "${spcd_wcc__path}" "${spcd_wcc__text}" spcd_openssl "${spcd_wcc__path}" done } @@ -1064,7 +1064,7 @@ spcd_install_python() { *) ;; esac spcd_step "Configure PIP" - spcd_write "/etc/pip.conf" "\ + spcd_os_write "/etc/pip.conf" "\ [global] index-url = ${SPCD_URL_PYTHON} " @@ -1178,7 +1178,7 @@ spcd_write_python_module() { done for spcd_wpm__root in \ "${SPCD_PYTHON_PACKAGES}" "${SPCD_PYTHON_VENV_PACKAGES}"; do - spcd_write "${spcd_wpm__root}/env.py" "${spcd_wpm__text} + spcd_os_write "${spcd_wpm__root}/env.py" "${spcd_wpm__text} SPCD_STEP = $((SPCD_STEP + 1)) " done @@ -1230,14 +1230,15 @@ spcd_sed() { fi } -spcd_write() { - spcd_write__file="${1}" - spcd_write__text="${2}" - if [ -n "${spcd_write__file}" ]; then - [ -f "${spcd_write__file}" ] && spcd_os_cat "${spcd_write__file}" - echo "→ ${spcd_write__file}" - printf "%s" "${spcd_write__text}" >"${spcd_write__file}" || exit - spcd_os_cat "${spcd_write__file}" +spcd_os_write() { + spcd_os_write__file="${1}" + spcd_os_write__text="${2}" + if [ -n "${spcd_os_write__file}" ]; then + [ -f "${spcd_os_write__file}" ] && + spcd_os_cat "${spcd_os_write__file}" + echo "→ ${spcd_os_write__file}" + printf "%s" "${spcd_os_write__text}" >"${spcd_os_write__file}" + spcd_os_cat "${spcd_os_write__file}" fi }