2023-05-09 22:09:01 +02:00
|
|
|
#! /usr/bin/env bash
|
2023-05-15 09:19:43 +02:00
|
|
|
|
2024-11-13 11:21:37 +01:00
|
|
|
MAIN_USERS_FILE="$(realpath --canonicalize-existing "${BASH_SOURCE[0]}")"
|
2023-05-15 09:19:43 +02:00
|
|
|
|
2024-11-13 12:03:00 +01:00
|
|
|
main_get_root() {
|
|
|
|
dirname "${MAIN_USERS_FILE}"
|
|
|
|
}
|
2023-05-12 23:38:42 +02:00
|
|
|
|
2024-11-12 07:44:21 +01:00
|
|
|
main_link_bashrc() {
|
2024-11-12 10:14:08 +01:00
|
|
|
local file="/etc/bash.bashrc"
|
|
|
|
rm --force "${file}"
|
2024-11-13 09:41:47 +01:00
|
|
|
ln --symbolic "${MAIN_USERS_FILE}" "${file}"
|
2023-05-12 23:38:42 +02:00
|
|
|
}
|
2023-05-09 22:09:01 +02:00
|
|
|
|
2023-05-14 14:46:23 +02:00
|
|
|
# import modules
|
2024-11-12 07:44:21 +01:00
|
|
|
main_import_modules() {
|
2024-11-12 10:14:08 +01:00
|
|
|
local file="${1}"
|
2024-11-13 09:43:27 +01:00
|
|
|
if [ -f "${file}" ]; then
|
2024-11-13 12:41:37 +01:00
|
|
|
local ifs module modules path root
|
|
|
|
path="$(realpath --canonicalize-existing "${file}")"
|
2024-11-13 11:57:56 +01:00
|
|
|
root="$(dirname "${path}")"
|
2024-11-13 12:50:49 +01:00
|
|
|
modules="$(find "${root}" -type "f" -name "*.sh" -printf "%P
|
|
|
|
" | sort)"
|
2024-11-13 12:41:37 +01:00
|
|
|
ifs="${IFS}"
|
|
|
|
IFS="
|
|
|
|
"
|
|
|
|
for module in ${modules}; do
|
2024-11-13 12:50:49 +01:00
|
|
|
module="${root}/${module}"
|
2024-11-13 09:43:27 +01:00
|
|
|
if [ "${module}" != "${path}" ]; then
|
2024-11-12 10:14:08 +01:00
|
|
|
. "${module}"
|
|
|
|
fi
|
|
|
|
done
|
2024-11-13 12:41:37 +01:00
|
|
|
IFS="${ifs}"
|
2024-11-13 12:55:14 +01:00
|
|
|
log_info
|
|
|
|
log_info "${root}"
|
|
|
|
log_info "${modules}"
|
2024-11-12 10:14:08 +01:00
|
|
|
return 0
|
|
|
|
else
|
|
|
|
log_fatal "No file: ${file}"
|
|
|
|
return 1
|
|
|
|
fi
|
2023-05-09 22:15:40 +02:00
|
|
|
}
|
2023-05-09 22:09:01 +02:00
|
|
|
|
2023-05-14 14:46:23 +02:00
|
|
|
# import modules
|
2024-11-13 09:41:47 +01:00
|
|
|
main_import_modules "${MAIN_USERS_FILE}"
|