import 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/usr/bin/env bash
  2. # shellcheck shell=bash
  3. ################################################################################
  4. #################### External variables/functions and libs #####################
  5. ################################################################################
  6. # Set of external files with variables, functions and other. The configuration
  7. # of each of them is in lib directory. The fd_stack array stores the names of
  8. # attached files. If you create a new file with some interesting function,
  9. # name it appropriately and insert to the array.
  10. # Example:
  11. # - lib/kill_process - file with your function
  12. # - _fd_stack=("kill_process") - says to include this file in the script
  13. readonly _fd_stack=("CheckConn" "CreateTorDirectory" "CreateTorProcess" \
  14. "DestroyProcess" "GetTorProcess" "CheckProxyProcess" \
  15. "CreateProxyProcess" "CreateWebProxyProcess" "OutputGen")
  16. if [[ "${#_fd_stack[@]}" -ne 0 ]] ; then
  17. for _fd in "${_fd_stack[@]}" ; do
  18. # shellcheck disable=SC2154
  19. _fd_full_path="${_lib}/${_fd}"
  20. if [[ ! -z "$_fd_full_path" ]] && [[ -e "$_fd_full_path" ]] ; then
  21. # If the file exists is loaded.
  22. # shellcheck disable=SC1090
  23. source "$_fd_full_path"
  24. elif [[ -z "$_fd_full_path" ]] ; then
  25. printf "incorrectly loaded '%s' file (incorrect filename)" "$_fd_full_path"
  26. _exit_ "1"
  27. else
  28. printf "incorrectly loaded '%s' file (does not exist?)" "$_fd_full_path"
  29. _exit_ "1"
  30. fi
  31. done
  32. fi