v_change_sys_ip_status 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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_CONF/vesta.conf
  12. source $V_FUNC/shared.func
  13. source $V_FUNC/ip.func
  14. #----------------------------------------------------------#
  15. # Verifications #
  16. #----------------------------------------------------------#
  17. # Checking arg number
  18. check_args '2' "$#" 'ip ip_status'
  19. # Checking argument format
  20. format_validation 'ip' 'ip_status'
  21. # Checking system ip
  22. is_sys_ip_valid
  23. # Checking current status
  24. current_status=$(get_sys_ip_value '$STATUS')
  25. if [ "$ip_status" = "$current_status" ]; then
  26. echo "Error: status is already set"
  27. log_event 'debug' "$E_EXISTS $V_EVENT"
  28. exit $E_EXISTS
  29. fi
  30. # Parsing current ip usage
  31. web_domains=$(get_sys_ip_value '$U_WEB_DOMAINS')
  32. sys_user=$(get_sys_ip_value '$U_SYS_USERS')
  33. ip_owner=$(get_sys_ip_value '$OWNER')
  34. # Checking condition
  35. if [ "$web_domains" -ne '0' ] && [ "$sys_user" != "$ip_owner" ]; then
  36. echo "Error: ip is used"
  37. log_event 'debug' "$E_INUSE $V_EVENT"
  38. exit $E_INUSE
  39. fi
  40. #----------------------------------------------------------#
  41. # Action #
  42. #----------------------------------------------------------#
  43. # Changing ip name
  44. update_sys_ip_value '$STATUS' "$ip_status"
  45. #----------------------------------------------------------#
  46. # Vesta #
  47. #----------------------------------------------------------#
  48. # Logging
  49. log_event 'system' "$V_EVENT"
  50. exit