v_change_web_domain_stats 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #!/bin/bash
  2. # info: change web domain statistics
  3. # options: user domain type
  4. #
  5. # The function of deleting site's system of statistics. Its type is
  6. # automatically chooses from client's configuration file.
  7. #----------------------------------------------------------#
  8. # Variable&Function #
  9. #----------------------------------------------------------#
  10. # Argument defenition
  11. user=$1
  12. domain=$(idn -t --quiet -u "$2" )
  13. type=$3
  14. # Includes
  15. source $VESTA/conf/vesta.conf
  16. source $VESTA/func/main.sh
  17. source $VESTA/func/domain.sh
  18. #----------------------------------------------------------#
  19. # Verifications #
  20. #----------------------------------------------------------#
  21. check_args '3' "$#" 'user domain type'
  22. validate_format 'user' 'domain'
  23. is_system_enabled "$WEB_SYSTEM"
  24. is_type_valid "$STATS_SYSTEM" "$type"
  25. is_object_valid 'user' 'USER' "$user"
  26. is_object_unsuspended 'user' 'USER' "$user"
  27. is_object_valid 'web' 'DOMAIN' "$domain"
  28. is_object_unsuspended 'web' 'DOMAIN' "$domain"
  29. is_object_value_exist 'web' 'DOMAIN' "$domain" '$STATS'
  30. #----------------------------------------------------------#
  31. # Action #
  32. #----------------------------------------------------------#
  33. # Defining statistic type
  34. get_domain_values 'web'
  35. # Comparing stats types
  36. if [ "$STATS" == $type ]; then
  37. log_event "$OK" "$EVENT"
  38. exit 0
  39. fi
  40. # Defining statistic dir
  41. stats_dir="$HOMEDIR/$user/web/$domain/stats"
  42. # Deleting dir content
  43. rm -rf $stats_dir/*
  44. # Deleting config
  45. rm -f $HOMEDIR/$user/conf/web/$STATS.$domain.conf
  46. # Preparing domain values for the template substitution
  47. upd_web_domain_values
  48. # Adding statistic config
  49. cat $WEBTPL/$type.tpl |\
  50. sed -e "s/%ip%/$ip/g" \
  51. -e "s/%web_port%/$WEB_PORT/g" \
  52. -e "s/%web_ssl_port%/$WEB_SSL_PORT/g" \
  53. -e "s/%proxy_port%/$PROXY_PORT/g" \
  54. -e "s/%proxy_ssl_port%/$PROXY_SSL_PORT/g" \
  55. -e "s/%domain_idn%/$domain_idn/g" \
  56. -e "s/%domain%/$domain/g" \
  57. -e "s/%user%/$user/g" \
  58. -e "s/%home%/${HOMEDIR////\/}/g" \
  59. -e "s/%alias%/${aliases//,/ }/g" \
  60. -e "s/%alias_idn%/${aliases_idn//,/ }/g" \
  61. > $HOMEDIR/$user/conf/web/$type.$domain.conf
  62. #----------------------------------------------------------#
  63. # Vesta #
  64. #----------------------------------------------------------#
  65. # Update config
  66. update_object_value 'web' 'DOMAIN' "$domain" '$STATS' "$type"
  67. # Logging
  68. log_history "$EVENT"
  69. log_event "$OK" "$EVENT"
  70. exit