v-get-user-value 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/bin/bash
  2. # info: get user value
  3. # options: USER KEY
  4. # labels: panel
  5. #
  6. # example: v-get-user-value admin FNAME
  7. #
  8. # The function for obtaining certain user's parameters.
  9. #----------------------------------------------------------#
  10. # Variable&Function #
  11. #----------------------------------------------------------#
  12. # Argument definition
  13. user=$1
  14. key=$(echo "$2"| tr '[:lower:]' '[:upper:]' | sed "s/^/$/")
  15. # Includes
  16. # shellcheck source=/usr/local/hestia/func/main.sh
  17. source $HESTIA/func/main.sh
  18. #----------------------------------------------------------#
  19. # Verifications #
  20. #----------------------------------------------------------#
  21. check_args '2' "$#" 'USER KEY'
  22. is_format_valid 'user'
  23. is_object_valid 'user' 'USER' "$user"
  24. #----------------------------------------------------------#
  25. # Action #
  26. #----------------------------------------------------------#
  27. # Checking key
  28. value=$(get_user_value "$key")
  29. # Printing value
  30. echo "$value"
  31. #----------------------------------------------------------#
  32. # Hestia #
  33. #----------------------------------------------------------#
  34. exit