2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-09-05 12:37:54 +00:00
Files
xcat-core/xCAT-server/share/xcat/install/scripts/scriptlib
T
2026-08-30 21:53:29 -03:00

66 lines
1.9 KiB
Plaintext

declare -F msgutil_r &>/dev/null || function msgutil_r {
local logserver=$1
local msgtype=$2
local msgstr=$3
local logfile=$4
local logtag=$5
if [ -z "$msgtype" ]; then
msgtype="debug"
fi
if [ -z "$logtag" ]; then
logtag="xcat"
fi
if [ -n "$logserver" ];then
logger -n $logserver -t $logtag -p local4.$msgtype "$msgstr"
if [ "$?" != "0" ];then
exec 3<>/dev/udp/$logserver/514 >/dev/null;logger -s -t $logtag -p local4.$msgtype "$msgstr" 2>&3
if [ "$?" != "0" ];then
logger -s -t $logtag -p local4.$msgtype "$msgstr" 2>&1|nc $logserver 514 >/dev/null 2>&1
if [ "$?" != "0" ];then
logger -t $logtag -p local4.$msgtype "$msgstr"
fi
fi
fi
else
logger -t $logtag -p local4.$msgtype "$msgstr"
fi
if [ -n "$logfile" ]; then
local logdir="$(dirname $logfile)"
if [ ! -d "$logdir" ]; then
mkdir -p "$logdir"
touch "$logfile"
fi
echo "$(date) [$msgtype]: $logtag: $msgstr" >> $logfile
fi
}
declare -F msgutil &>/dev/null || function msgutil {
msgutil_r "" "$@"
}
declare -F xcat_enable_active_nm_autoconnect &>/dev/null || function xcat_enable_active_nm_autoconnect {
local log_changes="${1:-}"
command -v nmcli >/dev/null 2>&1 || return 0
nmcli -g NAME,STATE con show | \
awk -F: '$1 != "lo" && $2 == "activated" {print $1}' | \
while IFS= read -r con_name
do
[ -n "$con_name" ] || continue
if [ -n "$log_changes" ]; then
case "$XCATDEBUGMODE" in
"1"|"2")
msgutil_r "$MASTER_IP" "info" "set connection $con_name to be activated on system boot" "/var/log/xcat/xcat.log"
;;
esac
fi
nmcli con mod "$con_name" connection.autoconnect yes
done
}