- New centralized logfile system for Network, DNS & VPN,
- Now kill VPN suprocesses, - Move file config in syscoinfig file, - Misc fixes.
This commit is contained in:
@@ -12,6 +12,9 @@ fi
|
||||
# Global Variable
|
||||
#-----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
declare -g LOG_FILE=""
|
||||
declare -g LOG_LOCK=""
|
||||
declare -g LOG_ECHO=""
|
||||
|
||||
|
||||
|
||||
@@ -253,7 +256,7 @@ file_lock()
|
||||
|
||||
if ! flock ${flag} -w 5 ${desc}
|
||||
then
|
||||
err_echo "Failed to acquire read lock on: [${file}]"
|
||||
err_echo "Failed to acquire [${mode}] lock on: [${file}]"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
@@ -285,18 +288,67 @@ file_unlock()
|
||||
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------------------------------------------------
|
||||
# log_file_set
|
||||
#--------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
log_set()
|
||||
{
|
||||
local log_file="$1"
|
||||
local lock_file="$2"
|
||||
local echo_function="$3"
|
||||
|
||||
|
||||
LOG_FILE="${log_file}"
|
||||
LOG_LOCK="${lock_file}"
|
||||
LOG_ECHO="${echo_function}"
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------------------------------------------------
|
||||
# log_print_file
|
||||
#--------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
log_print_file()
|
||||
{
|
||||
local log_file="$1"
|
||||
local lock_file="$2"
|
||||
local echo_function="$3"
|
||||
local log_prefix="$4"
|
||||
|
||||
|
||||
shift; shift; shift; shift
|
||||
|
||||
${echo_function} "($BASHPID):" "$*"
|
||||
|
||||
if [[ "${log_file}" != "" ]]
|
||||
then
|
||||
if [[ "${lock_file}" != "" ]]
|
||||
then
|
||||
file_lock "${lock_file}" WRITE 8
|
||||
fi
|
||||
|
||||
printf >> "${log_file}" "%s %9s %8s %s\n" "$(date --rfc-3339=seconds -u)" "($BASHPID)" "${log_prefix}:" "$*"
|
||||
|
||||
if [[ "${lock_file}" != "" ]]
|
||||
then
|
||||
file_unlock 8
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------------------------------------------------
|
||||
# log_print
|
||||
#--------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
log_print()
|
||||
{
|
||||
local log_file="$1"
|
||||
local echo_function="$2"
|
||||
|
||||
|
||||
shift; shift
|
||||
|
||||
${echo_function} "($BASHPID):" "$*"
|
||||
echo >> ${VPN_LOG_FILE} $(date) "($BASHPID):" "$*"
|
||||
log_print_file "${LOG_FILE}" "${LOG_LOCK}" "${LOG_ECHO}" $*
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user