Compare commits

...

13 commits

Author SHA1 Message Date
Marc Beninca 4bff4f687c
ca/anchors
Some checks failed
/ job (push) Failing after 3s
2024-04-29 17:47:34 +02:00
Marc Beninca 2de5d95747
update-ca-trust 2024-04-29 17:44:57 +02:00
Marc Beninca 461230fe16
python/command,packages 2024-04-29 17:37:15 +02:00
Marc Beninca 17ce94a63f
git 2024-04-29 17:25:30 +02:00
Marc Beninca ca19c5dc1b
install,python 2024-04-29 17:23:10 +02:00
Marc Beninca 4d9a7671f9
upgrade 2024-04-29 16:41:12 +02:00
Marc Beninca 5f661ba6db
makecache 2024-04-29 16:21:31 +02:00
Marc Beninca bf32e90fe5
cd_python_modules 2024-04-29 15:14:49 +02:00
Marc Beninca 4e10aef6a9
cd_dns 2024-04-29 15:10:51 +02:00
Marc Beninca 9ab60f5b56
readme 2024-04-29 13:04:36 +02:00
Marc Beninca 63b862cdd1
cd_step 2024-04-29 12:51:48 +02:00
Marc Beninca 966f400652
cd_cat 2024-04-29 12:45:57 +02:00
Marc Beninca f51e89ee79
sections 2024-04-29 12:43:22 +02:00
2 changed files with 63 additions and 28 deletions

77
cd.sh
View file

@ -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

14
readme.md Normal file
View file

@ -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