v-change-sys-ip-status 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/bin/bash
  2. # info: change ip status
  3. # options: IP IP_STATUS
  4. #
  5. # The function of changing an ip address's status.
  6. #----------------------------------------------------------#
  7. # Variable&Function #
  8. #----------------------------------------------------------#
  9. # Argument definition
  10. ip=$1
  11. ip_status=$2
  12. # Includes
  13. source $VESTA/func/main.sh
  14. source $VESTA/func/ip.sh
  15. source $VESTA/conf/vesta.conf
  16. #----------------------------------------------------------#
  17. # Verifications #
  18. #----------------------------------------------------------#
  19. check_args '2' "$#" 'IP IP_STATUS'
  20. is_format_valid 'ip' 'ip_status'
  21. is_ip_valid "$ip"
  22. if [ "$ip_status" = "$(get_ip_value '$STATUS')" ]; then
  23. check_result "$E_EXISTS" "status $ip_status is already set"
  24. fi
  25. web_domains=$(get_ip_value '$U_WEB_DOMAINS')
  26. sys_user=$(get_ip_value '$U_SYS_USERS')
  27. ip_owner=$(get_ip_value '$OWNER')
  28. if [ "$web_domains" -ne '0' ] && [ "$sys_user" != "$ip_owner" ]; then
  29. check_result "$E_INUSE" "ip $ip is used"
  30. fi
  31. #----------------------------------------------------------#
  32. # Action #
  33. #----------------------------------------------------------#
  34. # Changing ip name
  35. update_ip_value '$STATUS' "$ip_status"
  36. #----------------------------------------------------------#
  37. # Vesta #
  38. #----------------------------------------------------------#
  39. # Logging
  40. log_history "changed $ip status to $ip_status" '' 'admin'
  41. log_event "$OK" "$ARGUMENTS"
  42. exit