sh/bash/main.sh

27 lines
611 B
Bash
Raw Normal View History

2023-05-09 20:09:01 +00:00
#! /usr/bin/env bash
2023-05-12 21:38:42 +00:00
MAIN_FILE="$(realpath "${BASH_SOURCE[0]}")"
MAIN_ROOT="$(dirname "${MAIN_FILE}")"
function link_bashrc {
local file='/etc/bash.bashrc'
rm --force "${file}"
ln --symbolic "${MAIN_FILE}" "${file}"
}
2023-05-09 20:09:01 +00:00
2023-05-14 12:46:23 +00:00
# import modules
2023-05-14 11:59:46 +00:00
function main_import_modules {
2023-05-14 12:46:23 +00:00
local IFS=$'\n'
local modules=($(find "${MAIN_ROOT}" -type 'f' -name '*.sh'))
local module
for module in "${modules[@]}" ; do
2023-05-12 21:38:42 +00:00
if [ "${module}" != "${MAIN_FILE}" ] ; then
2023-05-14 12:46:23 +00:00
echo
echo "${module}"
2023-05-09 20:15:40 +00:00
source "${module}"
fi
done
}
2023-05-09 20:09:01 +00:00
2023-05-14 12:46:23 +00:00
# import modules
2023-05-14 11:59:46 +00:00
main_import_modules