v_del_sys_ip 2.0 KB

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