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