v_change_sys_ip_status 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #!/bin/bash
  2. # info: changing ip status
  3. #----------------------------------------------------------#
  4. # Variable&Function #
  5. #----------------------------------------------------------#
  6. # Argument defenition
  7. ip="$1"
  8. ip_status="$2"
  9. # Importing variables
  10. source $VESTA/conf/vars.conf
  11. source $V_FUNC/shared_func.sh
  12. source $V_FUNC/ip_func.sh
  13. #----------------------------------------------------------#
  14. # Verifications #
  15. #----------------------------------------------------------#
  16. # Checking arg number
  17. check_args '2' "$#" 'ip ip_status'
  18. # Checking argument format
  19. format_validation 'ip' 'ip_status'
  20. # Checking system ip
  21. is_sys_ip_valid
  22. # Checking current status
  23. current_status=$(get_sys_ip_value '$STATUS')
  24. if [ "$ip_status" = "$current_status" ]; then
  25. echo "Error: status is already set"
  26. log_event 'debug' "$E_VALUE_EXIST $V_EVENT"
  27. exit $E_VALUE_EXIST
  28. fi
  29. # Parsing current ip usage
  30. web_domains=$(get_sys_ip_value '$U_WEB_DOMAINS')
  31. sys_user=$(get_sys_ip_value '$U_SYS_USERS')
  32. ip_owner=$(get_sys_ip_value '$OWNER')
  33. # Checking condition
  34. if [ "$web_domains" -ne '0' ] && [ "$sys_user" != "$ip_owner" ]; then
  35. echo "Error: ip is used"
  36. log_event 'debug' "$E_IP_USED $V_EVENT"
  37. exit $E_IP_USED
  38. fi
  39. #----------------------------------------------------------#
  40. # Action #
  41. #----------------------------------------------------------#
  42. # Changing ip name
  43. update_sys_ip_value '$STATUS' "$ip_status"
  44. #----------------------------------------------------------#
  45. # Vesta #
  46. #----------------------------------------------------------#
  47. # Logging
  48. log_event 'system' "$V_EVENT"
  49. exit $OK