/
v-log-user-logout
executable file
·44 lines (34 loc) · 1.38 KB
/
v-log-user-logout
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash
# info: Log User logout event
# options: USER FINGERPRINT
#----------------------------------------------------------#
# Variables & Functions #
#----------------------------------------------------------#
# Argument definition
user=$1
session_id=$2
# Includes
# shellcheck source=/etc/hestiacp/hestia.conf
source /etc/hestiacp/hestia.conf
# shellcheck source=/usr/local/hestia/func/main.sh
source $HESTIA/func/main.sh
# load config file
source_conf "$HESTIA/conf/hestia.conf"
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
check_args '2' "$#" 'USER SESSION_ID'
is_format_valid 'user'
is_common_format_valid "$session_id" "Session ID"
is_object_valid 'user' 'USER' "$user"
if [ ! -f "$USER_DATA/auth.log" ]; then
touch "$USER_DATA/auth.log"
fi
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
sed -i "s/SESSION='$session_id' ACTIVE='yes'/SESSION='$session_id' ACTIVE='no'/g" "$USER_DATA/auth.log"
#----------------------------------------------------------#
# Hestia #
#----------------------------------------------------------#
exit