diff --git a/cd.sh b/cd.sh index ea77f6d..9039eb9 100644 --- a/cd.sh +++ b/cd.sh @@ -1,11 +1,17 @@ #! /usr/bin/env sh -set "cd" "rwx" +[ "${CD_DNS}" ] || CD_DNS="\ +9.9.9.9 \ +" +CD_PYTHON_MODULES="\ +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 @@ -20,28 +26,38 @@ 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 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=" ;; + "bookworm") echo "TODO" ;; + *) cd_error_os "CD_OS_VERSION" ;; esac ;; - *) cd_error_os "CD_OS_NAME=" ;; + "alma") + case "${CD_OS_VERSION}" in + "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" ;; esac # ci / github if [ "${GITHUB_ACTIONS}" ] ; then @@ -111,6 +127,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 } @@ -129,6 +146,7 @@ Dir::Etc::SourceParts \"\"; " cd_cat "/etc/apt/apt.conf.d/apt.conf" ;; + "alma") echo "TODO" ;; *) cd_error_os "cd_set_packages_configuration" ;; esac } @@ -142,6 +160,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 } @@ -150,6 +169,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 } @@ -158,6 +178,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 } @@ -166,6 +187,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 } @@ -175,6 +197,7 @@ local target 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 # TODO copy @@ -184,6 +207,7 @@ cd_update_ca () { cd_step "Update CA" case "${CD_OS_NAME}" in "debian") update-ca-certificates || exit ;; + "alma") update-ca-trust || exit ;; *) cd_error_os "cd_update_ca" ;; esac } @@ -192,6 +216,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 } @@ -199,31 +224,27 @@ cd_set_https_verification_on () { cd_upgrade_packages () { cd_step "Upgrade packages" case "${CD_OS_NAME}" in - "debian") apt-get upgrade --yes || exit ;; + "debian") apt-get upgrade --assume-yes || exit ;; + "alma") dnf upgrade --assumeyes || exit ;; *) cd_error_os "cd_upgrade_packages" ;; esac } cd_install_git () { cd_step "Install Git" - case "${CD_OS_NAME}" in - "debian") cd_install_package "git" ;; - *) cd_error_os "cd_install_git" ;; - esac + cd_install_package "${CD_GIT_PACKAGE}" } cd_install_python () { cd_step "Install Python" - case "${CD_OS_NAME}" in - "debian") cd_install_package "python3" ;; - *) 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") dnf clean all || exit ;; *) cd_error_os "cd_clean_packages_cache" ;; esac } @@ -270,11 +291,11 @@ ${1} "${CD_PYTHON_COMMAND}" -m "${1}" "${CD_STEP}" "${self}" } -# +# tools cd_cat () { if [ -f "${1}" ] ; then - echo "⋅$(realpath "${1}")" + echo "╭$(realpath "${1}")" cat "${1}" || exit fi } @@ -291,7 +312,8 @@ 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 ;; + "alma") dnf install --assumeyes "${1}" || exit ;; *) exit 1 ;; esac fi @@ -307,7 +329,7 @@ cd_rm () { cd_step () { if [ "${1}" ] ; then CD_STEP=$((CD_STEP+1)) - echo "\ + echo -n "\ ╭─╌┄┈ │ ${CD_STEP} ${1} ╰─╌┄┈ @@ -325,6 +347,5 @@ local text="${2}" fi } -# - -cd_main "${@}" +# main +cd_main 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