v_delete_sys_ip 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #!/bin/bash
  2. # info: delete system ip
  3. # options: ip
  4. #
  5. # The function for deleting a system ip. It does not allow to delete first ip
  6. # on interface and do not allow to delete ip which is used by a web domain.
  7. #----------------------------------------------------------#
  8. # Variable&Function #
  9. #----------------------------------------------------------#
  10. # Argument defenition
  11. ip=$1
  12. # Importing variables
  13. source $VESTA/conf/vars.conf
  14. source $V_CONF/vesta.conf
  15. source $V_FUNC/shared.func
  16. source $V_FUNC/ip.func
  17. source $V_FUNC/domain.func
  18. #----------------------------------------------------------#
  19. # Verifications #
  20. #----------------------------------------------------------#
  21. # Checking arg number
  22. check_args '1' "$#" 'ip'
  23. # Checking argument format
  24. format_validation 'ip'
  25. # Checking system ip
  26. is_sys_ip_valid "$ip"
  27. # Checking webdomains on ip
  28. is_ip_key_empty '$U_WEB_DOMAINS'
  29. # Checking users on ip
  30. is_ip_key_empty '$U_SYS_USERS'
  31. # Checking interface
  32. interface=$(get_current_interface)
  33. #----------------------------------------------------------#
  34. # Action #
  35. #----------------------------------------------------------#
  36. # Defining config paths
  37. conf='/etc/httpd/conf.d/vesta.conf'
  38. nconf='/etc/nginx/conf.d/vesta_ip.conf'
  39. iconf='/etc/sysconfig/network-scripts/ifcfg'
  40. rconf='/etc/httpd/conf.d/rpaf.conf'
  41. # Get ip owner
  42. user="$(get_sys_ip_value '$OWNER')"
  43. # Deleting interface
  44. /sbin/ifconfig "$interface" down
  45. # Deleting startup script
  46. rm -f $iconf-$interface
  47. # Deleting vesta ip
  48. rm -f $V_IPS/$ip
  49. # Importing main config
  50. source $V_CONF/vesta.conf
  51. # Deleting namehosting support
  52. namehost_ip_disable
  53. #----------------------------------------------------------#
  54. # Vesta #
  55. #----------------------------------------------------------#
  56. # Updating user conf
  57. if [ ! -z "$user" ]; then
  58. decrease_user_value "$user" '$IP_OWNED'
  59. fi
  60. # Adding task to the vesta pipe
  61. if [ "$web_restart" = 'yes' ]; then
  62. restart_schedule 'web'
  63. fi
  64. # Logging
  65. log_event 'system' "$V_EVENT"
  66. exit