This commit is contained in:
Marc Beninca 2024-06-24 10:48:26 +02:00
parent 81bcc37d25
commit 0dbbaaab69
Signed by: marc.beninca
GPG key ID: 9C7613450C80C24F

80
pidd.sh
View file

@ -8,7 +8,7 @@
[ -n "${PIDD_GIT_ROOT}" ] || PIDD_GIT_ROOT="rwx"
# main
pidd_main () {
pidd_main() {
pidd_list_environment_variables
pidd_list_working_directory
#
@ -40,12 +40,12 @@ pidd_main () {
# context
pidd_list_environment_variables () {
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_lwd__path="$(realpath .)"
pidd_ls "${pidd_lwd__path}"
@ -53,7 +53,7 @@ pidd_list_working_directory () {
# steps
pidd_set_environment_variables () {
pidd_set_environment_variables() {
pidd_step "Set environment variables"
# set path
PIDD_PATH="$(realpath "${0}")"
@ -443,7 +443,7 @@ Acquire::https::Verify-Peer False;
esac
}
pidd_set_packages_repositories () {
pidd_set_packages_repositories() {
pidd_step "Set packages repositories"
case "${PIDD_OS_ID}" in
"${PIDD_OS_ALMA}")
@ -497,7 +497,7 @@ deb ${PIDD_URL_CHOSEN} ${PIDD_OS_VERSION}-security main
esac
}
pidd_set_packages_configuration () {
pidd_set_packages_configuration() {
pidd_step "Set packages configuration"
pidd_write "${PIDD_PM_CONF_PATH}" "${PIDD_PM_CONF_TEXT}"
case "${PIDD_OS_ID}" in
@ -510,7 +510,7 @@ pidd_set_packages_configuration () {
# agnostic steps
pidd_set_https_verification_off () {
pidd_set_https_verification_off() {
if [ -n "${PIDD_CA}" ] || [ "${PIDD_PM}" = "${PIDD_PM_APT}" ] ; then
pidd_step "Set HTTPS verification off"
pidd_mkdir "$(dirname "${PIDD_PM_HTTPS_PATH}")"
@ -518,7 +518,7 @@ pidd_set_https_verification_off () {
fi
}
pidd_set_dns_resolving () {
pidd_set_dns_resolving() {
pidd_step "Set DNS resolving"
for pidd_sdr__server in ${PIDD_DNS} ; do
pidd_sdr__text="${pidd_sdr__text}\
@ -528,22 +528,22 @@ nameserver ${pidd_sdr__server}
pidd_write "${PIDD_DNS_FILE}" "${pidd_sdr__text}"
}
pidd_update_packages_catalog () {
pidd_update_packages_catalog() {
pidd_step "Update packages catalog"
${PIDD_PM_UPDATE} || exit
}
pidd_install_packages_tools () {
pidd_install_packages_tools() {
pidd_step "Install packages tools"
pidd_install_package "${PIDD_PKG_PKG}"
}
pidd_install_ca_certificates () {
pidd_install_ca_certificates() {
pidd_step "Install CA"
pidd_install_package "${PIDD_PKG_CA}"
}
pidd_write_ca_certificates () {
pidd_write_ca_certificates() {
pidd_step "Write CA certificates"
pidd_mkdir "${PIDD_CA_ROOT}"
pidd_wcc__index=1
@ -560,27 +560,27 @@ pidd_write_ca_certificates () {
done
}
pidd_update_ca_certificates () {
pidd_update_ca_certificates() {
pidd_step "Update CA certificates"
${PIDD_CMD_CA} || exit
}
pidd_set_https_verification_on () {
pidd_set_https_verification_on() {
pidd_step "Set HTTPS verification on"
pidd_rm "${PIDD_PM_HTTPS_PATH}"
}
pidd_upgrade_packages () {
pidd_upgrade_packages() {
pidd_step "Upgrade packages"
${PIDD_PM_UPGRADE} || exit
}
pidd_install_git () {
pidd_install_git() {
pidd_step "Install Git"
pidd_install_package "${PIDD_PKG_GIT}"
}
pidd_install_python () {
pidd_install_python() {
pidd_step "Install Python"
pidd_install_package "${PIDD_PYTHON_PACKAGE}"
pidd_split
@ -588,23 +588,23 @@ pidd_install_python () {
}
# TODO move to Python
pidd_install_rsync () {
pidd_install_rsync() {
pidd_step "Install Rsync"
pidd_install_package "${PIDD_PKG_RSYNC}"
}
# TODO move to Python
pidd_install_ssh () {
pidd_install_ssh() {
pidd_step "Install SSH"
pidd_install_package "${PIDD_PKG_SSH}"
}
pidd_clean_packages_cache () {
pidd_clean_packages_cache() {
pidd_step "Clean packages cache"
${PIDD_PM_CLEAN} || exit
}
pidd_install_python_modules () {
pidd_install_python_modules() {
pidd_step "Install Python modules"
pidd_ipm__root="$(mktemp --directory)" || exit
echo "${pidd_ipm__root}"
@ -638,7 +638,7 @@ ${PIDD_PYTHON_PACKAGES}"
pidd_rm "${pidd_ipm__root}"
}
pidd_write_python_module () {
pidd_write_python_module() {
pidd_step "Write Python module"
for pidd_wpm__variable in \
OPEN DOWN VERT SPLT __UP SHUT \
@ -654,7 +654,7 @@ PIDD_STEP = $((PIDD_STEP+1))
"
}
pidd_switch_to_python () {
pidd_switch_to_python() {
pidd_step "Switch to Python"
pidd_stp__name="$(basename "${PIDD_GIT_MAIN}")"
echo "\
@ -666,7 +666,7 @@ ${PIDD_PYTHON_PACKAGES}/${pidd_stp__name}"
# functions
pidd_cat () {
pidd_cat() {
pidd_cat__file="${1}"
if [ -n "${pidd_cat__file}" ] ; then
pidd_open "${pidd_cat__file}"
@ -675,7 +675,7 @@ pidd_cat () {
fi
}
pidd_echo () {
pidd_echo() {
if [ -n "${1}" ] ; then
for pidd_echo__name in "${@}" ; do
pidd_echo__text=""
@ -685,19 +685,19 @@ pidd_echo () {
fi
}
pidd_error_ci () {
pidd_error_ci() {
echo "× CI: ${*}"
exit "${PIDD_ERROR_CI}"
}
pidd_error_os () {
pidd_error_os() {
pidd_error_os__variable="${1}"
printf "× OS: "
pidd_echo "${pidd_error_os__variable}"
exit "${PIDD_ERROR_OS}"
}
pidd_grep_os () {
pidd_grep_os() {
pidd_grep_os__variable="${1}"
if [ -n "${pidd_grep_os__variable}" ] ; then
grep "^${pidd_grep_os__variable}=" "/etc/os-release" \
@ -706,14 +706,14 @@ pidd_grep_os () {
fi
}
pidd_install_package () {
pidd_install_package() {
pidd_install_package__name="${1}"
if [ -n "${pidd_install_package__name}" ] ; then
${PIDD_PM_INSTALL} "${pidd_install_package__name}" || exit
fi
}
pidd_ln_python () {
pidd_ln_python() {
pidd_ln_python__command="${1}"
if [ -n "${pidd_ln_python__command}" ] ; then
echo "${PIDD_PYTHON_ALIAS}${pidd_ln_python__command}"
@ -722,7 +722,7 @@ pidd_ln_python () {
fi
}
pidd_ls () {
pidd_ls() {
pidd_ls__path="${1}"
if [ -n "${pidd_ls__path}" ] ; then
pidd_open "${pidd_ls__path}"
@ -731,7 +731,7 @@ pidd_ls () {
fi
}
pidd_mkdir () {
pidd_mkdir() {
pidd_mkdir__path="${1}"
if [ -n "${pidd_mkdir__path}" ] ; then
echo "${pidd_mkdir__path}"
@ -739,11 +739,11 @@ pidd_mkdir () {
fi
}
pidd_open () {
pidd_open() {
echo "${PIDD_OPEN}${*}"
}
pidd_openssl () {
pidd_openssl() {
pidd_openssl__file="${1}"
if [ -f "${pidd_openssl__file}" ] ; then
openssl x509 \
@ -753,7 +753,7 @@ pidd_openssl () {
fi
}
pidd_rm () {
pidd_rm() {
pidd_rm__path="${1}"
if [ -e "${pidd_rm__path}" ] ; then
echo "${pidd_rm__path}"
@ -761,7 +761,7 @@ pidd_rm () {
fi
}
pidd_sed () {
pidd_sed() {
pidd_sed__file="${1}"
shift
if [ -f "${pidd_sed__file}" ] ; then
@ -774,15 +774,15 @@ pidd_sed () {
fi
}
pidd_shut () {
pidd_shut() {
echo "${PIDD_SHUT}${*}"
}
pidd_split () {
pidd_split() {
echo "${PIDD_SPLT}"
}
pidd_step () {
pidd_step() {
PIDD_STEP=$((PIDD_STEP+1))
echo "\
${PIDD_DOWN}
@ -790,7 +790,7 @@ ${PIDD_VERT} ${PIDD_STEP} ${*}
${PIDD___UP}"
}
pidd_write () {
pidd_write() {
pidd_write__file="${1}"
pidd_write__text="${2}"
if [ -n "${pidd_write__file}" ] ; then