- Major VPN management debug and fixing.

This commit is contained in:
2025-07-21 12:32:57 +02:00
parent 15678efa10
commit f5a8f84155
4 changed files with 463 additions and 98 deletions

View File

@@ -188,18 +188,20 @@ var_assign()
file_dir_init()
{
locale File="$1"
locale Owner="$2"
locale Group="$3"
local File="$1"
local Owner="$2"
local Group="$3"
local dir
if [[ "'$id -u" != "0" ]]
if [[ "$( id -u)" != "0" ]]
then
${LOG} "Can't perform file: [${File}] init as non root user!"
${LOG} "Can't perform file init of: [${File}] as non root user!"
else
if [ ! -f ${File} ]
then
dir="$( dirname ${file})"
dir="$( dirname ${File})"
if [ ! -d ${dir} ]
then
@@ -215,6 +217,7 @@ file_dir_init()
>${File}
chmod ug+rw ${File}
chown ${Owner}:${Group} ${File}
fi
fi
}
@@ -228,27 +231,27 @@ file_dir_init()
file_lock()
{
fl_file="$1"
fl_mode="$2"
fl_desc="$3"
local file="$1"
local mode="$2"
local desc="$3"
if [[ ( "${fl_mode}" == "EXCLUSIVE" ) || ( "${fl_mode}" == "WRITE" ) ]]
if [[ ( "${mode}" == "EXCLUSIVE" ) || ( "${mode}" == "WRITE" ) ]]
then
fl_flag="-x"
flag="-x"
else
fl_flag="-s"
flag="-s"
fi
if [[ "${fl_desc}" == "" ]]
if [[ "${desc}" == "" ]]
then
fl_desc="9"
desc="9"
fi
eval "exec ${fl_desc}<>\"\${fl_file}\""
eval "exec ${desc}<>\"\${file}\""
if ! flock ${fl_flag} -w 5 ${fl_desc}
if ! flock ${flag} -w 5 ${desc}
then
err_echo "Failed to acquire read lock on: [${file}]"
exit 1
@@ -265,15 +268,35 @@ file_lock()
file_unlock()
{
fu_desc="$1"
local desc="$1"
if [[ "${fu_desc}" == "" ]]
if [[ "${desc}" == "" ]]
then
fu_desc="9"
desc="9"
fi
eval "exec ${fl_desc}<&-"
eval "exec ${fl_desc}>&-"
eval "exec ${desc}<&-"
eval "exec ${desc}>&-"
}
#--------------------------------------------------------------------------------------------------------------------------
# log_print
#--------------------------------------------------------------------------------------------------------------------------
log_print()
{
local log_file="$1"
local echo_function="$2"
shift; shift
${echo_function} "($BASHPID):" "$*"
echo >> ${VPN_LOG_FILE} $(date) "($BASHPID):" "$*"
}