v_delete_sys_ip 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. # Checking interface
  28. interface=$(get_current_interface)
  29. #----------------------------------------------------------#
  30. # Action #
  31. #----------------------------------------------------------#
  32. # Defining config paths
  33. conf='/etc/httpd/conf.d/vesta.conf'
  34. nconf='/etc/nginx/conf.d/vesta_ip.conf'
  35. iconf='/etc/sysconfig/network-scripts/ifcfg'
  36. rconf='/etc/httpd/conf.d/rpaf.conf'
  37. # Get ip owner
  38. user="$(get_sys_ip_value '$OWNER')"
  39. # Deleting interface
  40. /sbin/ifconfig "$interface" down
  41. # Deleting startup script
  42. rm -f $iconf-$interface
  43. # Deleting vesta ip
  44. rm -f $V_IPS/$ip
  45. # Importing main config
  46. source $V_CONF/vesta.conf
  47. # Deleting namehosting support
  48. namehost_ip_disable
  49. #----------------------------------------------------------#
  50. # Vesta #
  51. #----------------------------------------------------------#
  52. # Updating user conf
  53. if [ ! -z "$user" ]; then
  54. decrease_user_value "$user" '$IP_OWNED'
  55. fi
  56. # Adding task to the vesta pipe
  57. if [ "$web_restart" = 'yes' ]; then
  58. restart_schedule 'web'
  59. fi
  60. # Logging
  61. log_event 'system' "$V_EVENT"
  62. exit