You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
hestiacp/bin/v-log-action

63 lines
1.8 KiB

#!/bin/bash
# info: adds action event to user or system log
# options: LOG_TYPE USER
# Event Levels:
# info, warning, error
# Event Categories:
# user: web, dns, mail, db, letsencrypt, pwchange, pwreset
# system: ip, firewall, service, updates,
# users, pwchange, pwreset, impersonation
#----------------------------------------------------------#
# Variables & Functions #
#----------------------------------------------------------#
# 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 #
#----------------------------------------------------------#
# Argument definition
user=$1
event_level=$2
export event_category=$3
event_details=$4
is_common_format_valid "$event_level" "event level"
# Validate event type input
if [ "$event_level" != "Info" ] && [ "$event_level" != "Warning" ] && [ "$event_level" != "Error" ]; then
echo "Error: Invalid event type specified."
exit 1
fi
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
if [ "$user" = "system" ] || [ "$user" = "System" ]; then
user="system"
fi
check_args '4' "$#" 'USER TYPE CATEGORY DETAILS'
if [ "$user" != "system" ]; then
is_format_valid 'user'
is_object_valid 'user' 'USER' "$user"
fi
log_history "$event_details" '' "$user"
#----------------------------------------------------------#
# Hestia #
#----------------------------------------------------------#
exit