v_del_sys_ip 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #!/bin/bash
  2. # info: deleting system ip
  3. #----------------------------------------------------------#
  4. # Variable&Function #
  5. #----------------------------------------------------------#
  6. # Argument defenition
  7. ip=$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. source $V_FUNC/domain.func
  14. #----------------------------------------------------------#
  15. # Verifications #
  16. #----------------------------------------------------------#
  17. # Checking arg number
  18. check_args '1' "$#" 'ip'
  19. # Checking argument format
  20. format_validation 'ip'
  21. # Checking system ip
  22. is_sys_ip_valid "$ip"
  23. # Checking webdomains on ip
  24. is_ip_key_empty '$U_WEB_DOMAINS'
  25. # Checking users on ip
  26. is_ip_key_empty '$U_SYS_USERS'
  27. # We do not check ownership if
  28. # no one actualy use this ip
  29. # Checking interface
  30. interface=$(get_current_interface)
  31. #----------------------------------------------------------#
  32. # Action #
  33. #----------------------------------------------------------#
  34. # Defining config paths
  35. conf='/etc/httpd/conf.d/vesta.conf'
  36. nconf='/etc/nginx/conf.d/vesta_ip.conf'
  37. iconf='/etc/sysconfig/network-scripts/ifcfg'
  38. rconf='/etc/httpd/conf.d/rpaf.conf'
  39. # Get ip owner
  40. user="$(get_sys_ip_value '$OWNER')"
  41. # Deleting interface
  42. /sbin/ifconfig "$interface" down
  43. # Deleting startup script
  44. rm -f $iconf-$interface
  45. # Deleting vesta ip
  46. rm -f $V_IPS/$ip
  47. # Importing main config
  48. source $V_CONF/vesta.conf
  49. # Deleting namehosting support
  50. namehost_ip_disable
  51. #----------------------------------------------------------#
  52. # Vesta #
  53. #----------------------------------------------------------#
  54. # Updating user conf
  55. if [ ! -z "$user" ]; then
  56. decrease_user_value "$user" '$IP_OWNED'
  57. fi
  58. # Adding task to the vesta pipe
  59. if [ "$web_restart" = 'yes' ]; then
  60. restart_schedule 'web'
  61. fi
  62. # Logging
  63. log_event 'system' "$V_EVENT"
  64. exit