v_upd_sys_ip 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. # Importing main config
  40. source $V_CONF/vesta.conf
  41. # Defining config paths
  42. conf='/etc/httpd/conf.d/vesta.conf'
  43. nconf='/etc/nginx/conf.d/vesta_ip.conf'
  44. iconf='/etc/sysconfig/network-scripts/ifcfg'
  45. rconf='/etc/httpd/conf.d/rpaf.conf'
  46. # Comparing each ip
  47. for ip in $ip_list; do
  48. check_ip=$(echo $vesta_ip_list|grep -w "$ip")
  49. # Checking ip registered
  50. if [ -z "$check_ip" ]; then
  51. # Parsing additional params
  52. iface=$(/sbin/ifconfig|grep -B1 -w "$ip"|head -n 1|cut -f 1 -d ' ')
  53. interface=$(echo "$iface" | cut -f 1 -d :)
  54. mask=$(/sbin/ifconfig |grep -w "$ip"|awk -F "Mask:" '{print $2}')
  55. # Adding vesta ip
  56. ip_add_vesta
  57. # Adding namehosting support
  58. namehost_ip_support
  59. # Creating startup script
  60. if [ ! -e "$iconf-$iface" ]; then
  61. ip_add_startup
  62. fi
  63. fi
  64. # NOTE: later we'll make revers comparation
  65. done
  66. #----------------------------------------------------------#
  67. # Vesta #
  68. #----------------------------------------------------------#
  69. # Updating user conf
  70. if [ ! -z "$owner" ]; then
  71. user="$owner"
  72. increase_user_value "$user" '$IP_OWNED'
  73. fi
  74. # Adding task to the vesta pipe
  75. if [ "$web_restart" = 'yes' ]; then
  76. restart_schedule 'web'
  77. fi
  78. # Logging
  79. log_event 'system' "$V_EVENT"
  80. exit