Compare commits
21 commits
f67a9478bb
...
70eaf4bba3
Author | SHA1 | Date | |
---|---|---|---|
70eaf4bba3 | |||
a014410c7f | |||
ba4b428ede | |||
d7d6f37648 | |||
21b91211ec | |||
35123c72c1 | |||
31a0b4d257 | |||
6fd8e23029 | |||
5633916895 | |||
5dd39bc1cb | |||
4be8512ffc | |||
5604fb2be7 | |||
f1f5004e2a | |||
e87d66c3a9 | |||
517b5b0f68 | |||
b2e3a5db4c | |||
3784d4d6a6 | |||
89998d8a65 | |||
37668ac488 | |||
f7ae3796d9 | |||
d587944e95 |
1 changed files with 139 additions and 65 deletions
204
spcd/main.sh
204
spcd/main.sh
|
@ -1,22 +1,42 @@
|
||||||
#! /usr/bin/env sh
|
#! /usr/bin/env sh
|
||||||
|
|
||||||
# defaults
|
# defaults
|
||||||
[ -n "${SPCD_BRANCH_RELEASE}" ] || SPCD_BRANCH_RELEASE="main"
|
|
||||||
[ -n "${SPCD_BRANCH_STAGING}" ] || SPCD_BRANCH_STAGING="dev"
|
|
||||||
[ -n "${SPCD_BRANCH_FEATURE}" ] || SPCD_BRANCH_FEATURE="f"
|
|
||||||
[ -n "${SPCD_CMD_SUM}" ] || SPCD_CMD_SUM="sha512sum"
|
[ -n "${SPCD_CMD_SUM}" ] || SPCD_CMD_SUM="sha512sum"
|
||||||
[ -n "${SPCD_DNS_1}" ] || SPCD_DNS_1="9.9.9.9"
|
[ -n "${SPCD_DNS_1}" ] || SPCD_DNS_1="9.9.9.9"
|
||||||
[ -n "${SPCD_GIT_MAIN}" ] || SPCD_GIT_MAIN="spcd"
|
[ -n "${SPCD_GIT_MAIN}" ] || SPCD_GIT_MAIN="spcd"
|
||||||
[ -n "${SPCD_GIT_ROOT}" ] || SPCD_GIT_ROOT="rwx"
|
[ -n "${SPCD_GIT_ROOT}" ] || SPCD_GIT_ROOT="rwx"
|
||||||
[ -n "${SPCD_GIT_SHUNIT}" ] || SPCD_GIT_SHUNIT="shunit2"
|
[ -n "${SPCD_GIT_SHUNIT}" ] || SPCD_GIT_SHUNIT="shunit2"
|
||||||
[ -n "${SPCD_URL_PYTHON}" ] || SPCD_URL_PYTHON="https://pypi.org/simple"
|
[ -n "${SPCD_REF_FEATURE}" ] || SPCD_REF_FEATURE="f"
|
||||||
|
[ -n "${SPCD_REF_RELEASE}" ] || SPCD_REF_RELEASE="main"
|
||||||
|
[ -n "${SPCD_REF_STAGING}" ] || SPCD_REF_STAGING="dev"
|
||||||
|
[ -n "${SPCD_URL_ALPINE}" ] ||
|
||||||
|
SPCD_URL_ALPINE="https://dl-cdn.alpinelinux.org"
|
||||||
|
[ -n "${SPCD_URL_ARCH}" ] ||
|
||||||
|
SPCD_URL_ARCH="https://geo.mirror.pkgbuild.com"
|
||||||
|
[ -n "${SPCD_URL_DEBIAN}" ] ||
|
||||||
|
SPCD_URL_DEBIAN="https://deb.debian.org"
|
||||||
|
[ -n "${SPCD_URL_EPEL}" ] ||
|
||||||
|
SPCD_URL_EPEL="https://dl.fedoraproject.org"
|
||||||
|
[ -n "${SPCD_URL_FEDORA}" ] ||
|
||||||
|
SPCD_URL_FEDORA="https://rpmfind.net"
|
||||||
|
[ -n "${SPCD_URL_OPENSUSE}" ] ||
|
||||||
|
SPCD_URL_OPENSUSE="https://download.opensuse.org"
|
||||||
|
[ -n "${SPCD_URL_PYTHON}" ] ||
|
||||||
|
SPCD_URL_PYTHON="https://pypi.org/simple"
|
||||||
|
[ -n "${SPCD_URL_ROCKY}" ] ||
|
||||||
|
SPCD_URL_ROCKY="https://dl.rockylinux.org"
|
||||||
|
[ -n "${SPCD_URL_UBUNTU}" ] ||
|
||||||
|
SPCD_URL_UBUNTU="https://ubuntu.mirrors.ovh.net"
|
||||||
|
|
||||||
|
# ╭───────╮
|
||||||
|
# │ steps │
|
||||||
|
# ╰───────╯
|
||||||
|
|
||||||
# main
|
|
||||||
spcd_main() {
|
spcd_main() {
|
||||||
|
# env
|
||||||
spcd_set_environment_variables
|
spcd_set_environment_variables
|
||||||
#
|
|
||||||
spcd_list_working_directory
|
spcd_list_working_directory
|
||||||
#
|
# pkg
|
||||||
spcd_set_packages_repositories
|
spcd_set_packages_repositories
|
||||||
spcd_set_packages_configuration
|
spcd_set_packages_configuration
|
||||||
#
|
#
|
||||||
|
@ -24,14 +44,17 @@ spcd_main() {
|
||||||
spcd_set_dns_resolving
|
spcd_set_dns_resolving
|
||||||
spcd_update_packages_catalog
|
spcd_update_packages_catalog
|
||||||
spcd_install_packages_tools
|
spcd_install_packages_tools
|
||||||
|
# ca
|
||||||
spcd_install_ca_certificates
|
spcd_install_ca_certificates
|
||||||
spcd_write_ca_certificates
|
spcd_write_ca_certificates
|
||||||
spcd_update_ca_certificates
|
spcd_update_ca_certificates
|
||||||
|
# pkg
|
||||||
spcd_set_https_verification_on
|
spcd_set_https_verification_on
|
||||||
spcd_update_packages_catalog
|
spcd_update_packages_catalog
|
||||||
spcd_upgrade_packages
|
spcd_upgrade_packages
|
||||||
spcd_install_dos2unix
|
spcd_install_dos2unix
|
||||||
spcd_install_git
|
spcd_install_git
|
||||||
|
# python
|
||||||
spcd_install_python
|
spcd_install_python
|
||||||
spcd_install_python_modules
|
spcd_install_python_modules
|
||||||
spcd_install_packages
|
spcd_install_packages
|
||||||
|
@ -39,7 +62,9 @@ spcd_main() {
|
||||||
spcd_switch_to_python
|
spcd_switch_to_python
|
||||||
}
|
}
|
||||||
|
|
||||||
# steps
|
# ╭───────┬─────╮
|
||||||
|
# │ steps │ env │
|
||||||
|
# ╰───────┴─────╯
|
||||||
|
|
||||||
spcd_set_environment_variables() {
|
spcd_set_environment_variables() {
|
||||||
spcd_step "Set environment variables"
|
spcd_step "Set environment variables"
|
||||||
|
@ -121,9 +146,9 @@ ${SPCD_PROJECT_ROOT}$(basename "${GITHUB_SERVER_URL}")"
|
||||||
fi
|
fi
|
||||||
# check project variables
|
# check project variables
|
||||||
case "${SPCD_PROJECT_BRANCH}" in
|
case "${SPCD_PROJECT_BRANCH}" in
|
||||||
"${SPCD_BRANCH_RELEASE}" | \
|
"${SPCD_REF_RELEASE}" | \
|
||||||
"${SPCD_BRANCH_STAGING}" | \
|
"${SPCD_REF_STAGING}" | \
|
||||||
"${SPCD_BRANCH_FEATURE}") ;;
|
"${SPCD_REF_FEATURE}") ;;
|
||||||
*) spcd_error_ci "SPCD_PROJECT_BRANCH" ;;
|
*) spcd_error_ci "SPCD_PROJECT_BRANCH" ;;
|
||||||
esac
|
esac
|
||||||
[ -n "${SPCD_PROJECT_ROOT}" ] || spcd_error_ci "SPCD_PROJECT_ROOT"
|
[ -n "${SPCD_PROJECT_ROOT}" ] || spcd_error_ci "SPCD_PROJECT_ROOT"
|
||||||
|
@ -528,6 +553,10 @@ spcd_list_working_directory() {
|
||||||
spcd_ls "${spcd_lwd__path}"
|
spcd_ls "${spcd_lwd__path}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# ╭───────┬─────╮
|
||||||
|
# │ steps │ pkg │
|
||||||
|
# ╰───────┴─────╯
|
||||||
|
|
||||||
spcd_set_packages_repositories() {
|
spcd_set_packages_repositories() {
|
||||||
spcd_step "Set packages repositories"
|
spcd_step "Set packages repositories"
|
||||||
case "${SPCD_OS_ID}" in
|
case "${SPCD_OS_ID}" in
|
||||||
|
@ -642,6 +671,10 @@ spcd_install_packages_tools() {
|
||||||
spcd_install_package "${SPCD_PKG_PKG}"
|
spcd_install_package "${SPCD_PKG_PKG}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# ╭───────┬────╮
|
||||||
|
# │ steps │ ca │
|
||||||
|
# ╰───────┴────╯
|
||||||
|
|
||||||
spcd_install_ca_certificates() {
|
spcd_install_ca_certificates() {
|
||||||
spcd_step "Install CA"
|
spcd_step "Install CA"
|
||||||
spcd_install_package "${SPCD_PKG_CA}"
|
spcd_install_package "${SPCD_PKG_CA}"
|
||||||
|
@ -666,6 +699,10 @@ spcd_update_ca_certificates() {
|
||||||
${SPCD_CMD_CA} || exit
|
${SPCD_CMD_CA} || exit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# ╭───────┬─────╮
|
||||||
|
# │ steps │ pkg │
|
||||||
|
# ╰───────┴─────╯
|
||||||
|
|
||||||
spcd_set_https_verification_on() {
|
spcd_set_https_verification_on() {
|
||||||
spcd_step "Set HTTPS verification on"
|
spcd_step "Set HTTPS verification on"
|
||||||
spcd_rm "${SPCD_PM_HTTPS_PATH}"
|
spcd_rm "${SPCD_PM_HTTPS_PATH}"
|
||||||
|
@ -686,6 +723,10 @@ spcd_install_git() {
|
||||||
spcd_install_package "${SPCD_PKG_GIT}"
|
spcd_install_package "${SPCD_PKG_GIT}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# ╭───────┬────────╮
|
||||||
|
# │ steps │ python │
|
||||||
|
# ╰───────┴────────╯
|
||||||
|
|
||||||
spcd_install_python() {
|
spcd_install_python() {
|
||||||
spcd_step "Install Python"
|
spcd_step "Install Python"
|
||||||
spcd_install_package "${SPCD_PYTHON_PACKAGE}"
|
spcd_install_package "${SPCD_PYTHON_PACKAGE}"
|
||||||
|
@ -825,49 +866,9 @@ ${SPCD_PYTHON_ALIAS} / ${spcd_stp__name}"
|
||||||
"${SPCD_PYTHON_ALIAS}" -m "${spcd_stp__name}"
|
"${SPCD_PYTHON_ALIAS}" -m "${spcd_stp__name}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# functions
|
# ╭───────────╮
|
||||||
|
# │ functions │
|
||||||
spcd_banner() {
|
# ╰───────────╯
|
||||||
unset SPCD_BANNER_1 SPCD_BANNER_2 SPCD_BANNER_3
|
|
||||||
spcd_banner_add_123 "${SPCD_BOX_DOWN}" "${SPCD_VERT}" "${SPCD_BOX_UP}"
|
|
||||||
#
|
|
||||||
spcd_banner__index="${SPCD_STEP}"
|
|
||||||
[ -n "${SPCD_SUBSTEP}" ] &&
|
|
||||||
spcd_banner__index="${spcd_banner__index}.${SPCD_SUBSTEP}"
|
|
||||||
spcd_banner_add "${spcd_banner__index}"
|
|
||||||
#
|
|
||||||
for spcd_banner__item in "${SPCD_STEP_TEXT}" "${SPCD_SUBSTEP_TEXT}"; do
|
|
||||||
if [ -n "${spcd_banner__item}" ]; then
|
|
||||||
spcd_banner_add_123 "┬" "${SPCD_VERT}" "┴"
|
|
||||||
spcd_banner_add "${spcd_banner__item}"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
#
|
|
||||||
spcd_banner_add_123 "╮" "${SPCD_VERT}" "╯"
|
|
||||||
#
|
|
||||||
echo "\
|
|
||||||
${SPCD_BANNER_1}
|
|
||||||
${SPCD_BANNER_2}
|
|
||||||
${SPCD_BANNER_3}"
|
|
||||||
}
|
|
||||||
|
|
||||||
spcd_banner_add() {
|
|
||||||
if [ -n "${1}" ]; then
|
|
||||||
spcd_ba__text=" ${1} "
|
|
||||||
spcd_ba__length=${#spcd_ba__text}
|
|
||||||
spcd_ba__filler="$(spcd_fill "${spcd_ba__length}" ─)"
|
|
||||||
spcd_banner_add_123 \
|
|
||||||
"${spcd_ba__filler}" "${spcd_ba__text}" "${spcd_ba__filler}"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
spcd_banner_add_123() {
|
|
||||||
if [ -n "${3}" ]; then
|
|
||||||
SPCD_BANNER_1="${SPCD_BANNER_1}${1}"
|
|
||||||
SPCD_BANNER_2="${SPCD_BANNER_2}${2}"
|
|
||||||
SPCD_BANNER_3="${SPCD_BANNER_3}${3}"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
spcd_cat() {
|
spcd_cat() {
|
||||||
spcd_cat__file="${1}"
|
spcd_cat__file="${1}"
|
||||||
|
@ -900,14 +901,6 @@ spcd_error_os() {
|
||||||
exit "${SPCD_ERROR_OS}"
|
exit "${SPCD_ERROR_OS}"
|
||||||
}
|
}
|
||||||
|
|
||||||
spcd_fill() {
|
|
||||||
spcd_fill__index=${1}
|
|
||||||
while [ "${spcd_fill__index}" -gt 0 ]; do
|
|
||||||
printf "%s" "${2}"
|
|
||||||
spcd_fill__index=$((spcd_fill__index - 1))
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
spcd_git_clone() {
|
spcd_git_clone() {
|
||||||
if [ -n "${1}" ]; then
|
if [ -n "${1}" ]; then
|
||||||
spcd_gc__name="$(basename "${1}")"
|
spcd_gc__name="$(basename "${1}")"
|
||||||
|
@ -1084,11 +1077,92 @@ SPCD_PYTHON_VENV_BINARIES="${SPCD_PYTHON_VENV}/bin"
|
||||||
SPCD_HORIZONTAL="────╌╌╌╌┄┄┄┄┈┈┈┈"
|
SPCD_HORIZONTAL="────╌╌╌╌┄┄┄┄┈┈┈┈"
|
||||||
|
|
||||||
SPCD_OPEN="${SPCD_BOX_DOWN}${SPCD_BOX_LEFT}"
|
SPCD_OPEN="${SPCD_BOX_DOWN}${SPCD_BOX_LEFT}"
|
||||||
SPCD_DOWN="${SPCD_BOX_DOWN}${SPCD_HORIZONTAL}"
|
|
||||||
SPCD_VERT="${SPCD_BOX_VERTICAL}"
|
SPCD_VERT="${SPCD_BOX_VERTICAL}"
|
||||||
SPCD_SPLT="${SPCD_BOX_RIGHT}${SPCD_HORIZONTAL}"
|
SPCD_SPLT="${SPCD_BOX_RIGHT}${SPCD_HORIZONTAL}"
|
||||||
SPCD___UP="${SPCD_BOX_UP}${SPCD_HORIZONTAL}"
|
|
||||||
SPCD_SHUT="${SPCD_BOX_UP}${SPCD_BOX_LEFT}"
|
SPCD_SHUT="${SPCD_BOX_UP}${SPCD_BOX_LEFT}"
|
||||||
|
|
||||||
# run
|
# ╭──────────╮
|
||||||
|
# │ internal │
|
||||||
|
# ╰──────────╯
|
||||||
|
|
||||||
|
spcd_fill() {
|
||||||
|
spcd_fill__index=${1}
|
||||||
|
while [ "${spcd_fill__index}" -gt 0 ]; do
|
||||||
|
printf "%s" "${2}"
|
||||||
|
spcd_fill__index=$((spcd_fill__index - 1))
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# ╭──────────┬────────╮
|
||||||
|
# │ internal │ banner │
|
||||||
|
# ╰──────────┴────────╯
|
||||||
|
|
||||||
|
spcd_banner() {
|
||||||
|
spcd_banner_unset
|
||||||
|
spcd_banner_open
|
||||||
|
#
|
||||||
|
spcd_banner__index="${SPCD_STEP}"
|
||||||
|
[ -n "${SPCD_SUBSTEP}" ] &&
|
||||||
|
spcd_banner__index="${spcd_banner__index}.${SPCD_SUBSTEP}"
|
||||||
|
spcd_banner_add "${spcd_banner__index}"
|
||||||
|
#
|
||||||
|
spcd_banner_add "S"
|
||||||
|
#
|
||||||
|
for spcd_banner__item in "${SPCD_STEP_TEXT}" "${SPCD_SUBSTEP_TEXT}"; do
|
||||||
|
[ -n "${spcd_banner__item}" ] &&
|
||||||
|
spcd_banner_add "${spcd_banner__item}"
|
||||||
|
done
|
||||||
|
#
|
||||||
|
spcd_banner_close
|
||||||
|
#
|
||||||
|
spcd_banner_echo
|
||||||
|
spcd_banner_unset
|
||||||
|
}
|
||||||
|
|
||||||
|
spcd_banner_add() {
|
||||||
|
if [ -n "${1}" ]; then
|
||||||
|
spcd_ba__text=" ${1} "
|
||||||
|
spcd_ba__length=${#spcd_ba__text}
|
||||||
|
spcd_ba__filler="$(spcd_fill "${spcd_ba__length}" ─)"
|
||||||
|
spcd_banner_split
|
||||||
|
spcd_banner_append \
|
||||||
|
"${spcd_ba__filler}" "${spcd_ba__text}" "${spcd_ba__filler}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
spcd_banner_append() {
|
||||||
|
if [ -n "${3}" ]; then
|
||||||
|
SPCD_BANNER_1="${SPCD_BANNER_1}${1}"
|
||||||
|
SPCD_BANNER_2="${SPCD_BANNER_2}${2}"
|
||||||
|
SPCD_BANNER_3="${SPCD_BANNER_3}${3}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
spcd_banner_close() {
|
||||||
|
spcd_banner_append "╮" "${SPCD_VERT}" "╯"
|
||||||
|
}
|
||||||
|
|
||||||
|
spcd_banner_echo() {
|
||||||
|
echo "\
|
||||||
|
${SPCD_BANNER_1}
|
||||||
|
${SPCD_BANNER_2}
|
||||||
|
${SPCD_BANNER_3}"
|
||||||
|
}
|
||||||
|
|
||||||
|
spcd_banner_open() {
|
||||||
|
spcd_banner_append "${SPCD_BOX_DOWN}" "${SPCD_VERT}" "${SPCD_BOX_UP}"
|
||||||
|
}
|
||||||
|
|
||||||
|
spcd_banner_split() {
|
||||||
|
spcd_banner_append "┬" "${SPCD_VERT}" "┴"
|
||||||
|
}
|
||||||
|
|
||||||
|
spcd_banner_unset() {
|
||||||
|
unset SPCD_BANNER_1 SPCD_BANNER_2 SPCD_BANNER_3
|
||||||
|
}
|
||||||
|
|
||||||
|
# ╭──────────┬─────╮
|
||||||
|
# │ internal │ run │
|
||||||
|
# ╰──────────┴─────╯
|
||||||
|
|
||||||
spcd_main
|
spcd_main
|
||||||
|
|
Loading…
Reference in a new issue