diff --git a/cd.sh b/cd.sh index 4717b24..eb54620 100644 --- a/cd.sh +++ b/cd.sh @@ -17,9 +17,9 @@ cd_main () { cd_set_https_verification_off cd_update_packages_catalog cd_install_packages_tools - cd_install_ca - cd_copy_ca - cd_update_ca + cd_install_ca_certificates + cd_write_ca_certificates + cd_update_ca_certificates cd_set_https_verification_on cd_update_packages_catalog cd_upgrade_packages @@ -47,7 +47,7 @@ cd_set_environment () { ;; "alma") case "${CD_OS_VERSION}" in - "8") + "8"|"9") CD_PYTHON_PACKAGE="python3.11" CD_PYTHON_PACKAGES="/usr/lib64/python3.11/site-packages" ;; @@ -112,6 +112,8 @@ local text="" } cd_set_packages_repositories () { +local expression +local file cd_step "Set packages repositories" case "${CD_OS_NAME}" in "debian") @@ -122,7 +124,11 @@ deb https://deb.debian.org/debian bookworm-updates main deb https://deb.debian.org/debian-security bookworm-security main " ;; - "alma") echo "TODO" ;; + "alma") + file="/etc/yum.repos.d/almalinux.repo" + cd_sed "${file}" "|^m|# m|" "|^# b|b|" + cd_cat "${file}" + ;; *) cd_error_os "cd_set_packages_repositories" ;; esac } @@ -180,23 +186,31 @@ cd_install_packages_tools () { esac } -cd_install_ca () { +cd_install_ca_certificates () { cd_step "Install CA" cd_install_package "${CD_CA_PACKAGE}" } -cd_copy_ca () { +cd_write_ca_certificates () { +local index local target +local text cd_step "Copy CA" case "${CD_OS_NAME}" in "debian") target="/usr/local/share/ca-certificates" ;; "alma") target="/etc/pki/ca-trust/source/anchors" ;; *) cd_error_os "cd_copy_ca" ;; esac - echo "TODO" + index=1 + eval "text=\${CD_CA_${index}}" + while [ "${text}" ] ; do + cd_write "${target}/${index}.crt" "${text}" + index=$((index+1)) + eval "text=\${CD_CA_${index}}" + done } -cd_update_ca () { +cd_update_ca_certificates () { cd_step "Update CA" case "${CD_OS_NAME}" in "debian") update-ca-certificates || exit ;; @@ -326,13 +340,31 @@ cd_rm () { fi } +cd_sed () { +local expression +local file + if [ -f "${1}" ] ; then + file="${1}" + shift + for expression in "${@}" ; do + sed --in-place "s${expression}g" "${file}" || exit + done + fi +} + +cd_split () { + echo -n "\ +╶─╌╌┄┄┈┈ +" +} + cd_step () { if [ "${1}" ] ; then CD_STEP=$((CD_STEP+1)) echo -n "\ -╭─╌┄┈ +╭─╌╌┄┄┈┈ │ ${CD_STEP} ${1} -╰─╌┄┈ +╰─╌╌┄┄┈┈ " fi }