2024-11-15 15:43:48 +00:00
|
|
|
[ "${ENV}" ] || export ENV="/etc/shell/main.sh"
|
|
|
|
|
2024-11-15 15:26:54 +00:00
|
|
|
main_env_root() {
|
|
|
|
dirname "${ENV}"
|
2024-11-13 11:03:00 +00:00
|
|
|
}
|
2023-05-12 21:38:42 +00:00
|
|
|
|
2024-11-12 06:44:21 +00:00
|
|
|
main_link_bashrc() {
|
2024-11-12 09:14:08 +00:00
|
|
|
local file="/etc/bash.bashrc"
|
|
|
|
rm --force "${file}"
|
2024-11-13 08:41:47 +00:00
|
|
|
ln --symbolic "${MAIN_USERS_FILE}" "${file}"
|
2023-05-12 21:38:42 +00:00
|
|
|
}
|
2023-05-09 20:09:01 +00:00
|
|
|
|
2024-11-15 18:02:22 +00:00
|
|
|
main_import_directory() {
|
|
|
|
local path="${1}"
|
|
|
|
if [ -d "${path}" ]; then
|
|
|
|
local count ifs module modules
|
|
|
|
modules="$(find "${path}" -type "f" -name "*.sh" -printf "%P
|
2024-11-13 11:50:49 +00:00
|
|
|
" | sort)"
|
2024-11-13 11:41:37 +00:00
|
|
|
ifs="${IFS}"
|
|
|
|
IFS="
|
|
|
|
"
|
2024-11-13 13:55:20 +00:00
|
|
|
count=0
|
|
|
|
echo
|
2024-11-15 18:02:22 +00:00
|
|
|
echo ". ${path}"
|
2024-11-13 11:41:37 +00:00
|
|
|
for module in ${modules}; do
|
2024-11-13 13:55:20 +00:00
|
|
|
count=$((count + 1))
|
|
|
|
printf "%02d" "${count}"
|
|
|
|
echo " ${module%.sh}"
|
2024-11-15 18:02:22 +00:00
|
|
|
module="${path}/${module}"
|
|
|
|
if [ "${module}" != "${ENV}" ]; then
|
2024-11-12 09:14:08 +00:00
|
|
|
. "${module}"
|
|
|
|
fi
|
|
|
|
done
|
2024-11-13 11:41:37 +00:00
|
|
|
IFS="${ifs}"
|
2024-11-12 09:14:08 +00:00
|
|
|
else
|
2024-11-15 18:02:22 +00:00
|
|
|
echo "Not a directory: ${path}"
|
2024-11-12 09:14:08 +00:00
|
|
|
return 1
|
|
|
|
fi
|
2023-05-09 20:15:40 +00:00
|
|
|
}
|
2023-05-09 20:09:01 +00:00
|
|
|
|
2024-11-15 18:02:22 +00:00
|
|
|
main_import_file() {
|
|
|
|
local path="${1}"
|
|
|
|
if [ -f "${path}" ]; then
|
|
|
|
main_import_directory "$(dirname "${path}")"
|
|
|
|
else
|
|
|
|
echo "Not a file: ${path}"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
main_import_file "${ENV}"
|
|
|
|
|
|
|
|
main_import_directory ~/shell
|