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