v_delete_user_ips 1.6 KB

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