Compare commits

..

No commits in common. "4bff4f687c3430379ee7af6fa16dbea18e391316" and "4dbf04fb108bc42eda04d662ec75a3d3d81bf9ae" have entirely different histories.

2 changed files with 27 additions and 62 deletions

75
cd.sh
View file

@ -1,17 +1,11 @@
#! /usr/bin/env sh
[ "${CD_DNS}" ] || CD_DNS="\
9.9.9.9 \
"
CD_PYTHON_MODULES="\
cd \
rwx \
"
set "cd" "rwx"
# steps
cd_main () {
cd_set_environment
cd_set_dns_resolving ${CD_DNS}
cd_set_dns_resolving \
"9.9.9.9"
cd_set_packages_repositories
cd_set_packages_configuration
cd_set_https_verification_off
@ -26,38 +20,28 @@ cd_main () {
cd_install_git
cd_install_python
cd_clean_packages_cache
cd_install_python_modules ${CD_PYTHON_MODULES}
cd_execute_python_module ${CD_PYTHON_MODULES}
cd_install_python_modules "${@}"
cd_execute_python_module "${@}"
}
# 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_PACKAGE="python3"
CD_PYTHON_COMMAND="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")
case "${CD_OS_VERSION}" in
"8")
CD_PYTHON_PACKAGE="python3.11"
CD_PYTHON_PACKAGES="/usr/lib64/python3.11/site-packages"
"bookworm")
echo "TODO"
;;
*) cd_error_os "CD_OS_VERSION" ;;
*) 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
@ -127,7 +111,6 @@ 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
}
@ -146,7 +129,6 @@ Dir::Etc::SourceParts \"\";
"
cd_cat "/etc/apt/apt.conf.d/apt.conf"
;;
"alma") echo "TODO" ;;
*) cd_error_os "cd_set_packages_configuration" ;;
esac
}
@ -160,7 +142,6 @@ 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
}
@ -169,7 +150,6 @@ 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
}
@ -178,7 +158,6 @@ 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
}
@ -187,7 +166,6 @@ 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
}
@ -197,7 +175,6 @@ 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
@ -207,7 +184,6 @@ 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
}
@ -216,7 +192,6 @@ 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
}
@ -224,27 +199,31 @@ cd_set_https_verification_on () {
cd_upgrade_packages () {
cd_step "Upgrade packages"
case "${CD_OS_NAME}" in
"debian") apt-get upgrade --assume-yes || exit ;;
"alma") dnf upgrade --assumeyes || exit ;;
"debian") apt-get upgrade --yes || exit ;;
*) cd_error_os "cd_upgrade_packages" ;;
esac
}
cd_install_git () {
cd_step "Install Git"
cd_install_package "${CD_GIT_PACKAGE}"
case "${CD_OS_NAME}" in
"debian") cd_install_package "git" ;;
*) cd_error_os "cd_install_git" ;;
esac
}
cd_install_python () {
cd_step "Install Python"
cd_install_package "${CD_PYTHON_PACKAGE}" ;;
case "${CD_OS_NAME}" in
"debian") cd_install_package "python3" ;;
*) cd_error_os "cd_install_python" ;;
esac
}
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
}
@ -291,11 +270,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
}
@ -312,8 +291,7 @@ cd_error_os () {
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 ;;
"debian") apt-get install --yes "${1}" || exit ;;
*) exit 1 ;;
esac
fi
@ -329,7 +307,7 @@ cd_rm () {
cd_step () {
if [ "${1}" ] ; then
CD_STEP=$((CD_STEP+1))
echo -n "\
echo "\
╭─╌┄┈
${CD_STEP} ${1}
╰─╌┄┈
@ -347,5 +325,6 @@ local text="${2}"
fi
}
# main
cd_main
#
cd_main "${@}"

View file

@ -1,14 +0,0 @@
# Continuous Deployment
## Features
* [ ] detect
* [ ] OS name
* [ ] OS version
* [X] handle CI platforms
* [X] ForgeJo / Gitea / GitHub
* [X] GitLab
## Tasks
* use constants for OS names