This commit is contained in:
Marc Beninca 2024-05-03 21:03:07 +02:00
parent 18e3f300d3
commit cf99e6ff2f
Signed by: marc.beninca
GPG key ID: 9C7613450C80C24F
2 changed files with 38 additions and 36 deletions

72
cd.sh
View file

@ -42,14 +42,14 @@ cd_set_environment_variables () {
[ "${CD_CA_1}" ] && CD_CA=true [ "${CD_CA_1}" ] && CD_CA=true
# #
case "$(cd_grep_os ID)" in case "$(cd_grep_os ID)" in
"debian")
CD_OS_ID="${CD_OS_DEBIAN}"
CD_OS_VERSION="$(cd_grep_os VERSION_CODENAME)"
;;
"almalinux") "almalinux")
CD_OS_ID="${CD_OS_ALMA}" CD_OS_ID="${CD_OS_ALMA}"
CD_OS_VERSION="$(cd_grep_os VERSION_ID)" CD_OS_VERSION="$(cd_grep_os VERSION_ID)"
;; ;;
"debian")
CD_OS_ID="${CD_OS_DEBIAN}"
CD_OS_VERSION="$(cd_grep_os VERSION_CODENAME)"
;;
esac esac
# #
CD_CA_PACKAGE="ca-certificates" CD_CA_PACKAGE="ca-certificates"
@ -57,18 +57,6 @@ cd_set_environment_variables () {
CD_GIT_PACKAGE="git" CD_GIT_PACKAGE="git"
# #
case "${CD_OS_ID}" in case "${CD_OS_ID}" in
"${CD_OS_DEBIAN}")
CD_OS_REPO="${CD_DEFAULT_REPO_DEBIAN}"
[ "${CD_REPO_DEBIAN}" ] && CD_OS_REPO="${CD_REPO_DEBIAN}"
case "${CD_OS_VERSION}" in
"bookworm"|"bullseye") cd_nop ;;
*) cd_error_os "CD_OS_VERSION" ;;
esac
CD_CA_ROOT="/usr/local/share/ca-certificates"
CD_PYTHON_COMMAND="python3"
CD_PYTHON_PACKAGE="python3"
CD_PYTHON_PACKAGES="/usr/lib/python3/dist-packages"
;;
"${CD_OS_ALMA}") "${CD_OS_ALMA}")
CD_OS_REPO="${CD_DEFAULT_REPO_ALMA}" CD_OS_REPO="${CD_DEFAULT_REPO_ALMA}"
[ "${CD_REPO_ALMA}" ] && CD_OS_REPO="${CD_REPO_ALMA}" [ "${CD_REPO_ALMA}" ] && CD_OS_REPO="${CD_REPO_ALMA}"
@ -81,6 +69,18 @@ cd_set_environment_variables () {
CD_PYTHON_PACKAGE="python3.11" CD_PYTHON_PACKAGE="python3.11"
CD_PYTHON_PACKAGES="/usr/lib64/python3.11/site-packages" CD_PYTHON_PACKAGES="/usr/lib64/python3.11/site-packages"
;; ;;
"${CD_OS_DEBIAN}")
CD_OS_REPO="${CD_DEFAULT_REPO_DEBIAN}"
[ "${CD_REPO_DEBIAN}" ] && CD_OS_REPO="${CD_REPO_DEBIAN}"
case "${CD_OS_VERSION}" in
"bookworm"|"bullseye") cd_nop ;;
*) cd_error_os "CD_OS_VERSION" ;;
esac
CD_CA_ROOT="/usr/local/share/ca-certificates"
CD_PYTHON_COMMAND="python3"
CD_PYTHON_PACKAGE="python3"
CD_PYTHON_PACKAGES="/usr/lib/python3/dist-packages"
;;
*) cd_error_os "CD_OS_ID" ;; *) cd_error_os "CD_OS_ID" ;;
esac esac
# continuous integration platform # continuous integration platform
@ -141,14 +141,6 @@ local expression
local file local file
cd_step "Set packages repositories" cd_step "Set packages repositories"
case "${CD_OS_ID}" in case "${CD_OS_ID}" in
"${CD_OS_DEBIAN}")
cd_write "/etc/apt/sources.list" "\
deb ${CD_OS_REPO} ${CD_OS_VERSION} main
deb ${CD_OS_REPO} ${CD_OS_VERSION}-backports main
deb ${CD_OS_REPO} ${CD_OS_VERSION}-updates main
deb ${CD_OS_REPO}-security ${CD_OS_VERSION}-security main
"
;;
"${CD_OS_ALMA}") "${CD_OS_ALMA}")
file="/etc/yum.repos.d/almalinux.repo" file="/etc/yum.repos.d/almalinux.repo"
cd_sed "${file}" \ cd_sed "${file}" \
@ -157,12 +149,21 @@ deb ${CD_OS_REPO}-security ${CD_OS_VERSION}-security main
"|^# baseurl|baseurl|" "|^# baseurl|baseurl|"
cd_cat "${file}" cd_cat "${file}"
;; ;;
"${CD_OS_DEBIAN}")
cd_write "/etc/apt/sources.list" "\
deb ${CD_OS_REPO} ${CD_OS_VERSION} main
deb ${CD_OS_REPO} ${CD_OS_VERSION}-backports main
deb ${CD_OS_REPO} ${CD_OS_VERSION}-updates main
deb ${CD_OS_REPO}-security ${CD_OS_VERSION}-security main
"
;;
esac esac
} }
cd_set_packages_configuration () { cd_set_packages_configuration () {
cd_step "Set packages configuration" cd_step "Set packages configuration"
case "${CD_OS_ID}" in case "${CD_OS_ID}" in
"${CD_OS_ALMA}") cd_mkdir "/etc/dnf/dnf.conf.d" ;;
"${CD_OS_DEBIAN}") "${CD_OS_DEBIAN}")
export DEBIAN_FRONTEND="noninteractive" export DEBIAN_FRONTEND="noninteractive"
cd_write "/etc/apt/apt.conf.d/apt.conf" "\ cd_write "/etc/apt/apt.conf.d/apt.conf" "\
@ -173,7 +174,6 @@ APT::Install-Suggests False;
Dir::Etc::SourceParts \"\"; Dir::Etc::SourceParts \"\";
" "
;; ;;
"${CD_OS_ALMA}") cd_mkdir "/etc/dnf/dnf.conf.d" ;;
esac esac
} }
@ -181,14 +181,14 @@ cd_set_https_verification_off () {
if [ "${CD_CA}" -o "${CD_OS_ID}" = "${CD_OS_DEBIAN}" ] ; then if [ "${CD_CA}" -o "${CD_OS_ID}" = "${CD_OS_DEBIAN}" ] ; then
cd_step "Set HTTPS verification off" cd_step "Set HTTPS verification off"
case "${CD_OS_ID}" in case "${CD_OS_ID}" in
"${CD_OS_DEBIAN}")
cd_write "/etc/apt/apt.conf.d/https" "\
Acquire::https::Verify-Peer False;
"
;;
"${CD_OS_ALMA}") "${CD_OS_ALMA}")
cd_write "/etc/dnf/dnf.conf.d/https.conf" "\ cd_write "/etc/dnf/dnf.conf.d/https.conf" "\
sslverify=False sslverify=False
"
;;
"${CD_OS_DEBIAN}")
cd_write "/etc/apt/apt.conf.d/https" "\
Acquire::https::Verify-Peer False;
" "
;; ;;
esac esac
@ -198,16 +198,16 @@ sslverify=False
cd_update_packages_catalog () { cd_update_packages_catalog () {
cd_step "Update packages catalog" cd_step "Update packages catalog"
case "${CD_OS_ID}" in case "${CD_OS_ID}" in
"${CD_OS_DEBIAN}") apt-get update || exit ;;
"${CD_OS_ALMA}") dnf makecache || exit ;; "${CD_OS_ALMA}") dnf makecache || exit ;;
"${CD_OS_DEBIAN}") apt-get update || exit ;;
esac esac
} }
cd_install_packages_tools () { cd_install_packages_tools () {
cd_step "Install packages tools" cd_step "Install packages tools"
case "${CD_OS_ID}" in case "${CD_OS_ID}" in
"${CD_OS_DEBIAN}") cd_install_package "apt-utils" ;;
"${CD_OS_ALMA}") cd_nop ;; "${CD_OS_ALMA}") cd_nop ;;
"${CD_OS_DEBIAN}") cd_install_package "apt-utils" ;;
esac esac
} }
@ -233,8 +233,8 @@ local text
cd_update_ca_certificates () { cd_update_ca_certificates () {
cd_step "Update CA" cd_step "Update CA"
case "${CD_OS_ID}" in case "${CD_OS_ID}" in
"${CD_OS_DEBIAN}") update-ca-certificates || exit ;;
"${CD_OS_ALMA}") update-ca-trust || exit ;; "${CD_OS_ALMA}") update-ca-trust || exit ;;
"${CD_OS_DEBIAN}") update-ca-certificates || exit ;;
esac esac
} }
@ -242,8 +242,8 @@ cd_set_https_verification_on () {
if [ "${CD_CA}" -o "${CD_OS_ID}" = "${CD_OS_DEBIAN}" ] ; then if [ "${CD_CA}" -o "${CD_OS_ID}" = "${CD_OS_DEBIAN}" ] ; then
cd_step "Set HTTPS verification on" cd_step "Set HTTPS verification on"
case "${CD_OS_ID}" in case "${CD_OS_ID}" in
"${CD_OS_DEBIAN}") cd_rm "/etc/apt/apt.conf.d/https" ;;
"${CD_OS_ALMA}") cd_rm "/etc/dnf/dnf.conf.d/https.conf" ;; "${CD_OS_ALMA}") cd_rm "/etc/dnf/dnf.conf.d/https.conf" ;;
"${CD_OS_DEBIAN}") cd_rm "/etc/apt/apt.conf.d/https" ;;
esac esac
fi fi
} }
@ -251,8 +251,8 @@ cd_set_https_verification_on () {
cd_upgrade_packages () { cd_upgrade_packages () {
cd_step "Upgrade packages" cd_step "Upgrade packages"
case "${CD_OS_ID}" in case "${CD_OS_ID}" in
"${CD_OS_DEBIAN}") apt-get upgrade --assume-yes || exit ;;
"${CD_OS_ALMA}") dnf upgrade --assumeyes || exit ;; "${CD_OS_ALMA}") dnf upgrade --assumeyes || exit ;;
"${CD_OS_DEBIAN}") apt-get upgrade --assume-yes || exit ;;
esac esac
} }
@ -269,8 +269,8 @@ cd_install_python () {
cd_clean_packages_cache () { cd_clean_packages_cache () {
cd_step "Clean packages cache" cd_step "Clean packages cache"
case "${CD_OS_ID}" in case "${CD_OS_ID}" in
"${CD_OS_DEBIAN}") apt-get clean || exit ;;
"${CD_OS_ALMA}") dnf clean all || exit ;; "${CD_OS_ALMA}") dnf clean all || exit ;;
"${CD_OS_DEBIAN}") apt-get clean || exit ;;
esac esac
} }

View file

@ -29,6 +29,8 @@ from various CA, CI, OCI / OS.
## Tasks ## Tasks
* write bats
* handle cloning credentials * handle cloning credentials
* show CA certificates as text * show CA certificates as text
* write Python bootstrap * write Python bootstrap