From f51e89ee795515a811b1c019da87f42586b8525e Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 29 Apr 2024 12:43:22 +0200 Subject: [PATCH 01/13] sections --- cd.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cd.sh b/cd.sh index ea77f6d..6f19a47 100644 --- a/cd.sh +++ b/cd.sh @@ -1,7 +1,9 @@ #! /usr/bin/env sh +# modules set "cd" "rwx" +# steps cd_main () { cd_set_environment cd_set_dns_resolving \ @@ -24,7 +26,7 @@ cd_main () { cd_execute_python_module "${@}" } -# +# functions cd_set_environment () { cd_step "Set environment" @@ -270,7 +272,7 @@ ${1} "${CD_PYTHON_COMMAND}" -m "${1}" "${CD_STEP}" "${self}" } -# +# tools cd_cat () { if [ -f "${1}" ] ; then @@ -325,6 +327,5 @@ local text="${2}" fi } -# - +# main cd_main "${@}" From 966f40065208ab5e0fb17c4ffa9a319836fb8d10 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 29 Apr 2024 12:45:57 +0200 Subject: [PATCH 02/13] cd_cat --- cd.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cd.sh b/cd.sh index 6f19a47..a24b913 100644 --- a/cd.sh +++ b/cd.sh @@ -276,7 +276,7 @@ ${1} cd_cat () { if [ -f "${1}" ] ; then - echo "⋅$(realpath "${1}")" + echo "╭$(realpath "${1}")" cat "${1}" || exit fi } From 63b862cdd1d61ff0d20b46ed05c7171c6eb172d4 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 29 Apr 2024 12:51:48 +0200 Subject: [PATCH 03/13] cd_step --- cd.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cd.sh b/cd.sh index a24b913..b31afb0 100644 --- a/cd.sh +++ b/cd.sh @@ -309,7 +309,7 @@ cd_rm () { cd_step () { if [ "${1}" ] ; then CD_STEP=$((CD_STEP+1)) - echo "\ + echo -n "\ ╭─╌┄┈ │ ${CD_STEP} ${1} ╰─╌┄┈ From 9ab60f5b5651bc6e736c604430a29759e371d371 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 29 Apr 2024 13:04:36 +0200 Subject: [PATCH 04/13] readme --- readme.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 readme.md diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..95f9c4b --- /dev/null +++ b/readme.md @@ -0,0 +1,14 @@ +# Continuous Deployment + +## Features + +* [ ] detect + * [ ] OS name + * [ ] OS version +* [X] handle CI platforms + * [X] ForgeJo / Gitea / GitHub + * [X] GitLab + +## Tasks + +* use constants for OS names From 4e10aef6a9a70a3d7e686bdd7bb38b8afc442fd4 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 29 Apr 2024 15:10:51 +0200 Subject: [PATCH 05/13] cd_dns --- cd.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cd.sh b/cd.sh index b31afb0..7a780e3 100644 --- a/cd.sh +++ b/cd.sh @@ -1,13 +1,15 @@ #! /usr/bin/env sh +[ "${CD_DNS}" ] || CD_DNS="\ +9.9.9.9 \ +" # modules set "cd" "rwx" # steps cd_main () { cd_set_environment - cd_set_dns_resolving \ - "9.9.9.9" + cd_set_dns_resolving ${CD_DNS} cd_set_packages_repositories cd_set_packages_configuration cd_set_https_verification_off From bf32e90fe5ac63474ae36471056d68b8cdda78a4 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 29 Apr 2024 15:14:49 +0200 Subject: [PATCH 06/13] cd_python_modules --- cd.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/cd.sh b/cd.sh index 7a780e3..b5ddf8d 100644 --- a/cd.sh +++ b/cd.sh @@ -3,8 +3,10 @@ [ "${CD_DNS}" ] || CD_DNS="\ 9.9.9.9 \ " -# modules -set "cd" "rwx" +CD_PYTHON_MODULES="\ +cd \ +rwx \ +" # steps cd_main () { @@ -24,8 +26,8 @@ cd_main () { cd_install_git cd_install_python cd_clean_packages_cache - cd_install_python_modules "${@}" - cd_execute_python_module "${@}" + cd_install_python_modules ${CD_PYTHON_MODULES} + cd_execute_python_module ${CD_PYTHON_MODULES} } # functions @@ -330,4 +332,4 @@ local text="${2}" } # main -cd_main "${@}" +cd_main From 5f661ba6dba3b680da537fbd53486dbc8d56ebd9 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 29 Apr 2024 16:21:31 +0200 Subject: [PATCH 07/13] makecache --- cd.sh | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/cd.sh b/cd.sh index b5ddf8d..3846d43 100644 --- a/cd.sh +++ b/cd.sh @@ -41,12 +41,11 @@ cd_set_environment () { CD_PYTHON_COMMAND="python3" CD_PYTHON_PACKAGES="/usr/lib/python3/dist-packages" case "${CD_OS_VERSION}" in - "bookworm") - echo "TODO" - ;; + "bookworm") echo "TODO" ;; *) cd_error_os "CD_OS_VERSION=" ;; esac ;; + "alma") echo "TODO" ;; *) cd_error_os "CD_OS_NAME=" ;; esac # ci / github @@ -117,6 +116,7 @@ deb https://deb.debian.org/debian-security bookworm-security main " cd_cat "/etc/apt/sources.list" ;; + "alma") echo "TODO" ;; *) cd_error_os "cd_set_packages_repositories" ;; esac } @@ -135,6 +135,7 @@ Dir::Etc::SourceParts \"\"; " cd_cat "/etc/apt/apt.conf.d/apt.conf" ;; + "alma") echo "TODO" ;; *) cd_error_os "cd_set_packages_configuration" ;; esac } @@ -148,6 +149,7 @@ Acquire::https::Verify-Peer False; " cd_cat "/etc/apt/apt.conf.d/https" ;; + "alma") echo "TODO" ;; *) cd_error_os "cd_set_https_verification_off" ;; esac } @@ -156,6 +158,7 @@ cd_update_packages_catalog () { cd_step "Update packages catalog" case "${CD_OS_NAME}" in "debian") apt-get update || exit ;; + "alma") dnf makecache || exit ;; *) cd_error_os "cd_update_packages_catalog" ;; esac } @@ -164,6 +167,7 @@ cd_install_packages_tools () { cd_step "Install packages tools" case "${CD_OS_NAME}" in "debian") cd_install_package "apt-utils" ;; + "alma") echo "TODO" ;; *) cd_error_os "cd_install_packages_tools" ;; esac } @@ -172,6 +176,7 @@ cd_install_ca () { cd_step "Install CA" case "${CD_OS_NAME}" in "debian") cd_install_package "ca-certificates" ;; + "alma") echo "TODO" ;; *) cd_error_os "cd_install_ca" ;; esac } @@ -181,6 +186,7 @@ local target cd_step "Copy CA" case "${CD_OS_NAME}" in "debian") target="/usr/local/share/ca-certificates" ;; + "alma") echo "TODO" ;; *) cd_error_os "cd_copy_ca" ;; esac # TODO copy @@ -190,6 +196,7 @@ cd_update_ca () { cd_step "Update CA" case "${CD_OS_NAME}" in "debian") update-ca-certificates || exit ;; + "alma") echo "TODO" ;; *) cd_error_os "cd_update_ca" ;; esac } @@ -198,6 +205,7 @@ cd_set_https_verification_on () { cd_step "Set HTTPS verification on" case "${CD_OS_NAME}" in "debian") cd_rm "/etc/apt/apt.conf.d/https" ;; + "alma") echo "TODO" ;; *) cd_error_os "cd_set_https_verification_on" ;; esac } @@ -206,6 +214,7 @@ cd_upgrade_packages () { cd_step "Upgrade packages" case "${CD_OS_NAME}" in "debian") apt-get upgrade --yes || exit ;; + "alma") echo "TODO" ;; *) cd_error_os "cd_upgrade_packages" ;; esac } @@ -214,6 +223,7 @@ cd_install_git () { cd_step "Install Git" case "${CD_OS_NAME}" in "debian") cd_install_package "git" ;; + "alma") echo "TODO" ;; *) cd_error_os "cd_install_git" ;; esac } @@ -222,6 +232,7 @@ cd_install_python () { cd_step "Install Python" case "${CD_OS_NAME}" in "debian") cd_install_package "python3" ;; + "alma") echo "TODO" ;; *) cd_error_os "cd_install_python" ;; esac } @@ -230,6 +241,7 @@ cd_clean_packages_cache () { cd_step "Clean packages cache" case "${CD_OS_NAME}" in "debian") apt-get clean || exit ;; + "alma") echo "TODO" ;; *) cd_error_os "cd_clean_packages_cache" ;; esac } From 4d9a7671f93f952602aca9615098fdadcf39e841 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 29 Apr 2024 16:41:12 +0200 Subject: [PATCH 08/13] upgrade --- cd.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cd.sh b/cd.sh index 3846d43..9b78b05 100644 --- a/cd.sh +++ b/cd.sh @@ -213,8 +213,8 @@ cd_set_https_verification_on () { cd_upgrade_packages () { cd_step "Upgrade packages" case "${CD_OS_NAME}" in - "debian") apt-get upgrade --yes || exit ;; - "alma") echo "TODO" ;; + "debian") apt-get upgrade --assume-yes || exit ;; + "alma") dnf upgrade --assumeyes || exit ;; *) cd_error_os "cd_upgrade_packages" ;; esac } @@ -309,7 +309,7 @@ cd_error_os () { cd_install_package () { if [ "${1}" ] ; then case "${CD_OS_NAME}" in - "debian") apt-get install --yes "${1}" || exit ;; + "debian") apt-get install --assume-yes "${1}" || exit ;; *) exit 1 ;; esac fi From ca19c5dc1bc4965507977b549036bc3fd3d80f0c Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 29 Apr 2024 17:23:10 +0200 Subject: [PATCH 09/13] install,python --- cd.sh | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/cd.sh b/cd.sh index 9b78b05..4488d70 100644 --- a/cd.sh +++ b/cd.sh @@ -39,13 +39,19 @@ cd_set_environment () { case "${CD_OS_NAME}" in "debian") CD_PYTHON_COMMAND="python3" + CD_PYTHON_PACKAGE="python3" CD_PYTHON_PACKAGES="/usr/lib/python3/dist-packages" case "${CD_OS_VERSION}" in "bookworm") echo "TODO" ;; *) cd_error_os "CD_OS_VERSION=" ;; esac ;; - "alma") echo "TODO" ;; + "alma") + case "${CD_OS_VERSION}" in + "8") CD_PYTHON_PACKAGE="python3.11" ;; + *) cd_error_os "CD_OS_VERSION=" ;; + esac + ;; *) cd_error_os "CD_OS_NAME=" ;; esac # ci / github @@ -221,27 +227,19 @@ cd_upgrade_packages () { cd_install_git () { cd_step "Install Git" - case "${CD_OS_NAME}" in - "debian") cd_install_package "git" ;; - "alma") echo "TODO" ;; - *) cd_error_os "cd_install_git" ;; - esac + cd_install_package "git" } cd_install_python () { cd_step "Install Python" - case "${CD_OS_NAME}" in - "debian") cd_install_package "python3" ;; - "alma") echo "TODO" ;; - *) cd_error_os "cd_install_python" ;; - esac + cd_install_package "${CD_PYTHON_PACKAGE}" ;; } cd_clean_packages_cache () { cd_step "Clean packages cache" case "${CD_OS_NAME}" in "debian") apt-get clean || exit ;; - "alma") echo "TODO" ;; + "alma") dnf clean all || exit ;; *) cd_error_os "cd_clean_packages_cache" ;; esac } @@ -310,6 +308,7 @@ cd_install_package () { if [ "${1}" ] ; then case "${CD_OS_NAME}" in "debian") apt-get install --assume-yes "${1}" || exit ;; + "alma") dnf install --assumeyes "${1}" || exit ;; *) exit 1 ;; esac fi From 17ce94a63fb4d000f3e127dbd3d47ccb25c8fa1b Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 29 Apr 2024 17:25:30 +0200 Subject: [PATCH 10/13] git --- cd.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cd.sh b/cd.sh index 4488d70..262dbe9 100644 --- a/cd.sh +++ b/cd.sh @@ -35,6 +35,7 @@ cd_main () { cd_set_environment () { cd_step "Set environment" CD_DNS_FILE="/etc/resolv.conf" + CD_GIT_PACKAGE="git" # case "${CD_OS_NAME}" in "debian") @@ -227,7 +228,7 @@ cd_upgrade_packages () { cd_install_git () { cd_step "Install Git" - cd_install_package "git" + cd_install_package "${CD_GIT_PACKAGE}" } cd_install_python () { From 461230fe16fa76dbfba62fb17e453021e5710a23 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 29 Apr 2024 17:37:15 +0200 Subject: [PATCH 11/13] python/command,packages --- cd.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/cd.sh b/cd.sh index 262dbe9..48d8b37 100644 --- a/cd.sh +++ b/cd.sh @@ -34,26 +34,30 @@ cd_main () { cd_set_environment () { cd_step "Set environment" + # CD_DNS_FILE="/etc/resolv.conf" CD_GIT_PACKAGE="git" + CD_PYTHON_COMMAND="python3" # case "${CD_OS_NAME}" in "debian") - CD_PYTHON_COMMAND="python3" CD_PYTHON_PACKAGE="python3" CD_PYTHON_PACKAGES="/usr/lib/python3/dist-packages" case "${CD_OS_VERSION}" in "bookworm") echo "TODO" ;; - *) cd_error_os "CD_OS_VERSION=" ;; + *) cd_error_os "CD_OS_VERSION" ;; esac ;; "alma") case "${CD_OS_VERSION}" in - "8") CD_PYTHON_PACKAGE="python3.11" ;; - *) cd_error_os "CD_OS_VERSION=" ;; + "8") + CD_PYTHON_PACKAGE="python3.11" + CD_PYTHON_PACKAGES="/usr/lib64/python3.11/site-packages" + ;; + *) cd_error_os "CD_OS_VERSION" ;; esac ;; - *) cd_error_os "CD_OS_NAME=" ;; + *) cd_error_os "CD_OS_NAME" ;; esac # ci / github if [ "${GITHUB_ACTIONS}" ] ; then From 2de5d957473d8e71b76ee49f6e7387737419d7a8 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 29 Apr 2024 17:44:57 +0200 Subject: [PATCH 12/13] update-ca-trust --- cd.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cd.sh b/cd.sh index 48d8b37..d1ac177 100644 --- a/cd.sh +++ b/cd.sh @@ -207,7 +207,7 @@ cd_update_ca () { cd_step "Update CA" case "${CD_OS_NAME}" in "debian") update-ca-certificates || exit ;; - "alma") echo "TODO" ;; + "alma") update-ca-trust || exit ;; *) cd_error_os "cd_update_ca" ;; esac } From 4bff4f687c3430379ee7af6fa16dbea18e391316 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Mon, 29 Apr 2024 17:47:34 +0200 Subject: [PATCH 13/13] ca/anchors --- cd.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cd.sh b/cd.sh index d1ac177..9039eb9 100644 --- a/cd.sh +++ b/cd.sh @@ -197,7 +197,7 @@ local target cd_step "Copy CA" case "${CD_OS_NAME}" in "debian") target="/usr/local/share/ca-certificates" ;; - "alma") echo "TODO" ;; + "alma") target="/etc/pki/ca-trust/source/anchors" ;; *) cd_error_os "cd_copy_ca" ;; esac # TODO copy