v_delete_user_ips 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #!/bin/bash
  2. # info: delete user ips
  3. # options: user
  4. #
  5. # The function deletes all user's ip addresses.
  6. #----------------------------------------------------------#
  7. # Variable&Function #
  8. #----------------------------------------------------------#
  9. # Argument defenition
  10. user=$1
  11. # Importing variables
  12. source $VESTA/conf/vars.conf
  13. source $V_CONF/vesta.conf
  14. source $V_FUNC/shared.func
  15. source $V_FUNC/ip.func
  16. #----------------------------------------------------------#
  17. # Verifications #
  18. #----------------------------------------------------------#
  19. # Checking arg number
  20. check_args '1' "$#" 'user'
  21. # Checking argument format
  22. format_validation 'user'
  23. # Checking user
  24. is_user_valid
  25. # Checking user is active
  26. is_user_suspended
  27. # Checking user vesta
  28. if [ "$user" = 'vesta' ]; then
  29. exit
  30. fi
  31. #----------------------------------------------------------#
  32. # Action #
  33. #----------------------------------------------------------#
  34. # Parsing user ips
  35. ip_list=$(grep -H "OWNER='$user'" $V_IPS/* | cut -f 1 -d:)
  36. for ip in $ip_list; do
  37. ip=$(basename $ip)
  38. # Checking webdomains and users
  39. is_ip_key_empty '$U_WEB_DOMAINS'
  40. is_ip_key_empty '$U_SYS_USERS'
  41. # Assig ip to main account
  42. update_sys_ip_value '$OWNER' 'vesta'
  43. update_sys_ip_value '$STATUS' 'exclusive'
  44. done
  45. #----------------------------------------------------------#
  46. # Vesta #
  47. #----------------------------------------------------------#
  48. # Logging
  49. log_event 'system' "$V_EVENT"
  50. exit