v_update_sys_ip 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #!/bin/bash
  2. # info: adding system ip
  3. #----------------------------------------------------------#
  4. # Variable&Function #
  5. #----------------------------------------------------------#
  6. # Argument defenition
  7. owner=$1
  8. ip_status=$2
  9. owner=${3-vesta}
  10. ip_status=${4-shared}
  11. # Importing variables
  12. source $VESTA/conf/vars.conf
  13. source $V_CONF/vesta.conf # include for internal func
  14. source $V_FUNC/shared.func
  15. source $V_FUNC/ip.func
  16. source $V_FUNC/domain.func
  17. #----------------------------------------------------------#
  18. # Verifications #
  19. #----------------------------------------------------------#
  20. # Checking arg number
  21. check_args '0' "$#" '[owner] [ip_status]'
  22. # Checking owner
  23. if [ ! -z "$owner" ]; then
  24. format_validation 'owner'
  25. is_user_valid "$owner"
  26. fi
  27. # Checking ip_status
  28. if [ ! -z "$ip_status" ]; then
  29. format_validation 'ip_status'
  30. fi
  31. #----------------------------------------------------------#
  32. # Action #
  33. #----------------------------------------------------------#
  34. # Get ip list
  35. ip_list=$(/sbin/ifconfig |grep 'inet addr:'|cut -f 2 -d :|\
  36. cut -f 1 -d ' '| grep -v 127.0.0.1)
  37. # Get vesta registered ip list
  38. vesta_ip_list=$(ls $V_IPS/)
  39. # Defining config paths
  40. conf='/etc/httpd/conf.d/vesta.conf'
  41. nconf='/etc/nginx/conf.d/vesta_ip.conf'
  42. iconf='/etc/sysconfig/network-scripts/ifcfg'
  43. rconf='/etc/httpd/conf.d/rpaf.conf'
  44. # Comparing each ip
  45. for ip in $ip_list; do
  46. check_ip=$(echo $vesta_ip_list|grep -w "$ip")
  47. # Checking ip registered
  48. if [ -z "$check_ip" ]; then
  49. # Parsing additional params
  50. iface=$(/sbin/ifconfig|grep -B1 -w "$ip"|head -n 1|cut -f 1 -d ' ')
  51. interface=$(echo "$iface" | cut -f 1 -d :)
  52. mask=$(/sbin/ifconfig |grep -w "$ip"|awk -F "Mask:" '{print $2}')
  53. # Adding vesta ip
  54. ip_add_vesta
  55. # Adding namehosting support
  56. namehost_ip_support
  57. # Creating startup script
  58. if [ ! -e "$iconf-$iface" ]; then
  59. ip_add_startup
  60. fi
  61. fi
  62. # NOTE: later we'll make revers comparation
  63. done
  64. #----------------------------------------------------------#
  65. # Vesta #
  66. #----------------------------------------------------------#
  67. # Updating user conf
  68. if [ ! -z "$owner" ]; then
  69. user="$owner"
  70. increase_user_value "$user" '$IP_OWNED'
  71. fi
  72. # Adding task to the vesta pipe
  73. if [ "$web_restart" = 'yes' ]; then
  74. restart_schedule 'web'
  75. fi
  76. # Logging
  77. log_event 'system' "$V_EVENT"
  78. exit