Compare commits
10 commits
7405da845d
...
c0ea80cf6f
Author | SHA1 | Date | |
---|---|---|---|
c0ea80cf6f | |||
456b96da31 | |||
6891be7a73 | |||
4fb4f2a32e | |||
0a1330b58e | |||
ba5f74d0a9 | |||
e83076e35d | |||
aa76386700 | |||
c494c59f06 | |||
8004c604b3 |
2 changed files with 67 additions and 32 deletions
93
pidd.sh
93
pidd.sh
|
@ -4,8 +4,8 @@
|
||||||
[ -n "${PIDD_DNS}" ] || PIDD_DNS="\
|
[ -n "${PIDD_DNS}" ] || PIDD_DNS="\
|
||||||
9.9.9.9 \
|
9.9.9.9 \
|
||||||
"
|
"
|
||||||
[ -n "${PIDD_GIT_CHILD}" ] || PIDD_GIT_CHILD="pidd"
|
[ -n "${PIDD_GIT_MAIN}" ] || PIDD_GIT_MAIN="pidd"
|
||||||
[ -n "${PIDD_GIT_PARENT}" ] || PIDD_GIT_PARENT="rwx"
|
[ -n "${PIDD_GIT_ROOT}" ] || PIDD_GIT_ROOT="rwx"
|
||||||
|
|
||||||
# main
|
# main
|
||||||
pidd_main () {
|
pidd_main () {
|
||||||
|
@ -13,6 +13,7 @@ pidd_main () {
|
||||||
pidd_set_packages_repositories
|
pidd_set_packages_repositories
|
||||||
pidd_set_packages_configuration
|
pidd_set_packages_configuration
|
||||||
#
|
#
|
||||||
|
pidd_list_environment_variables
|
||||||
pidd_list_working_directory
|
pidd_list_working_directory
|
||||||
pidd_set_https_verification_off
|
pidd_set_https_verification_off
|
||||||
pidd_set_dns_resolving
|
pidd_set_dns_resolving
|
||||||
|
@ -351,12 +352,17 @@ Acquire::https::Verify-Peer False;
|
||||||
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_SERVER_URL="${GITHUB_SERVER_URL}"
|
if [ -n "${GITHUB_TOKEN}" ] ; then
|
||||||
|
PIDD_PROJECT_ROOT="$(dirname "${GITHUB_SERVER_URL}")\
|
||||||
|
//${GITHUB_TOKEN}@$(basename "${GITHUB_SERVER_URL}")"
|
||||||
|
else
|
||||||
|
pidd_error_ci "GITHUB_TOKEN"
|
||||||
|
fi
|
||||||
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_PROJECTS_GROUP="$(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"
|
||||||
|
@ -368,16 +374,33 @@ Acquire::https::Verify-Peer False;
|
||||||
fi
|
fi
|
||||||
elif [ -n "${GITLAB_CI}" ] ; then
|
elif [ -n "${GITLAB_CI}" ] ; then
|
||||||
# gitlab
|
# gitlab
|
||||||
if [ -n "${CI_SERVER_URL}" ] ; then
|
if [ -n "${CI_SERVER_PROTOCOL}" ] ; then
|
||||||
PIDD_SERVER_URL="${CI_SERVER_URL}"
|
if [ -n "${CI_REGISTRY_USER}" ] ; then
|
||||||
|
if [ -n "${CI_REGISTRY_PASSWORD}" ] ; then
|
||||||
|
if [ -n "${CI_SERVER_FQDN}" ] ; then
|
||||||
|
PIDD_PROJECT_ROOT="${CI_SERVER_PROTOCOL}\
|
||||||
|
://${CI_REGISTRY_USER}:${CI_REGISTRY_PASSWORD}@${CI_SERVER_FQDN}"
|
||||||
|
if [ -n "${CI_PROJECT_NAMESPACE}" ] ; then
|
||||||
|
PIDD_PROJECT_PATH="${CI_PROJECT_NAMESPACE}"
|
||||||
|
if [ -n "${CI_PROJECT_NAME}" ] ; then
|
||||||
|
PIDD_PROJECT_NAME="${CI_PROJECT_NAME}"
|
||||||
|
else
|
||||||
|
pidd_error_ci "CI_PROJECT_NAME"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
pidd_error_ci "CI_PROJECT_NAMESPACE"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
pidd_error_ci "CI_SERVER_FQDN"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
pidd_error_ci "CI_REGISTRY_PASSWORD"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
pidd_error_ci "CI_REGISTRY_USER"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
pidd_error_ci "CI_SERVER_URL"
|
pidd_error_ci "CI_SERVER_PROTOCOL"
|
||||||
fi
|
|
||||||
if [ -n "${CI_PROJECT_PATH}" ] ; then
|
|
||||||
PIDD_PROJECTS_GROUP="$(dirname "${CI_PROJECT_PATH}")"
|
|
||||||
PIDD_PROJECT_NAME="$(basename "${CI_PROJECT_PATH}")"
|
|
||||||
else
|
|
||||||
pidd_error_ci "CI_PROJECT_PATH"
|
|
||||||
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}"
|
||||||
|
@ -388,20 +411,16 @@ Acquire::https::Verify-Peer False;
|
||||||
# unsupported
|
# unsupported
|
||||||
pidd_error_ci "ø"
|
pidd_error_ci "ø"
|
||||||
fi
|
fi
|
||||||
[ -n "${PIDD_SERVER_URL}" ] || pidd_error_ci "PIDD_SERVER_URL"
|
[ -n "${PIDD_PROJECT_ROOT}" ] || pidd_error_ci "PIDD_PROJECT_ROOT"
|
||||||
[ -n "${PIDD_PROJECTS_GROUP}" ] || pidd_error_ci "PIDD_PROJECTS_GROUP"
|
[ -n "${PIDD_PROJECT_PATH}" ] || pidd_error_ci "PIDD_PROJECT_PATH"
|
||||||
[ -n "${PIDD_PROJECT_NAME}" ] || pidd_error_ci "PIDD_PROJECT_NAME"
|
[ -n "${PIDD_PROJECT_NAME}" ] || pidd_error_ci "PIDD_PROJECT_NAME"
|
||||||
[ -n "${PIDD_PROJECT_BRANCH}" ] || pidd_error_ci "PIDD_PROJECT_BRANCH"
|
[ -n "${PIDD_PROJECT_BRANCH}" ] || pidd_error_ci "PIDD_PROJECT_BRANCH"
|
||||||
#
|
#
|
||||||
PIDD_PROJECTS_URL="${PIDD_SERVER_URL}/${PIDD_PROJECTS_GROUP}"
|
|
||||||
#
|
|
||||||
pidd_split
|
pidd_split
|
||||||
pidd_echo "PIDD_CA"
|
pidd_echo "PIDD_CA"
|
||||||
pidd_split
|
pidd_split
|
||||||
pidd_echo "PIDD_SERVER_URL" \
|
pidd_echo "PIDD_PROJECT_ROOT" \
|
||||||
"PIDD_PROJECTS_GROUP" "PIDD_PROJECT_NAME" "PIDD_PROJECT_BRANCH"
|
"PIDD_PROJECT_PATH" "PIDD_PROJECT_NAME" "PIDD_PROJECT_BRANCH"
|
||||||
pidd_split
|
|
||||||
pidd_echo "PIDD_PROJECTS_URL"
|
|
||||||
# TODO move to Python
|
# TODO move to Python
|
||||||
case "${PIDD_PM}" in
|
case "${PIDD_PM}" in
|
||||||
"${PIDD_PM_APK}"|"${PIDD_PM_APT}") PIDD_PKG_SSH="openssh-client" ;;
|
"${PIDD_PM_APK}"|"${PIDD_PM_APT}") PIDD_PKG_SSH="openssh-client" ;;
|
||||||
|
@ -482,6 +501,11 @@ pidd_set_packages_configuration () {
|
||||||
|
|
||||||
# agnostic steps
|
# agnostic steps
|
||||||
|
|
||||||
|
pidd_list_environment_variables () {
|
||||||
|
pidd_step "List environment variables"
|
||||||
|
env | sort
|
||||||
|
}
|
||||||
|
|
||||||
pidd_list_working_directory () {
|
pidd_list_working_directory () {
|
||||||
pidd_step "List working directory"
|
pidd_step "List working directory"
|
||||||
pidd_list_working_directory__path="$(realpath .)"
|
pidd_list_working_directory__path="$(realpath .)"
|
||||||
|
@ -590,10 +614,18 @@ pidd_install_python_modules () {
|
||||||
pidd_install_python_modules__root="$(mktemp --directory)" || exit
|
pidd_install_python_modules__root="$(mktemp --directory)" || exit
|
||||||
echo "→ ${pidd_install_python_modules__root}"
|
echo "→ ${pidd_install_python_modules__root}"
|
||||||
for pidd_install_python_modules__repository \
|
for pidd_install_python_modules__repository \
|
||||||
in "${PIDD_GIT_CHILD}" "${PIDD_GIT_PARENT}" ; do
|
in "${PIDD_GIT_MAIN}" "${PIDD_GIT_ROOT}" ; do
|
||||||
pidd_split
|
case "${pidd_install_python_modules__repository}" in
|
||||||
|
http*) pidd_install_python_modules__url="\
|
||||||
|
${pidd_install_python_modules__repository}" ;;
|
||||||
|
/*) pidd_install_python_modules__url="\
|
||||||
|
${PIDD_PROJECT_ROOT}${pidd_install_python_modules__repository}" ;;
|
||||||
|
*) pidd_install_python_modules__url="\
|
||||||
|
${PIDD_PROJECT_ROOT}/${PIDD_PROJECT_PATH}/${pidd_install_python_modules__repository}" ;;
|
||||||
|
esac
|
||||||
pidd_install_python_modules__url="\
|
pidd_install_python_modules__url="\
|
||||||
${PIDD_PROJECTS_URL}/${pidd_install_python_modules__repository}"
|
${PIDD_PROJECT_ROOT}/${PIDD_PROJECT_PATH}/${pidd_install_python_modules__repository}"
|
||||||
|
pidd_split
|
||||||
echo "\
|
echo "\
|
||||||
${pidd_install_python_modules__url}
|
${pidd_install_python_modules__url}
|
||||||
↓"
|
↓"
|
||||||
|
@ -622,8 +654,11 @@ ${PIDD_PYTHON_PACKAGES}"
|
||||||
|
|
||||||
pidd_write_python_module () {
|
pidd_write_python_module () {
|
||||||
pidd_step "Write Python module"
|
pidd_step "Write Python module"
|
||||||
for pidd_write_python_module__variable \
|
for pidd_write_python_module__variable in \
|
||||||
in OPEN DOWN VERT SPLT __UP SHUT OS_ID OS_VERSION ; do
|
OPEN DOWN VERT SPLT __UP SHUT \
|
||||||
|
OS_ID OS_VERSION \
|
||||||
|
PROJECT_ROOT PROJECT_PATH PROJECT_NAME \
|
||||||
|
; do
|
||||||
pidd_write_python_module__value="\
|
pidd_write_python_module__value="\
|
||||||
$(pidd_echo "PIDD_${pidd_write_python_module__variable}")"
|
$(pidd_echo "PIDD_${pidd_write_python_module__variable}")"
|
||||||
pidd_write_python_module__text="${pidd_write_python_module__text}\
|
pidd_write_python_module__text="${pidd_write_python_module__text}\
|
||||||
|
@ -637,11 +672,12 @@ PIDD_STEP = $((PIDD_STEP+1))
|
||||||
|
|
||||||
pidd_switch_to_python () {
|
pidd_switch_to_python () {
|
||||||
pidd_step "Switch to Python"
|
pidd_step "Switch to Python"
|
||||||
|
pidd_switch_to_python__name="$(basename "${PIDD_GIT_MAIN}")"
|
||||||
echo "\
|
echo "\
|
||||||
${PIDD_PATH}
|
${PIDD_PATH}
|
||||||
↓
|
↓
|
||||||
${PIDD_PYTHON_PACKAGES}/${PIDD_GIT_CHILD}"
|
${PIDD_PYTHON_PACKAGES}/${pidd_switch_to_python__name}"
|
||||||
"${PIDD_PYTHON_ALIAS}" -m "${PIDD_GIT_CHILD}" "${@}"
|
"${PIDD_PYTHON_ALIAS}" -m "${pidd_switch_to_python__name}" "${@}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# functions
|
# functions
|
||||||
|
@ -658,6 +694,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=""
|
||||||
eval "pidd_echo__text=\"\${${pidd_echo__name}}\""
|
eval "pidd_echo__text=\"\${${pidd_echo__name}}\""
|
||||||
echo "${pidd_echo__name} = \"${pidd_echo__text}\""
|
echo "${pidd_echo__name} = \"${pidd_echo__text}\""
|
||||||
done
|
done
|
||||||
|
|
|
@ -43,8 +43,8 @@ from various contexts of CA, CI and OCI / OS.
|
||||||
|:----------------|:------------------------|:--------------------------------|
|
|:----------------|:------------------------|:--------------------------------|
|
||||||
| PIDD_CA_n | Numbered CA certificate | |
|
| PIDD_CA_n | Numbered CA certificate | |
|
||||||
| PIDD_DNS | Space separated servers | 9.9.9.9 |
|
| PIDD_DNS | Space separated servers | 9.9.9.9 |
|
||||||
| PIDD_GIT_CHILD | Child Git repository | pidd |
|
| PIDD_GIT_MAIN | Main Git repository | pidd |
|
||||||
| PIDD_GIT_PARENT | Parent Git repository | rwx |
|
| PIDD_GIT_ROOT | Root Git repository | rwx |
|
||||||
| PIDD_SSH_HOSTS | domain.tld ssh-type pub | |
|
| PIDD_SSH_HOSTS | domain.tld ssh-type pub | |
|
||||||
| PIDD_SSH_KEY | SSH private key | |
|
| PIDD_SSH_KEY | SSH private key | |
|
||||||
| PIDD_URL_ALMA | Alma repository URL | https://repo.almalinux.org |
|
| PIDD_URL_ALMA | Alma repository URL | https://repo.almalinux.org |
|
||||||
|
@ -93,7 +93,5 @@ from various contexts of CA, CI and OCI / OS.
|
||||||
|
|
||||||
### .sh
|
### .sh
|
||||||
|
|
||||||
* handle git cloning credentials
|
|
||||||
* override repository and framework locations
|
|
||||||
* reduce single conditions with &&
|
* reduce single conditions with &&
|
||||||
* support opensuse
|
* support opensuse
|
||||||
|
|
Loading…
Reference in a new issue