mirror of
https://github.com/serghey-rodin/vesta.git
synced 2025-08-14 02:28:03 -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
93
bin/v-update-user-stats
Executable file
93
bin/v-update-user-stats
Executable file
|
@ -0,0 +1,93 @@
|
|||
#!/bin/bash
|
||||
# info: update user statistics
|
||||
# options: user
|
||||
#
|
||||
# Function logs user parameters into statistics database.
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
user=$1
|
||||
|
||||
# Importing system enviroment as we run this script
|
||||
# mostly by cron wich not read it by itself
|
||||
source /etc/profile
|
||||
|
||||
# Includes
|
||||
source $VESTA/conf/vesta.conf
|
||||
source $VESTA/func/main.sh
|
||||
source $VESTA/func/domain.sh
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Verifications #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
check_args '0' "$#" 'user'
|
||||
if [ ! -z "$user" ]; then
|
||||
validate_format 'user'
|
||||
is_object_valid 'user' 'USER' "$user"
|
||||
fi
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Creating user_list
|
||||
if [ -z "$user" ]; then
|
||||
user_list=$(ls $VESTA/data/users)
|
||||
else
|
||||
user_list="$user"
|
||||
fi
|
||||
|
||||
# Updating user stats
|
||||
for user in $user_list; do
|
||||
USER_DATA=$VESTA/data/users/$user
|
||||
source $USER_DATA/user.conf
|
||||
DATE=$(date -d "$(date +'%m/01' -d "+ 1 month") -1day" +%F)
|
||||
|
||||
# Compiling report string
|
||||
s="DATE='$DATE' TIME='$TIME' PACKAGE='$PACKAGE' IP_OWNED='$IP_OWNED'"
|
||||
s="$s DISK_QUOTA='$DISK_QUOTA' U_DISK='$U_DISK' U_DISK_DIRS='$U_DISK_DIRS'"
|
||||
s="$s U_DISK_WEB='$U_DISK_WEB' U_DISK_MAIL='$U_DISK_MAIL'"
|
||||
s="$s U_DISK_DB='$U_DISK_DB' BANDWIDTH='$BANDWIDTH'"
|
||||
s="$s U_BANDWIDTH='$U_BANDWIDTH' U_WEB_DOMAINS='$U_WEB_DOMAINS'"
|
||||
s="$s U_WEB_SSL='$U_WEB_SSL' U_WEB_ALIASES='$U_WEB_ALIASES'"
|
||||
s="$s U_DNS_DOMAINS='$U_DNS_DOMAINS' U_DNS_RECORDS='$U_DNS_RECORDS'"
|
||||
s="$s U_MAIL_DOMAINS='$U_MAIL_DOMAINS' U_MAIL_DKIM='$U_MAIL_DKIM'"
|
||||
s="$s U_MAIL_ACCOUNTS='$U_MAIL_ACCOUNTS' U_DATABASES='$U_DATABASES'"
|
||||
s="$s U_CRON_JOBS='$U_CRON_JOBS' U_BACKUPS='$U_BACKUPS'"
|
||||
|
||||
# Updating user stats log
|
||||
stats="$USER_DATA/stats.log"
|
||||
if [ -e "$stats" ]; then
|
||||
# Checking dublicates
|
||||
check_month=$(grep -n "DATE='$DATE'" $stats|cut -f 1 -d :)
|
||||
if [ -z "$check_month" ]; then
|
||||
# Updating as there no dublicates
|
||||
echo "$s" >> $stats
|
||||
chmod 660 $stats
|
||||
else
|
||||
# Replacing string with new data
|
||||
sed -i "$check_month s/.*/$s/" $stats
|
||||
fi
|
||||
else
|
||||
# Creating stats log
|
||||
echo "$s" >$stats
|
||||
chmod 660 $stats
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Logging
|
||||
log_event "$OK" "$EVENT"
|
||||
|
||||
exit
|
Loading…
Add table
Add a link
Reference in a new issue