1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-03-09 15:40:03 +00:00

Add possibility to run script to all OMR-Tracker

This commit is contained in:
Ycarus (Yannick Chabanois) 2024-03-28 18:38:19 +01:00
parent ac1632cc85
commit 71336e9527
4 changed files with 67 additions and 2 deletions

View file

@ -15,6 +15,18 @@ _log() {
logger -p daemon.info -t "${basename}" "$@"
}
_post_tracking() {
[ ! -d /usr/share/omr/v2ray-post-tracking.d ] && return
for tracker_bin in /usr/share/omr/v2ray-post-tracking.d/*; do
[ -x "$tracker_bin" ] && (
_log() {
logger -t "v2ray-post-tracking-${tracker_bin##*/}" "$*"
}
. "$tracker_bin" 2>&1
)
done
}
_ping_server() {
local host=$1
ret=$(ping \
@ -70,6 +82,7 @@ uci -q set openmptcprouter.omr=router
uci -q delete openmptcprouter.omr.v2ray
_get_ip
OMR_TRACKER_PREV_STATUS=""
while true; do
host="${hosts%% *}"
[ "$host" = "$hosts" ] || {
@ -107,6 +120,7 @@ while true; do
fi
[ "$(uci -q get openmptcprouter.omr.detected_public_ipv4)" = "" ] || ([ "$(uci -q get openmptcprouter.settings.disable_ipv6)" != "1" ] && [ "$(uci -q get openmptcprouter.omr.detected_public_ipv6)" = "" ]) && _get_ip
last=0
OMR_TRACKER_STATUS="OK"
else
last=$((last + 1 ))
[ -z "$nocontact" ] && nocontact="$host" || nocontact="$nocontact, $host"
@ -145,6 +159,9 @@ while true; do
sleep $wait_test
fi
}
OMR_TRACKER_STATUS="ERROR"
fi
_post_tracking
OMR_TRACKER_PREV_STATUS="$OMR_TRACKER_STATUS"
sleep "${interval}"
done