v-change-web-domain-stats 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. domain_idn=$(idn -t --quiet -a "$domain")
  14. type=$3
  15. # Includes
  16. source $VESTA/conf/vesta.conf
  17. source $VESTA/func/main.sh
  18. source $VESTA/func/domain.sh
  19. #----------------------------------------------------------#
  20. # Verifications #
  21. #----------------------------------------------------------#
  22. check_args '3' "$#" 'user domain type'
  23. validate_format 'user' 'domain'
  24. is_system_enabled "$WEB_SYSTEM"
  25. is_type_valid "$STATS_SYSTEM" "$type"
  26. is_object_valid 'user' 'USER' "$user"
  27. is_object_unsuspended 'user' 'USER' "$user"
  28. is_object_valid 'web' 'DOMAIN' "$domain"
  29. is_object_unsuspended 'web' 'DOMAIN' "$domain"
  30. is_object_value_exist 'web' 'DOMAIN' "$domain" '$STATS'
  31. #----------------------------------------------------------#
  32. # Action #
  33. #----------------------------------------------------------#
  34. # Defining statistic type
  35. get_domain_values 'web'
  36. # Comparing stats types
  37. if [ "$STATS" == $type ]; then
  38. log_event "$OK" "$EVENT"
  39. exit 0
  40. fi
  41. # Defining statistic dir
  42. stats_dir="$HOMEDIR/$user/web/$domain/stats"
  43. # Deleting dir content
  44. rm -rf $stats_dir/*
  45. # Deleting config
  46. rm -f $HOMEDIR/$user/conf/web/$STATS.$domain.conf
  47. # Preparing domain values for the template substitution
  48. upd_web_domain_values
  49. # Adding statistic config
  50. cat $WEBTPL/$type.tpl |\
  51. sed -e "s/%ip%/$ip/g" \
  52. -e "s/%web_port%/$WEB_PORT/g" \
  53. -e "s/%web_ssl_port%/$WEB_SSL_PORT/g" \
  54. -e "s/%proxy_port%/$PROXY_PORT/g" \
  55. -e "s/%proxy_ssl_port%/$PROXY_SSL_PORT/g" \
  56. -e "s/%domain_idn%/$domain_idn/g" \
  57. -e "s/%domain%/$domain/g" \
  58. -e "s/%user%/$user/g" \
  59. -e "s/%home%/${HOMEDIR////\/}/g" \
  60. -e "s/%alias%/${aliases//,/ }/g" \
  61. -e "s/%alias_idn%/${aliases_idn//,/ }/g" \
  62. > $HOMEDIR/$user/conf/web/$type.$domain.conf
  63. #----------------------------------------------------------#
  64. # Vesta #
  65. #----------------------------------------------------------#
  66. # Update config
  67. update_object_value 'web' 'DOMAIN' "$domain" '$STATS' "$type"
  68. # Logging
  69. log_history "changed web log stats for $domain to $type"
  70. log_event "$OK" "$EVENT"
  71. # Build stats
  72. exec $BIN/v-update-web-domain-stat $user $domain
  73. exit