v-delete-user-ips 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #!/bin/bash
  2. # info: delete user ips
  3. # options: USER
  4. # labels: panel
  5. #
  6. # example: v-delete-user-ips admin
  7. #
  8. # The function deletes all user's ip addresses.
  9. #----------------------------------------------------------#
  10. # Variable&Function #
  11. #----------------------------------------------------------#
  12. # Argument definition
  13. user=$1
  14. # Includes
  15. source $HESTIA/func/main.sh
  16. source $HESTIA/func/ip.sh
  17. source $HESTIA/conf/hestia.conf
  18. #----------------------------------------------------------#
  19. # Verifications #
  20. #----------------------------------------------------------#
  21. check_args '1' "$#" 'USER'
  22. is_format_valid 'user'
  23. is_object_valid 'user' 'USER' "$user"
  24. is_object_unsuspended 'user' 'USER' "$user"
  25. if [ "$user" = 'admin' ]; then
  26. exit
  27. fi
  28. # Perform verification if read-only mode is enabled
  29. check_hestia_demo_mode
  30. #----------------------------------------------------------#
  31. # Action #
  32. #----------------------------------------------------------#
  33. # Parsing user ips
  34. ip_list=$(grep -H "OWNER='$user'" $HESTIA/data/ips/* | cut -f 1 -d:)
  35. for ip in $ip_list; do
  36. ip=$(basename $ip)
  37. # Checking webdomains and users
  38. is_ip_key_empty '$U_WEB_DOMAINS'
  39. is_ip_key_empty '$U_SYS_USERS'
  40. # Assig ip to main account
  41. update_ip_value '$OWNER' 'admin'
  42. update_ip_value '$STATUS' 'dedicated'
  43. increase_user_value 'admin' '$IP_OWNED'
  44. increase_user_value 'admin' '$IP_AVAIL'
  45. done
  46. #----------------------------------------------------------#
  47. # Hestia #
  48. #----------------------------------------------------------#
  49. # Logging
  50. log_event "$OK" "$ARGUMENTS"
  51. exit