mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-10-29 06:35:13 +08:00
🤞 Sync 2026-04-23 06:19:46
This commit is contained in:
1 parent
a1df15cd3d
commit
b86d032e91
250 files changed
+41507
-188
No files matched your search
@@ -1,9 +1,9 @@
|
||||
:
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=pingcontrol
|
||||
PKG_VERSION:=1
|
||||
PKG_RELEASE:=1
|
||||
PKG_RELEASE:=2
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/pingcontrol
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
@@ -10,7 +10,6 @@ SW_BEFORE_MODRES=$(uci -q get pingcontrol.$1.sw_before_modres)
|
||||
SW_BEFORE_SYSRES=$(uci -q get pingcontrol.$1.sw_before_sysres)
|
||||
|
||||
PING_OK=$(uci -q get pingcontrol.$1.ping_ok)
|
||||
SILENT=$(uci -q get pingcontrol.$1.ping_silent)
|
||||
PING_LOST=$(uci -q get pingcontrol.$1.ping_lost)
|
||||
PING_RESTORED=$(uci -q get pingcontrol.$1.ping_restored)
|
||||
BEFORE_IFACE_DOWN=$(uci -q get pingcontrol.$1.before_iface_down)
|
||||
@@ -35,15 +34,8 @@ done
|
||||
while true; do
|
||||
for IP in $TESTIP
|
||||
do
|
||||
[ -n $IFNAME ] && {
|
||||
/bin/ping -w5 -c1 -s8 -I $IFNAME $IP &> /dev/null
|
||||
STATUS=$?
|
||||
} || {
|
||||
/bin/ping -w5 -c1 -s8 $IP &> /dev/null
|
||||
STATUS=$?
|
||||
}
|
||||
|
||||
if [[ "${STATUS}" -eq "0" ]]; then
|
||||
/bin/ping -w5 -c1 -s8 -I $IFNAME $IP &> /dev/null
|
||||
if [[ "$?" -eq "0" ]]; then
|
||||
let host_up_count++
|
||||
else
|
||||
logger -t pingcontrol "$INSTANCE: Ping to host $IP lost"
|
||||
@@ -58,9 +50,7 @@ while true; do
|
||||
done
|
||||
|
||||
if [[ "$host_up_count" -gt "0" ]]; then
|
||||
[ "${SILENT}" != "1" ] && {
|
||||
logger -t pingcontrol "$INSTANCE: Ping OK, reset counters"
|
||||
}
|
||||
logger -t pingcontrol "$INSTANCE: Ping OK, reset counters"
|
||||
if [[ "$lost_flag" -eq "1" ]]; then
|
||||
if [[ -n "$PING_RESTORED" ]]; then
|
||||
logger -t pingcontrol "$INSTANCE: Execute $PING_RESTORED"
|
||||
@@ -68,10 +58,8 @@ while true; do
|
||||
fi
|
||||
else
|
||||
if [[ -n "$PING_OK" ]]; then
|
||||
[ "${SILENT}" != "1" ] && {
|
||||
logger -t pingcontrol "$INSTANCE: Execute $PING_OK"
|
||||
}
|
||||
eval $PING_OK
|
||||
logger -t pingcontrol "$INSTANCE: Execute $PING_OK"
|
||||
eval $PING_OK
|
||||
fi
|
||||
fi
|
||||
host_up_count=0
|
||||
@@ -111,4 +99,4 @@ while true; do
|
||||
fi
|
||||
|
||||
sleep $CHECK_PERIOD
|
||||
done
|
||||
done
|
||||
@@ -3,6 +3,5 @@ config pingcontrol 'pingcontrol'
|
||||
option check_period '30'
|
||||
option iface 'internet'
|
||||
option testip '8.8.8.8'
|
||||
option ping_silent '1'
|
||||
option sw_before_modres '3'
|
||||
option sw_before_sysres '0'
|
||||
@@ -42,8 +42,3 @@ service_triggers() {
|
||||
procd_add_reload_trigger 'pingcontrol'
|
||||
procd_add_validation validate_pingcontrol_section
|
||||
}
|
||||
|
||||
reload_service() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
Reference in new issue
Block a user