36 lines
828 B
Bash
36 lines
828 B
Bash
#! /usr/bin/env bash
|
|
|
|
MAIN_BASH_FILE="$(realpath "${BASH_SOURCE[0]}")"
|
|
|
|
MAIN_BASH_ROOT="$(dirname "${MAIN_BASH_FILE}")"
|
|
|
|
function main_link_bashrc {
|
|
local file='/etc/bash.bashrc'
|
|
rm --force "${file}"
|
|
ln --symbolic "${MAIN_BASH_FILE}" "${file}"
|
|
}
|
|
|
|
# import modules
|
|
function main_import_modules {
|
|
local file="${1}"
|
|
if [ -f "${file}" ] ; then
|
|
local path="$(realpath "${file}")"
|
|
local root="$(dirname "${path}")"
|
|
local IFS=$'\n'
|
|
local modules=($(find "${root}" -type 'f' -name '*.sh' | sort))
|
|
local module
|
|
for module in "${modules[@]}" ; do
|
|
if [ "${module}" != "${path}" ] ; then
|
|
source "${module}"
|
|
fi
|
|
done
|
|
log_trace "${modules[@]}"
|
|
return 0
|
|
else
|
|
log_fatal "No file: ${file}"
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
# import modules
|
|
main_import_modules "${MAIN_BASH_FILE}"
|