quotes
Some checks failed
/ job (push) Failing after 7s

This commit is contained in:
Marc Beninca 2024-04-27 23:36:26 +02:00
parent fd6998a68f
commit 323b8f6ba3
Signed by: marc.beninca
GPG key ID: 9C7613450C80C24F

92
cd.sh
View file

@ -1,11 +1,11 @@
#! /usr/bin/env sh
set 'cd' 'rwx'
set "cd" "rwx"
cd_main () {
cd_set_environment
cd_set_dns_resolving \
'9.9.9.9'
"9.9.9.9"
cd_set_packages_repositories
cd_set_packages_configuration
cd_set_https_verification_off
@ -25,24 +25,24 @@ cd_main () {
#
cd_set_environment () {
cd_step 'Set environment'
CD_DNS_FILE='/etc/resolv.conf'
cd_step "Set environment"
CD_DNS_FILE="/etc/resolv.conf"
case "${CD_OS_NAME}" in
'debian')
CD_PYTHON_COMMAND='python3'
CD_PYTHON_PACKAGES='/usr/lib/python3/dist-packages'
"debian")
CD_PYTHON_COMMAND="python3"
CD_PYTHON_PACKAGES="/usr/lib/python3/dist-packages"
case "${CD_OS_VERSION}" in
'bookworm')
echo 'TODO'
"bookworm")
echo "TODO"
;;
*)
echo 'CD_OS_VERSION'
echo "CD_OS_VERSION"
exit 2
;;
esac
;;
*)
echo 'CD_OS_NAME'
echo "CD_OS_NAME"
exit 1
;;
esac
@ -50,7 +50,7 @@ cd_set_environment () {
[ "${CI_COMMIT_BRANCH}" ] && CD_PROJECT_BRANCH="${CI_COMMIT_BRANCH}"
[ "${GITHUB_REF_NAME}" ] && CD_PROJECT_BRANCH="${GITHUB_REF_NAME}"
if [ ! "${CD_PROJECT_BRANCH}" ] ; then
echo 'CD_PROJECT_BRANCH'
echo "CD_PROJECT_BRANCH"
exit 3
fi
# project / name
@ -59,7 +59,7 @@ cd_set_environment () {
[ "${GITHUB_REPOSITORY}" ] \
&& CD_PROJECT_NAME="$(basename "${GITHUB_REPOSITORY}")"
if [ ! "${CD_PROJECT_NAME}" ] ; then
echo 'CD_PROJECT_NAME'
echo "CD_PROJECT_NAME"
exit 3
fi
# projects / group
@ -68,7 +68,7 @@ cd_set_environment () {
[ "${GITHUB_REPOSITORY}" ] \
&& CD_PROJECTS_GROUP="$(dirname "${GITHUB_REPOSITORY}")"
if [ ! "${CD_PROJECTS_GROUP}" ] ; then
echo 'CD_PROJECTS_GROUP'
echo "CD_PROJECTS_GROUP"
exit 3
fi
# projects / url
@ -77,7 +77,7 @@ cd_set_environment () {
if [ "${CD_PROJECTS_URL}" ] ; then
CD_PROJECTS_URL="${CD_PROJECTS_URL}/${CD_PROJECTS_GROUP}"
else
echo 'CD_PROJECTS_URL'
echo "CD_PROJECTS_URL"
exit 3
fi
# project / url
@ -86,8 +86,8 @@ cd_set_environment () {
cd_set_dns_resolving () {
local server
local text=''
cd_step 'Set DNS resolving'
local text=""
cd_step "Set DNS resolving"
for server in "${@}" ; do
text="${text}nameserver ${server}
"
@ -96,10 +96,10 @@ local text=''
}
cd_set_packages_repositories () {
cd_step 'Set packages repositories'
cd_step "Set packages repositories"
case "${CD_OS_NAME}" in
'debian')
cd_write '/etc/apt/sources.list' "\
"debian")
cd_write "/etc/apt/sources.list" "\
deb https://deb.debian.org/debian bookworm main
deb https://deb.debian.org/debian bookworm-backports main
deb https://deb.debian.org/debian bookworm-updates main
@ -111,11 +111,11 @@ deb https://deb.debian.org/debian-security bookworm-security main
}
cd_set_packages_configuration () {
cd_step 'Set packages configuration'
cd_step "Set packages configuration"
case "${CD_OS_NAME}" in
'debian')
export DEBIAN_FRONTEND='noninteractive'
cd_write '/etc/apt/apt.conf.d/apt.conf' "\
"debian")
export DEBIAN_FRONTEND="noninteractive"
cd_write "/etc/apt/apt.conf.d/apt.conf" "\
Acquire::Check-Valid-Until True;
APT::Get::Show-Versions True;
APT::Install-Recommends False;
@ -128,10 +128,10 @@ Dir::Etc::SourceParts \"\";
}
cd_set_https_verification_off () {
cd_step 'Set HTTPS verification off'
cd_step "Set HTTPS verification off"
case "${CD_OS_NAME}" in
'debian')
cd_write '/etc/apt/apt.conf.d/https' "\
"debian")
cd_write "/etc/apt/apt.conf.d/https" "\
Acquire::https::Verify-Peer False;
"
;;
@ -140,65 +140,65 @@ Acquire::https::Verify-Peer False;
}
cd_update_packages_catalog () {
cd_step 'Update packages catalog'
cd_step "Update packages catalog"
case "${CD_OS_NAME}" in
'debian') apt-get update || exit ;;
"debian") apt-get update || exit ;;
*) exit 1 ;;
esac
}
cd_install_packages_tools () {
cd_step 'Install packages tools'
cd_step "Install packages tools"
case "${CD_OS_NAME}" in
'debian') cd_install_package 'apt-utils' ;;
"debian") cd_install_package "apt-utils" ;;
*) exit 1 ;;
esac
}
cd_install_ca () {
cd_step 'Install CA'
cd_step "Install CA"
case "${CD_OS_NAME}" in
'debian') cd_install_package 'ca-certificates' ;;
"debian") cd_install_package "ca-certificates" ;;
*) exit 1 ;;
esac
}
cd_set_https_verification_on () {
cd_step 'Set HTTPS verification on'
cd_step "Set HTTPS verification on"
case "${CD_OS_NAME}" in
'debian') rm '/etc/apt/apt.conf.d/https' ;;
"debian") rm "/etc/apt/apt.conf.d/https" ;;
*) exit 1 ;;
esac
}
cd_upgrade_packages () {
cd_step 'Upgrade packages'
cd_step "Upgrade packages"
case "${CD_OS_NAME}" in
'debian') apt-get upgrade --yes || exit ;;
"debian") apt-get upgrade --yes || exit ;;
*) exit 1 ;;
esac
}
cd_install_git () {
cd_step 'Install Git'
cd_step "Install Git"
case "${CD_OS_NAME}" in
'debian') cd_install_package 'git' ;;
"debian") cd_install_package "git" ;;
*) exit 1 ;;
esac
}
cd_install_python () {
cd_step 'Install Python'
cd_step "Install Python"
case "${CD_OS_NAME}" in
'debian') cd_install_package 'python3' ;;
"debian") cd_install_package "python3" ;;
*) exit 1 ;;
esac
}
cd_clean_packages_cache () {
cd_step 'Clean packages cache'
cd_step "Clean packages cache"
case "${CD_OS_NAME}" in
'debian') apt-get clean || exit ;;
"debian") apt-get clean || exit ;;
*) exit 1 ;;
esac
}
@ -206,7 +206,7 @@ cd_clean_packages_cache () {
cd_install () {
local repository
local root
cd_step 'Install'
cd_step "Install"
root="$(mktemp --directory)" || exit
for repository in "${@}" ; do
git clone \
@ -220,7 +220,7 @@ local root
}
cd_bootstrap () {
cd_step 'Bootstrap'
cd_step "Bootstrap"
"${CD_PYTHON_COMMAND}" -m "${1}"
}
@ -229,7 +229,7 @@ cd_bootstrap () {
cd_install_package () {
if [ "${1}" ] ; then
case "${CD_OS_NAME}" in
'debian') apt-get install --yes "${1}" || exit ;;
"debian") apt-get install --yes "${1}" || exit ;;
*) exit 1 ;;
esac
fi