Skip to content

Commit 55799c8

Browse files
author
Kristan Kenney
committed
Merge branch 'fix/2021-03-logfiles' into main
2 parents 784da90 + 521d2ca commit 55799c8

File tree

2 files changed

+22
-19
lines changed

2 files changed

+22
-19
lines changed

bin/v-delete-user-auth-log

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
#
44
# The function for deleting a users auth log file
55

6+
#----------------------------------------------------------#
7+
# Variable&Function #
8+
#----------------------------------------------------------#
9+
610
# Argument definition
711
user=$1
8-
date=$(date "+%F %T")
912

1013
# Includes
1114
source $HESTIA/func/main.sh
@@ -22,17 +25,15 @@ check_args '1' "$#" 'USER'
2225
is_format_valid 'user'
2326
is_object_valid 'user' 'USER' "$user"
2427

25-
if [ ! -f $USER_DATA/auth.log ]; then
26-
touch $USER_DATA/auth.log
27-
fi
28-
2928
#----------------------------------------------------------#
3029
# Action #
3130
#----------------------------------------------------------#
3231

33-
rm $USER_DATA/auth.log
34-
35-
log_history "Authentication log for $user was cleared on $date."
36-
log_event "$OK" "$ARGUMENTS"
32+
# Remove log file and log event
33+
if [ -f $USER_DATA/auth.log ]; then
34+
rm -f $USER_DATA/auth.log
35+
log_history "login history for $user was cleared."
36+
log_event "$OK" "$ARGUMENTS"
37+
fi
3738

3839
exit

bin/v-delete-user-log

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
# Argument definition
1515
user=$1
16-
date=$(date "+%F %T")
1716

1817
# Includes
1918
source $HESTIA/func/main.sh
@@ -22,20 +21,23 @@ source $HESTIA/conf/hestia.conf
2221
# Perform verification if read-only mode is enabled
2322
check_hestia_demo_mode
2423

24+
#----------------------------------------------------------#
25+
# Verifications #
26+
#----------------------------------------------------------#
27+
28+
check_args '1' "$#" 'USER'
29+
is_format_valid 'user'
30+
is_object_valid 'user' 'USER' "$user"
31+
2532
#----------------------------------------------------------#
2633
# Action #
2734
#----------------------------------------------------------#
2835

29-
# Remove log file
30-
if [ -z $user ]; then
31-
echo "Error: no user specified."
32-
elif [ ! -f "$HESTIA/data/users/$user/history.log" ]; then
33-
echo "Error: no history log found for $user."
34-
else
36+
# Remove log file and log event
37+
if [ -f "$HESTIA/data/users/$user/history.log" ]; then
3538
rm -f $HESTIA/data/users/$user/history.log
39+
log_history "user action log for $user was cleared."
40+
log_event "$OK" "$ARGUMENTS"
3641
fi
3742

38-
log_history "Log for $user was cleared on $date."
39-
log_event "$OK" "$ARGUMENTS"
40-
4143
exit

0 commit comments

Comments
 (0)