mirror of
https://github.com/myvesta/vesta
synced 2025-08-19 21:04:07 -07:00
replaced underscore with dash in api syscalls
This commit is contained in:
parent
7ed705cee7
commit
b6b7eacadb
283 changed files with 438 additions and 412 deletions
76
bin/v-update-web-domain-traff
Executable file
76
bin/v-update-web-domain-traff
Executable file
|
@ -0,0 +1,76 @@
|
|||
#!/bin/bash
|
||||
# info: update domain bandwidth usage
|
||||
# options: user domain
|
||||
#
|
||||
# The function recalculates bandwidth usage for speciefic domain.
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
user=$1
|
||||
domain=$(idn -t --quiet -u "$2" )
|
||||
domain_idn=$(idn -t --quiet -a "$domain")
|
||||
|
||||
# Includes
|
||||
source $VESTA/conf/vesta.conf
|
||||
source $VESTA/func/main.sh
|
||||
source $VESTA/func/domain.sh
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
check_args '2' "$#" 'user domain'
|
||||
validate_format 'user' 'domain'
|
||||
is_system_enabled "$WEB_SYSTEM"
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
is_object_unsuspended 'user' 'USER' "$user"
|
||||
is_object_valid 'web' 'DOMAIN' "$domain"
|
||||
is_object_unsuspended 'web' 'DOMAIN' "$domain"
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Defining log file
|
||||
log_file="/var/log/httpd/domains/$domain.bytes"
|
||||
|
||||
# Defining bytes
|
||||
bytes=0
|
||||
|
||||
# Parsing log
|
||||
while read line; do
|
||||
if [[ '-' != "$line" ]] && [[ 0 -lt "$line" ]]; then
|
||||
bytes=$(($bytes + $line))
|
||||
fi
|
||||
done < $log_file
|
||||
|
||||
# Converting to Mb
|
||||
mb=$(echo "$bytes / 1024 / 1024"|bc)
|
||||
|
||||
# Nulling log
|
||||
echo > $log_file
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Parsing old value
|
||||
get_domain_values 'web'
|
||||
|
||||
# Defining new value
|
||||
bandwidth=$((U_BANDWIDTH + mb))
|
||||
|
||||
# Updating bandwidth value in config
|
||||
update_object_value 'web' 'DOMAIN' "$domain" '$U_BANDWIDTH' "$bandwidth"
|
||||
|
||||
# Logging
|
||||
log_event "$OK" "$EVENT"
|
||||
|
||||
exit
|
Loading…
Add table
Add a link
Reference in a new issue