4 .
/lib
/functions
/network.sh
20 logger
-t naywatch
"$msg"
25 eval $1 > /root
/$
(date +%s
)-"$1".log
28 config_list_foreach general save_cmd save_log
32 neighbors_available
() {
35 for interface
in $INTERFACES; do
36 network_get_physdev phy
$interface > /dev
/null
2>&1
37 linklocal
=$
(ip
-6 a list dev
$phy |
grep "scope link" |
awk '{print $2}' |
sed 's/\/64//') 2> /dev
/null
38 ips
=$
(ping ff02
::1%$phy -w5 -W5 -c2 |
awk '/from/{print($4)}' |
sed 's/.$//') 2> /dev
/null
40 if [ $ip != $linklocal ] && [ $
(owipcalc
$ip linklocal
) -eq 1 ]; then
51 # disable openwrt instrumentation:
52 ubus call system watchdog
'{"magicclose":true,"stop":true,"timeout":'${WATCHDOG_TIMEOUT}'}' > /dev
/null
57 # copied from watch-cat
62 echo 1 >/proc
/sys
/kernel
/sysrq
63 echo b
>/proc
/sysrq-trigger
68 log
"No Neighbors Available!"
70 if [ $ACTIVE -eq 0 ]; then
74 if [ $SAVE_LOGS ]; then
79 if [ $USE_WATCHDOG -eq 0 ]; then
84 log
"Naywatch Started!"
88 if [ $USE_WATCHDOG ]; then
94 if [ $USE_WATCHDOG ]; then
99 if [ $USE_WATCHDOG ]; then
105 sleep $CHECK_INTERVAL
107 has_neighbor
=$
(neighbors_available
)
108 if [ $has_neighbor -eq 0 ] && [ $ACTIVE -eq 1 ]; then
110 elif [ $has_neighbor -eq 1 ]; then