4 .
/lib
/functions
/network.sh
22 logger
-t naywatch
"$msg"
27 eval $1 > /root
/$
(date +%s
)-"$1".log
30 config_list_foreach general save_cmd save_log
34 neighbors_available
() {
37 for interface
in $INTERFACES; do
38 network_get_physdev phy
$interface > /dev
/null
2>&1
39 linklocal
=$
(ip
-6 a list dev
$phy |
grep "scope link" |
awk '{print $2}' |
sed 's/\/64//') 2> /dev
/null
40 ips
=$
(ping ff02
::1%$phy -w5 -W5 -c2 |
awk '/from/{print($4)}' |
sed 's/.$//') 2> /dev
/null
42 if [ $ip != $linklocal ] && [ $
(owipcalc
$ip linklocal
) -eq 1 ]; then
53 # disable openwrt instrumentation:
54 ubus call system watchdog
'{"magicclose":true,"stop":true,"timeout":'${WATCHDOG_TIMEOUT}'}' > /dev
/null
59 # copied from watch-cat
64 echo 1 >/proc
/sys
/kernel
/sysrq
65 echo b
>/proc
/sysrq-trigger
70 log
"No Neighbors Available!"
72 NO_NEIGHBORS_COUNT
=$
(($NO_NEIGHBORS_COUNT+1))
74 if [ $ACTIVE -eq 0 ]; then
78 if [ $SAVE_LOGS -eq 1 ]; then
83 if [ $USE_WATCHDOG -eq 0 ] && [ $NO_NEIGHBORS_COUNT -gt $MIN_KICK ]; then
88 log
"Naywatch Started!"
91 if [ $ACTIVE -eq 0 ]; then
92 log
"Naywatch Activated!"
96 if [ $USE_WATCHDOG -eq 1 ]; then
102 if [ $USE_WATCHDOG -eq 1 ]; then
107 if [ $USE_WATCHDOG -eq 1 ]; then
113 sleep $CHECK_INTERVAL
115 has_neighbor
=$
(neighbors_available
)
116 if [ $has_neighbor -eq 0 ] && [ $ACTIVE -eq 1 ]; then
118 elif [ $has_neighbor -eq 1 ]; then