v-change-sys-ip-status 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. validate_format 'ip' 'ip_status'
  21. is_ip_valid
  22. if [ "$ip_status" = "$(get_ip_value '$STATUS')" ]; then
  23. echo "Error: status $ip_status is already set"
  24. log_event "$E_EXISTS" "$EVENT"
  25. exit $E_EXISTS
  26. fi
  27. web_domains=$(get_ip_value '$U_WEB_DOMAINS')
  28. sys_user=$(get_ip_value '$U_SYS_USERS')
  29. ip_owner=$(get_ip_value '$OWNER')
  30. if [ "$web_domains" -ne '0' ] && [ "$sys_user" != "$ip_owner" ]; then
  31. echo "Error: ip $ip is used"
  32. log_event "$E_INUSE" "$EVENT"
  33. exit $E_INUSE
  34. fi
  35. #----------------------------------------------------------#
  36. # Action #
  37. #----------------------------------------------------------#
  38. # Changing ip name
  39. update_ip_value '$STATUS' "$ip_status"
  40. #----------------------------------------------------------#
  41. # Vesta #
  42. #----------------------------------------------------------#
  43. # Logging
  44. log_history "changed $ip status to $ip_status" '' 'admin'
  45. log_event "$OK" "$EVENT"
  46. exit