CreateTorDirectory 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #!/usr/bin/env bash
  2. # shellcheck shell=bash
  3. # ``````````````````````````````````````````````````````````````````````````````
  4. # Function name: CreateTorDirectory()
  5. #
  6. # Description:
  7. # It creates tor processes data directory.
  8. #
  9. # Usage:
  10. # CreateTorDirectory
  11. #
  12. # Examples:
  13. # CreateTorDirectory
  14. #
  15. function CreateTorDirectory() {
  16. local _FUNCTION_ID="CreateTorDirectory"
  17. local _STATE=0
  18. # shellcheck disable=SC2154
  19. mkdir -m 0700 "$_proc_dir" > /dev/null 2>&1 ; _kstate="$?"
  20. if [[ $_kstate -eq 0 ]] ; then
  21. _logger "info" \
  22. "${_FUNCTION_ID}()" \
  23. "created tor process directory: ${_proc_dir}"
  24. # shellcheck disable=SC2154
  25. chown "${_arg_uname}" "${_proc_dir}" >>"$_log_stdout" 2>&1
  26. _kstate="$?"
  27. if [[ $_kstate -eq 0 ]] ; then
  28. _logger "info" \
  29. "${_FUNCTION_ID}()" \
  30. "changed owner properly to: '${_arg_uname}'"
  31. else
  32. _logger "stop" \
  33. "${_FUNCTION_ID}()" \
  34. "the owner could not be changed"
  35. fi
  36. else
  37. _logger "stop" \
  38. "${_FUNCTION_ID}()" \
  39. "not created tor process directory"
  40. fi
  41. unset _kstate
  42. return $_STATE
  43. }