Skip to content

Commit 62ce4d6

Browse files
author
Kristan Kenney
committed
Merge branch 'feature/v-delete-user-stats' into feature/user-roles
2 parents 6799ee8 + 26224b7 commit 62ce4d6

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

bin/v-delete-user-stats

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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

Comments
 (0)