2023-05-09 22:09:01 +02:00
|
|
|
#! /usr/bin/env bash
|
2023-05-15 09:19:43 +02:00
|
|
|
|
|
|
|
MAIN_BASH_FILE="$(realpath "${BASH_SOURCE[0]}")"
|
|
|
|
|
|
|
|
MAIN_BASH_ROOT="$(dirname "${MAIN_BASH_FILE}")"
|
2023-05-12 23:38:42 +02:00
|
|
|
|
2023-05-15 12:07:16 +02:00
|
|
|
function main_link_bashrc {
|
2023-05-12 23:38:42 +02:00
|
|
|
local file='/etc/bash.bashrc'
|
|
|
|
rm --force "${file}"
|
2023-05-15 09:19:43 +02:00
|
|
|
ln --symbolic "${MAIN_BASH_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
|
2023-05-14 13:59:46 +02:00
|
|
|
function main_import_modules {
|
2023-05-15 18:41:02 +02:00
|
|
|
local file="${1}"
|
|
|
|
if [ -f "${file}" ] ; then
|
2023-05-15 18:56:12 +02:00
|
|
|
local path="$(realpath "${file}")"
|
|
|
|
local root="$(dirname "${path}")"
|
2023-05-14 14:46:23 +02:00
|
|
|
local IFS=$'\n'
|
2023-06-19 15:08:06 +02:00
|
|
|
local modules=($(find "${root}" -type 'f' -name '*.sh' | sort))
|
2023-05-14 14:46:23 +02:00
|
|
|
local module
|
|
|
|
for module in "${modules[@]}" ; do
|
2023-05-15 18:59:04 +02:00
|
|
|
if [ "${module}" != "${path}" ] ; then
|
2023-05-09 22:15:40 +02:00
|
|
|
source "${module}"
|
|
|
|
fi
|
|
|
|
done
|
2023-05-14 23:31:26 +02:00
|
|
|
log_trace "${modules[@]}"
|
2023-06-19 15:16:05 +02:00
|
|
|
return 0
|
2023-05-15 09:19:43 +02:00
|
|
|
else
|
2023-05-15 18:41:02 +02:00
|
|
|
log_fatal "No file: ${file}"
|
2023-06-19 15:16:05 +02:00
|
|
|
return 1
|
2023-05-15 09:19:43 +02:00
|
|
|
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
|
2023-05-15 18:41:02 +02:00
|
|
|
main_import_modules "${MAIN_BASH_FILE}"
|