From cf99e6ff2fe75fb6b89a37a3de9bed11d55f389a Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 3 May 2024 21:03:07 +0200 Subject: [PATCH] =?UTF-8?q?=E2=86=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cd.sh | 72 +++++++++++++++++++++++++++---------------------------- readme.md | 2 ++ 2 files changed, 38 insertions(+), 36 deletions(-) diff --git a/cd.sh b/cd.sh index f0bd9d2..665f82d 100644 --- a/cd.sh +++ b/cd.sh @@ -42,14 +42,14 @@ cd_set_environment_variables () { [ "${CD_CA_1}" ] && CD_CA=true # case "$(cd_grep_os ID)" in - "debian") - CD_OS_ID="${CD_OS_DEBIAN}" - CD_OS_VERSION="$(cd_grep_os VERSION_CODENAME)" - ;; "almalinux") CD_OS_ID="${CD_OS_ALMA}" CD_OS_VERSION="$(cd_grep_os VERSION_ID)" ;; + "debian") + CD_OS_ID="${CD_OS_DEBIAN}" + CD_OS_VERSION="$(cd_grep_os VERSION_CODENAME)" + ;; esac # CD_CA_PACKAGE="ca-certificates" @@ -57,18 +57,6 @@ cd_set_environment_variables () { CD_GIT_PACKAGE="git" # 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_REPO="${CD_DEFAULT_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_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" ;; esac # continuous integration platform @@ -141,14 +141,6 @@ local expression local file cd_step "Set packages repositories" 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}") file="/etc/yum.repos.d/almalinux.repo" cd_sed "${file}" \ @@ -157,12 +149,21 @@ deb ${CD_OS_REPO}-security ${CD_OS_VERSION}-security main "|^# baseurl|baseurl|" 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 } cd_set_packages_configuration () { cd_step "Set packages configuration" case "${CD_OS_ID}" in + "${CD_OS_ALMA}") cd_mkdir "/etc/dnf/dnf.conf.d" ;; "${CD_OS_DEBIAN}") export DEBIAN_FRONTEND="noninteractive" cd_write "/etc/apt/apt.conf.d/apt.conf" "\ @@ -173,7 +174,6 @@ APT::Install-Suggests False; Dir::Etc::SourceParts \"\"; " ;; - "${CD_OS_ALMA}") cd_mkdir "/etc/dnf/dnf.conf.d" ;; esac } @@ -181,14 +181,14 @@ cd_set_https_verification_off () { if [ "${CD_CA}" -o "${CD_OS_ID}" = "${CD_OS_DEBIAN}" ] ; then cd_step "Set HTTPS verification off" 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_write "/etc/dnf/dnf.conf.d/https.conf" "\ sslverify=False +" + ;; + "${CD_OS_DEBIAN}") + cd_write "/etc/apt/apt.conf.d/https" "\ +Acquire::https::Verify-Peer False; " ;; esac @@ -198,16 +198,16 @@ sslverify=False cd_update_packages_catalog () { cd_step "Update packages catalog" case "${CD_OS_ID}" in - "${CD_OS_DEBIAN}") apt-get update || exit ;; "${CD_OS_ALMA}") dnf makecache || exit ;; + "${CD_OS_DEBIAN}") apt-get update || exit ;; esac } cd_install_packages_tools () { cd_step "Install packages tools" case "${CD_OS_ID}" in - "${CD_OS_DEBIAN}") cd_install_package "apt-utils" ;; "${CD_OS_ALMA}") cd_nop ;; + "${CD_OS_DEBIAN}") cd_install_package "apt-utils" ;; esac } @@ -233,8 +233,8 @@ local text cd_update_ca_certificates () { cd_step "Update CA" case "${CD_OS_ID}" in - "${CD_OS_DEBIAN}") update-ca-certificates || exit ;; "${CD_OS_ALMA}") update-ca-trust || exit ;; + "${CD_OS_DEBIAN}") update-ca-certificates || exit ;; esac } @@ -242,8 +242,8 @@ cd_set_https_verification_on () { if [ "${CD_CA}" -o "${CD_OS_ID}" = "${CD_OS_DEBIAN}" ] ; then cd_step "Set HTTPS verification on" 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_DEBIAN}") cd_rm "/etc/apt/apt.conf.d/https" ;; esac fi } @@ -251,8 +251,8 @@ cd_set_https_verification_on () { cd_upgrade_packages () { cd_step "Upgrade packages" case "${CD_OS_ID}" in - "${CD_OS_DEBIAN}") apt-get upgrade --assume-yes || exit ;; "${CD_OS_ALMA}") dnf upgrade --assumeyes || exit ;; + "${CD_OS_DEBIAN}") apt-get upgrade --assume-yes || exit ;; esac } @@ -269,8 +269,8 @@ cd_install_python () { cd_clean_packages_cache () { cd_step "Clean packages cache" case "${CD_OS_ID}" in - "${CD_OS_DEBIAN}") apt-get clean || exit ;; "${CD_OS_ALMA}") dnf clean all || exit ;; + "${CD_OS_DEBIAN}") apt-get clean || exit ;; esac } diff --git a/readme.md b/readme.md index ab6acea..1e6dc72 100644 --- a/readme.md +++ b/readme.md @@ -29,6 +29,8 @@ from various CA, CI, OCI / OS. ## Tasks +* write bats + * handle cloning credentials * show CA certificates as text * write Python bootstrap