1+ #! /bin/bash
2+ # info: delete user usage statistics
3+ # options: USER DOMAIN
4+ # labels: panel
5+ #
6+ # example: v-delete-user-stats user
7+ # example: v-delete-user-stats admin overall
8+ #
9+ # The function deletes user statistics data.
10+
11+
12+ # ----------------------------------------------------------#
13+ # Variable&Function #
14+ # ----------------------------------------------------------#
15+
16+ # Argument definition
17+ user=$1
18+ mode=$2
19+
20+ # Includes
21+ # shellcheck source=/usr/local/hestia/func/main.sh
22+ source $HESTIA /func/main.sh
23+ # shellcheck source=/usr/local/hestia/conf/hestia.conf
24+ source $HESTIA /conf/hestia.conf
25+
26+
27+ # ----------------------------------------------------------#
28+ # Verifications #
29+ # ----------------------------------------------------------#
30+
31+ check_args ' 1' " $# " ' USER'
32+ is_format_valid ' user'
33+ is_object_valid ' user' ' USER' " $user "
34+
35+ # Perform verification if read-only mode is enabled
36+ check_hestia_demo_mode
37+
38+ # ----------------------------------------------------------#
39+ # Actions #
40+ # ----------------------------------------------------------#
41+
42+ if [ " $user " = ' admin' ] && [ " $mode " = " overall" ]; then
43+ log_file=" $USER_DATA /overall_stats.log"
44+ else
45+ log_file=" $USER_DATA /stats.log"
46+ fi
47+
48+ if [ -f " $USER_DATA /stats.log" ]; then
49+ rm -f " $log_file "
50+ touch $log_file
51+ fi
52+
53+ # ----------------------------------------------------------#
54+ # Logging #
55+ # ----------------------------------------------------------#
56+ if [ " $mode " = " overall" ]; then
57+ $BIN /v-log-action " system" " Info" " System" " Overall usage statistics deleted."
58+ else
59+ $BIN /v-log-action " system" " Info" " System" " Usage statistics deleted (User: $user )."
60+ fi
0 commit comments