Compare commits

..

16 commits

Author SHA1 Message Date
f92d49fe82
python
All checks were successful
/ job (push) Successful in 10m55s
2024-08-26 03:00:48 +02:00
8c0ae4174c
dos2unix,git 2024-08-26 01:50:23 +02:00
af90952b5c
upgrade system 2024-08-26 01:48:01 +02:00
906528b15c
verify https 2024-08-26 01:44:43 +02:00
789d67654e
tools 2024-08-26 01:39:55 +02:00
4c6eac7b5f
catalog 2024-08-26 01:36:25 +02:00
a217194d80
trust https 2024-08-26 01:33:33 +02:00
617695589f
packages 2024-08-26 01:22:38 +02:00
10e5685bf5
spcd_dns 2024-08-26 01:10:56 +02:00
d546eb8377
−rule 2024-08-26 01:02:41 +02:00
de4c334582
environment 2024-08-26 00:30:20 +02:00
a88c031ec3
steps/functions 2024-08-26 00:22:17 +02:00
03cde379b7
bootstrap.sh 2024-08-26 00:10:46 +02:00
82ac82da2f
−exit 2024-08-25 23:55:52 +02:00
530681b688
mv 2024-08-25 23:37:06 +02:00
636f53713b
spcd_openssl_x509 2024-08-25 23:35:16 +02:00

View file

@ -1,7 +1,5 @@
#! /usr/bin/env sh #! /usr/bin/env sh
#╶──────────────────────────────────────╴
# ╭──────────╮ # ╭──────────╮
# │ defaults │ # │ defaults │
# ╰──────────╯ # ╰──────────╯
@ -184,7 +182,7 @@ spcd_os_cat() {
spcd_cat__file="${1}" spcd_cat__file="${1}"
if [ -n "${spcd_cat__file}" ]; then if [ -n "${spcd_cat__file}" ]; then
spcd_frame_open "${spcd_cat__file}" spcd_frame_open "${spcd_cat__file}"
cat "${spcd_cat__file}" || exit cat "${spcd_cat__file}"
spcd_frame_shut "${spcd_cat__file}" spcd_frame_shut "${spcd_cat__file}"
fi fi
} }
@ -251,6 +249,19 @@ spcd_git_url() {
fi fi
} }
# ╭───────────┬─────────╮
# │ functions │ openssl │
# ╰───────────┴─────────╯
spcd_openssl_x509() {
spcd_openssl_x509__file="${1}"
if [ -f "${spcd_openssl_x509__file}" ]; then
openssl x509 \
-in "${spcd_openssl_x509__file}" \
-noout -text
fi
}
# ╭───────────┬────╮ # ╭───────────┬────╮
# │ functions │ os │ # │ functions │ os │
# ╰───────────┴────╯ # ╰───────────┴────╯
@ -294,7 +305,7 @@ spcd_os_rm() {
spcd_os_rm__path="${1}" spcd_os_rm__path="${1}"
if [ -e "${spcd_os_rm__path}" ]; then if [ -e "${spcd_os_rm__path}" ]; then
echo "${spcd_os_rm__path}" echo "${spcd_os_rm__path}"
rm -r "${spcd_os_rm__path}" || exit rm -r "${spcd_os_rm__path}"
fi fi
} }
@ -331,7 +342,7 @@ spcd_python_ln() {
if [ -n "${spcd_python_ln__command}" ]; then if [ -n "${spcd_python_ln__command}" ]; then
echo "${SPCD_PYTHON_ALIAS}${spcd_python_ln__command}" echo "${SPCD_PYTHON_ALIAS}${spcd_python_ln__command}"
ln -f -s "${spcd_python_ln__command}" \ ln -f -s "${spcd_python_ln__command}" \
"/usr/bin/${SPCD_PYTHON_ALIAS}" || exit "/usr/bin/${SPCD_PYTHON_ALIAS}"
fi fi
} }
@ -408,12 +419,12 @@ SPCD_PM_ZYPPER="zypper"
SPCD_PYTHON_VENV="/opt/venv" SPCD_PYTHON_VENV="/opt/venv"
SPCD_PYTHON_VENV_BINARIES="${SPCD_PYTHON_VENV}/bin" SPCD_PYTHON_VENV_BINARIES="${SPCD_PYTHON_VENV}/bin"
# ╭───────┬───── # ╭───────┬─────────────
# │ steps │ env # │ steps │ environment
# ╰───────┴───── # ╰───────┴─────────────
spcd_set_environment_variables() { spcd_environment_set_variables() {
spcd_step "Set environment variables" spcd_step "Set variables"
# check script first # check script first
[ -n "${SPCD}" ] || spcd_error_ci "SPCD" [ -n "${SPCD}" ] || spcd_error_ci "SPCD"
# continuous integration / github → gitea → forgejo # continuous integration / github → gitea → forgejo
@ -893,18 +904,47 @@ ${SPCD_PYTHON_VENV}/lib/${SPCD_PYTHON_COMMAND}/site-packages"
spcd_os_printenv "SPCD_CA" "SPCD_DL" spcd_os_printenv "SPCD_CA" "SPCD_DL"
} }
spcd_list_working_directory() { spcd_environment_list_workspace() {
spcd_step "List working directory" spcd_step "List workspace"
spcd_lwd__path="$(realpath .)" spcd_lwd__path="$(realpath .)"
spcd_os_ls "${spcd_lwd__path}" spcd_os_ls "${spcd_lwd__path}"
} }
# ╭───────┬───────────╮
# │ steps │ functions │
# ╰───────┴───────────╯
spcd_install_package() {
spcd_install_package__name="${1}"
if [ -n "${spcd_install_package__name}" ]; then
${SPCD_PM_INSTALL} "${spcd_install_package__name}"
${SPCD_PM_CLEAN}
fi
}
# ╭───────┬─────╮ # ╭───────┬─────╮
# │ steps │ pkg │ # │ steps │ dns
# ╰───────┴─────╯ # ╰───────┴─────╯
spcd_set_packages_repositories() { spcd_dns() {
spcd_step "Set packages repositories" spcd_step "DNS"
while true; do
spcd_sdr__index=$((spcd_sdr__index + 1))
eval "spcd_sdr__value=\"\${SPCD_DNS_${spcd_sdr__index}}\""
[ -n "${spcd_sdr__value}" ] || break
spcd_sdr__text="${spcd_sdr__text}\
nameserver ${spcd_sdr__value}
"
done
spcd_os_write "${SPCD_DNS_FILE}" "${spcd_sdr__text}"
}
# ╭───────┬──────────╮
# │ steps │ packages │
# ╰───────┴──────────╯
spcd_packages_set_repositories() {
spcd_step "Set repositories"
case "${SPCD_OS_ID}" in case "${SPCD_OS_ID}" in
"${SPCD_OS_ALMA}") "${SPCD_OS_ALMA}")
case "${SPCD_OS_VERSION}" in case "${SPCD_OS_VERSION}" in
@ -970,8 +1010,8 @@ deb ${SPCD_URL_CHOSEN} ${SPCD_OS_VERSION}-security main universe
esac esac
} }
spcd_set_packages_configuration() { spcd_packages_set_configuration() {
spcd_step "Set packages configuration" spcd_step "Set configuration"
spcd_os_write "${SPCD_PM_CONF_PATH}" "${SPCD_PM_CONF_TEXT}" spcd_os_write "${SPCD_PM_CONF_PATH}" "${SPCD_PM_CONF_TEXT}"
case "${SPCD_OS_ID}" in case "${SPCD_OS_ID}" in
"${SPCD_OS_ARCH}") "${SPCD_OS_ARCH}")
@ -984,36 +1024,21 @@ spcd_set_packages_configuration() {
esac esac
} }
# agnostic steps spcd_packages_trust_https() {
spcd_step "Trust HTTPS"
spcd_set_https_verification_off() {
if [ -n "${SPCD_CA}" ] || [ "${SPCD_PM}" = "${SPCD_PM_APT}" ]; then if [ -n "${SPCD_CA}" ] || [ "${SPCD_PM}" = "${SPCD_PM_APT}" ]; then
spcd_step "Set HTTPS verification off"
spcd_os_mkdir "$(dirname "${SPCD_PM_HTTPS_PATH}")" spcd_os_mkdir "$(dirname "${SPCD_PM_HTTPS_PATH}")"
spcd_os_write "${SPCD_PM_HTTPS_PATH}" "${SPCD_PM_HTTPS_TEXT}" spcd_os_write "${SPCD_PM_HTTPS_PATH}" "${SPCD_PM_HTTPS_TEXT}"
fi fi
} }
spcd_set_dns_resolving() { spcd_packages_update_catalog() {
spcd_step "Set DNS resolving" spcd_step "Update catalog"
while true; do ${SPCD_PM_UPDATE}
spcd_sdr__index=$((spcd_sdr__index + 1))
eval "spcd_sdr__value=\"\${SPCD_DNS_${spcd_sdr__index}}\""
[ -n "${spcd_sdr__value}" ] || break
spcd_sdr__text="${spcd_sdr__text}\
nameserver ${spcd_sdr__value}
"
done
spcd_os_write "${SPCD_DNS_FILE}" "${spcd_sdr__text}"
} }
spcd_update_packages_catalog() { spcd_packages_install_tools() {
spcd_step "Update packages catalog" spcd_step "Install tools"
${SPCD_PM_UPDATE} || exit
}
spcd_install_packages_tools() {
spcd_step "Install packages tools"
spcd_install_package "${SPCD_PKG_PKG}" spcd_install_package "${SPCD_PKG_PKG}"
} }
@ -1036,35 +1061,35 @@ spcd_write_ca_certificates() {
spcd_wcc__path="${SPCD_CA_ROOT}/${spcd_wcc__index}.crt" spcd_wcc__path="${SPCD_CA_ROOT}/${spcd_wcc__index}.crt"
spcd_split spcd_split
spcd_os_write "${spcd_wcc__path}" "${spcd_wcc__text}" spcd_os_write "${spcd_wcc__path}" "${spcd_wcc__text}"
spcd_openssl "${spcd_wcc__path}" spcd_openssl_x509 "${spcd_wcc__path}"
done done
} }
spcd_update_ca_certificates() { spcd_update_ca_certificates() {
spcd_step "Update CA certificates" spcd_step "Update CA certificates"
${SPCD_CMD_CA} || exit ${SPCD_CMD_CA}
} }
# ╭───────┬───── # ╭───────┬──────────
# │ steps │ pkg # │ steps │ packages
# ╰───────┴───── # ╰───────┴──────────
spcd_set_https_verification_on() { spcd_packages_verify_https() {
spcd_step "Set HTTPS verification on" spcd_step "Verify HTTPS"
spcd_os_rm "${SPCD_PM_HTTPS_PATH}" spcd_os_rm "${SPCD_PM_HTTPS_PATH}"
} }
spcd_upgrade_packages() { spcd_packages_upgrade_system() {
spcd_step "Upgrade packages" spcd_step "Upgrade system"
${SPCD_PM_UPGRADE} || exit ${SPCD_PM_UPGRADE}
} }
spcd_install_dos2unix() { spcd_packages_install_dos2unix() {
spcd_step "Install dos2unix" spcd_step "Install dos2unix"
spcd_install_package "${SPCD_PKG_DOS2UNIX}" spcd_install_package "${SPCD_PKG_DOS2UNIX}"
} }
spcd_install_git() { spcd_packages_install_git() {
spcd_step "Install Git" spcd_step "Install Git"
spcd_install_package "${SPCD_PKG_GIT}" spcd_install_package "${SPCD_PKG_GIT}"
} }
@ -1073,8 +1098,8 @@ spcd_install_git() {
# │ steps │ python │ # │ steps │ python │
# ╰───────┴────────╯ # ╰───────┴────────╯
spcd_install_python() { spcd_python_install() {
spcd_step_in "Install Python" spcd_step "Install package"
spcd_install_package "${SPCD_PYTHON_PACKAGE}" spcd_install_package "${SPCD_PYTHON_PACKAGE}"
spcd_step "Link alias to command" spcd_step "Link alias to command"
spcd_python_ln "${SPCD_PYTHON_COMMAND}" spcd_python_ln "${SPCD_PYTHON_COMMAND}"
@ -1098,11 +1123,10 @@ index-url = ${SPCD_URL_PYTHON}
export PATH="${SPCD_PYTHON_VENV_BINARIES}:${PATH}" export PATH="${SPCD_PYTHON_VENV_BINARIES}:${PATH}"
export VIRTUAL_ENV="${SPCD_PYTHON_VENV}" export VIRTUAL_ENV="${SPCD_PYTHON_VENV}"
spcd_step_out spcd_step_out
spcd_step_out
} }
spcd_install_python_modules() { spcd_python_modules() {
spcd_step_in "Python modules" spcd_step_in "Modules"
spcd_ipm__target="${SPCD_PYTHON_VENV_PACKAGES}" spcd_ipm__target="${SPCD_PYTHON_VENV_PACKAGES}"
spcd_step "List" spcd_step "List"
spcd_os_ls "${spcd_ipm__target}" spcd_os_ls "${spcd_ipm__target}"
@ -1110,7 +1134,7 @@ spcd_install_python_modules() {
spcd_ipm__path="$(spcd_python_pip "${SPCD_GIT_MAIN}")" spcd_ipm__path="$(spcd_python_pip "${SPCD_GIT_MAIN}")"
# check matching of file and variable # check matching of file and variable
spcd_step "Check" spcd_step "Check"
spcd_ipm__script="${spcd_ipm__path}/main.sh" spcd_ipm__script="${spcd_ipm__path}/bootstrap.sh"
ls -l "${spcd_ipm__script}" ls -l "${spcd_ipm__script}"
spcd_ipm__check="${spcd_ipm__script}.${SPCD_CMD_SUM}" spcd_ipm__check="${spcd_ipm__script}.${SPCD_CMD_SUM}"
"${SPCD_CMD_SUM}" "${spcd_ipm__script}" >"${spcd_ipm__check}" "${SPCD_CMD_SUM}" "${spcd_ipm__script}" >"${spcd_ipm__check}"
@ -1189,8 +1213,8 @@ spcd_install_packages() {
spcd_step_out spcd_step_out
} }
spcd_write_python_module() { spcd_python_write_module() {
spcd_step "Write Python module" spcd_step "Write module"
for spcd_wpm__variable in \ for spcd_wpm__variable in \
OS_ID OS_VERSION \ OS_ID OS_VERSION \
PROJECT_ROOT PROJECT_PATH PROJECT_NAME \ PROJECT_ROOT PROJECT_PATH PROJECT_NAME \
@ -1208,8 +1232,8 @@ SPCD_STEP = $((SPCD_STEP + 1))
done done
} }
spcd_switch_to_python() { spcd_python_switch() {
spcd_step "Switch to Python" spcd_step "Switch"
spcd_stp__name="$(basename "${SPCD_GIT_MAIN}")" spcd_stp__name="$(basename "${SPCD_GIT_MAIN}")"
echo "\ echo "\
${SPCD_PATH} ${SPCD_PATH}
@ -1220,62 +1244,45 @@ ${SPCD_PYTHON_ALIAS} / ${spcd_stp__name}"
#╶──────────────────────────────────────╴ #╶──────────────────────────────────────╴
# ╭───────────╮
# │ functions │
# ╰───────────╯
spcd_install_package() {
spcd_install_package__name="${1}"
if [ -n "${spcd_install_package__name}" ]; then
${SPCD_PM_INSTALL} "${spcd_install_package__name}" || exit
${SPCD_PM_CLEAN} || exit
fi
}
spcd_openssl() {
spcd_openssl__file="${1}"
if [ -f "${spcd_openssl__file}" ]; then
openssl x509 \
-in "${spcd_openssl__file}" \
-noout -text ||
exit
fi
}
#╶──────────────────────────────────────╴
# ╭──────╮ # ╭──────╮
# │ main │ # │ main │
# ╰──────╯ # ╰──────╯
spcd_main() { spcd_main() {
# env # environment
spcd_set_environment_variables spcd_step_in "Environment"
spcd_list_working_directory spcd_environment_set_variables
# pkg spcd_environment_list_workspace
spcd_set_packages_repositories spcd_step_out
spcd_set_packages_configuration # dns
# spcd_dns
spcd_set_https_verification_off # packages
spcd_set_dns_resolving spcd_step_in "Packages"
spcd_update_packages_catalog spcd_packages_set_repositories
spcd_install_packages_tools spcd_packages_set_configuration
spcd_packages_trust_https
spcd_packages_update_catalog
spcd_packages_install_tools
spcd_step_out
# ca # 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 # packages
spcd_set_https_verification_on spcd_step_in "Packages"
spcd_update_packages_catalog spcd_packages_verify_https
spcd_upgrade_packages spcd_packages_update_catalog
spcd_install_dos2unix spcd_packages_upgrade_system
spcd_install_git spcd_packages_install_dos2unix
spcd_packages_install_git
spcd_step_out
# python # python
spcd_install_python spcd_step_in "Python"
spcd_install_python_modules spcd_python_install
spcd_python_modules
spcd_install_packages spcd_install_packages
spcd_write_python_module spcd_python_write_module
spcd_switch_to_python spcd_python_switch
} }
spcd_main spcd_main