This commit is contained in:
Marc Beninca 2024-06-24 11:04:10 +02:00
parent de370d346d
commit 61f61b08f2
Signed by: marc.beninca
GPG key ID: 9C7613450C80C24F

50
pidd.sh
View file

@ -363,39 +363,39 @@ Acquire::https::Verify-Peer False;
# variables # variables
[ -n "${PIDD_CA_1}" ] && PIDD_CA=true [ -n "${PIDD_CA_1}" ] && PIDD_CA=true
# continuous integration platform # continuous integration platform
if [ -n "${GITHUB_ACTIONS}" ] ; then if [ -n "${GITHUB_ACTIONS}" ]; then
# github → gitea → forgejo # github → gitea → forgejo
if [ -n "${GITHUB_SERVER_URL}" ] ; then if [ -n "${GITHUB_SERVER_URL}" ]; then
PIDD_PROJECT_ROOT="$(dirname "${GITHUB_SERVER_URL}")//" PIDD_PROJECT_ROOT="$(dirname "${GITHUB_SERVER_URL}")//"
if [ -n "${GITHUB_TOKEN}" ] ; then if [ -n "${GITHUB_TOKEN}" ]; then
PIDD_PROJECT_ROOT="${PIDD_PROJECT_ROOT}${GITHUB_TOKEN}@" PIDD_PROJECT_ROOT="${PIDD_PROJECT_ROOT}${GITHUB_TOKEN}@"
fi fi
PIDD_PROJECT_ROOT="${PIDD_PROJECT_ROOT}$(basename "${GITHUB_SERVER_URL}")" PIDD_PROJECT_ROOT="${PIDD_PROJECT_ROOT}$(basename "${GITHUB_SERVER_URL}")"
else else
pidd_error_ci "GITHUB_SERVER_URL" pidd_error_ci "GITHUB_SERVER_URL"
fi fi
if [ -n "${GITHUB_REPOSITORY}" ] ; then if [ -n "${GITHUB_REPOSITORY}" ]; then
PIDD_PROJECT_PATH="$(dirname "${GITHUB_REPOSITORY}")" PIDD_PROJECT_PATH="$(dirname "${GITHUB_REPOSITORY}")"
PIDD_PROJECT_NAME="$(basename "${GITHUB_REPOSITORY}")" PIDD_PROJECT_NAME="$(basename "${GITHUB_REPOSITORY}")"
else else
pidd_error_ci "GITHUB_REPOSITORY" pidd_error_ci "GITHUB_REPOSITORY"
fi fi
if [ -n "${GITHUB_REF_NAME}" ] ; then if [ -n "${GITHUB_REF_NAME}" ]; then
PIDD_PROJECT_BRANCH="${GITHUB_REF_NAME}" PIDD_PROJECT_BRANCH="${GITHUB_REF_NAME}"
else else
pidd_error_ci "GITHUB_REF_NAME" pidd_error_ci "GITHUB_REF_NAME"
fi fi
elif [ -n "${GITLAB_CI}" ] ; then elif [ -n "${GITLAB_CI}" ]; then
# gitlab # gitlab
if [ -n "${CI_SERVER_PROTOCOL}" ] ; then if [ -n "${CI_SERVER_PROTOCOL}" ]; then
if [ -n "${CI_REGISTRY_USER}" ] ; then if [ -n "${CI_REGISTRY_USER}" ]; then
if [ -n "${CI_REGISTRY_PASSWORD}" ] ; then if [ -n "${CI_REGISTRY_PASSWORD}" ]; then
if [ -n "${CI_SERVER_FQDN}" ] ; then if [ -n "${CI_SERVER_FQDN}" ]; then
PIDD_PROJECT_ROOT="${CI_SERVER_PROTOCOL}\ PIDD_PROJECT_ROOT="${CI_SERVER_PROTOCOL}\
://${CI_REGISTRY_USER}:${CI_REGISTRY_PASSWORD}@${CI_SERVER_FQDN}" ://${CI_REGISTRY_USER}:${CI_REGISTRY_PASSWORD}@${CI_SERVER_FQDN}"
if [ -n "${CI_PROJECT_NAMESPACE}" ] ; then if [ -n "${CI_PROJECT_NAMESPACE}" ]; then
PIDD_PROJECT_PATH="${CI_PROJECT_NAMESPACE}" PIDD_PROJECT_PATH="${CI_PROJECT_NAMESPACE}"
if [ -n "${CI_PROJECT_NAME}" ] ; then if [ -n "${CI_PROJECT_NAME}" ]; then
PIDD_PROJECT_NAME="${CI_PROJECT_NAME}" PIDD_PROJECT_NAME="${CI_PROJECT_NAME}"
else else
pidd_error_ci "CI_PROJECT_NAME" pidd_error_ci "CI_PROJECT_NAME"
@ -415,7 +415,7 @@ Acquire::https::Verify-Peer False;
else else
pidd_error_ci "CI_SERVER_PROTOCOL" pidd_error_ci "CI_SERVER_PROTOCOL"
fi fi
if [ -n "${CI_COMMIT_BRANCH}" ] ; then if [ -n "${CI_COMMIT_BRANCH}" ]; then
PIDD_PROJECT_BRANCH="${CI_COMMIT_BRANCH}" PIDD_PROJECT_BRANCH="${CI_COMMIT_BRANCH}"
else else
pidd_error_ci "CI_COMMIT_BRANCH" pidd_error_ci "CI_COMMIT_BRANCH"
@ -511,7 +511,7 @@ pidd_set_packages_configuration() {
# agnostic steps # agnostic steps
pidd_set_https_verification_off() { pidd_set_https_verification_off() {
if [ -n "${PIDD_CA}" ] || [ "${PIDD_PM}" = "${PIDD_PM_APT}" ] ; then if [ -n "${PIDD_CA}" ] || [ "${PIDD_PM}" = "${PIDD_PM_APT}" ]; then
pidd_step "Set HTTPS verification off" pidd_step "Set HTTPS verification off"
pidd_mkdir "$(dirname "${PIDD_PM_HTTPS_PATH}")" pidd_mkdir "$(dirname "${PIDD_PM_HTTPS_PATH}")"
pidd_write "${PIDD_PM_HTTPS_PATH}" "${PIDD_PM_HTTPS_TEXT}" pidd_write "${PIDD_PM_HTTPS_PATH}" "${PIDD_PM_HTTPS_TEXT}"
@ -668,7 +668,7 @@ ${PIDD_PYTHON_PACKAGES}/${pidd_stp__name}"
pidd_cat() { pidd_cat() {
pidd_cat__file="${1}" pidd_cat__file="${1}"
if [ -n "${pidd_cat__file}" ] ; then if [ -n "${pidd_cat__file}" ]; then
pidd_open "${pidd_cat__file}" pidd_open "${pidd_cat__file}"
cat "${pidd_cat__file}" || exit cat "${pidd_cat__file}" || exit
pidd_shut "${pidd_cat__file}" pidd_shut "${pidd_cat__file}"
@ -676,7 +676,7 @@ pidd_cat() {
} }
pidd_echo() { pidd_echo() {
if [ -n "${1}" ] ; then if [ -n "${1}" ]; then
for pidd_echo__name in "${@}" ; do for pidd_echo__name in "${@}" ; do
pidd_echo__text="" pidd_echo__text=""
eval "pidd_echo__text=\"\${${pidd_echo__name}}\"" eval "pidd_echo__text=\"\${${pidd_echo__name}}\""
@ -699,7 +699,7 @@ pidd_error_os() {
pidd_grep_os() { pidd_grep_os() {
pidd_grep_os__variable="${1}" pidd_grep_os__variable="${1}"
if [ -n "${pidd_grep_os__variable}" ] ; then if [ -n "${pidd_grep_os__variable}" ]; then
grep "^${pidd_grep_os__variable}=" "/etc/os-release" \ grep "^${pidd_grep_os__variable}=" "/etc/os-release" \
| sed "s|^${pidd_grep_os__variable}=||" \ | sed "s|^${pidd_grep_os__variable}=||" \
| sed "s|^\"\(.*\)\"$|\1|" | sed "s|^\"\(.*\)\"$|\1|"
@ -708,14 +708,14 @@ pidd_grep_os() {
pidd_install_package() { pidd_install_package() {
pidd_install_package__name="${1}" pidd_install_package__name="${1}"
if [ -n "${pidd_install_package__name}" ] ; then if [ -n "${pidd_install_package__name}" ]; then
${PIDD_PM_INSTALL} "${pidd_install_package__name}" || exit ${PIDD_PM_INSTALL} "${pidd_install_package__name}" || exit
fi fi
} }
pidd_ln_python() { pidd_ln_python() {
pidd_ln_python__command="${1}" pidd_ln_python__command="${1}"
if [ -n "${pidd_ln_python__command}" ] ; then if [ -n "${pidd_ln_python__command}" ]; then
echo "${PIDD_PYTHON_ALIAS}${pidd_ln_python__command}" echo "${PIDD_PYTHON_ALIAS}${pidd_ln_python__command}"
ln -f -s "${pidd_ln_python__command}" "/usr/bin/${PIDD_PYTHON_ALIAS}" \ ln -f -s "${pidd_ln_python__command}" "/usr/bin/${PIDD_PYTHON_ALIAS}" \
|| exit || exit
@ -724,7 +724,7 @@ pidd_ln_python() {
pidd_ls() { pidd_ls() {
pidd_ls__path="${1}" pidd_ls__path="${1}"
if [ -n "${pidd_ls__path}" ] ; then if [ -n "${pidd_ls__path}" ]; then
pidd_open "${pidd_ls__path}" pidd_open "${pidd_ls__path}"
ls -a -l "${pidd_ls__path}" || exit ls -a -l "${pidd_ls__path}" || exit
pidd_shut "${pidd_ls__path}" pidd_shut "${pidd_ls__path}"
@ -733,7 +733,7 @@ pidd_ls() {
pidd_mkdir() { pidd_mkdir() {
pidd_mkdir__path="${1}" pidd_mkdir__path="${1}"
if [ -n "${pidd_mkdir__path}" ] ; then if [ -n "${pidd_mkdir__path}" ]; then
echo "${pidd_mkdir__path}" echo "${pidd_mkdir__path}"
mkdir --parents "${pidd_mkdir__path}" || exit mkdir --parents "${pidd_mkdir__path}" || exit
fi fi
@ -745,7 +745,7 @@ pidd_open() {
pidd_openssl() { pidd_openssl() {
pidd_openssl__file="${1}" pidd_openssl__file="${1}"
if [ -f "${pidd_openssl__file}" ] ; then if [ -f "${pidd_openssl__file}" ]; then
openssl x509 \ openssl x509 \
-in "${pidd_openssl__file}" \ -in "${pidd_openssl__file}" \
-noout -text \ -noout -text \
@ -755,7 +755,7 @@ pidd_openssl() {
pidd_rm() { pidd_rm() {
pidd_rm__path="${1}" pidd_rm__path="${1}"
if [ -e "${pidd_rm__path}" ] ; then if [ -e "${pidd_rm__path}" ]; then
echo "${pidd_rm__path}" echo "${pidd_rm__path}"
rm -r "${pidd_rm__path}" || exit rm -r "${pidd_rm__path}" || exit
fi fi
@ -764,7 +764,7 @@ pidd_rm() {
pidd_sed() { pidd_sed() {
pidd_sed__file="${1}" pidd_sed__file="${1}"
shift shift
if [ -f "${pidd_sed__file}" ] ; then if [ -f "${pidd_sed__file}" ]; then
pidd_cat "${pidd_sed__file}" pidd_cat "${pidd_sed__file}"
for pidd_sed__regex in "${@}" ; do for pidd_sed__regex in "${@}" ; do
sed --in-place "s${pidd_sed__regex}g" "${pidd_sed__file}" \ sed --in-place "s${pidd_sed__regex}g" "${pidd_sed__file}" \
@ -793,7 +793,7 @@ ${PIDD___UP}"
pidd_write() { pidd_write() {
pidd_write__file="${1}" pidd_write__file="${1}"
pidd_write__text="${2}" pidd_write__text="${2}"
if [ -n "${pidd_write__file}" ] ; then if [ -n "${pidd_write__file}" ]; then
[ -f "${pidd_write__file}" ] && pidd_cat "${pidd_write__file}" [ -f "${pidd_write__file}" ] && pidd_cat "${pidd_write__file}"
echo "${pidd_write__file}" echo "${pidd_write__file}"
printf "%s" "${pidd_write__text}" > "${pidd_write__file}" || exit printf "%s" "${pidd_write__text}" > "${pidd_write__file}" || exit