v-change-sys-ipv6-status 1.6 KB

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