Skip to content
Snippets Groups Projects
Commit a2bc9502 authored by FFS-Roland's avatar FFS-Roland
Browse files

bug fix: due to possible invalid systemtime, using counter instead of time.

parent c22cea54
No related branches found
No related tags found
No related merge requests found
......@@ -9,21 +9,23 @@ FFS=/tmp/.gw.ffs
if [ "$(uci get gluon-setup-mode.@setup_mode[0].enabled)" = "0" ] &&
[ "$(uci get system.@system[0].enable_watchdog)" != "0" ] &&
[ "$(netstat -nt | grep -c ':22')" = "0" ]; then
NOW=$(date +%s)
if [ -n "$(batctl gwl | grep '=>')" ]; then
echo $NOW >$FFS
echo 0 >$FFS
logger -t $ME "node is online"
else
if [ -f $FFS ]; then
OFF=$(cat $FFS)
DELTA=$((NOW - OFF))
logger -t $ME "offline for ${DELTA} sec."
else
OFF=0
fi
logger -t $ME "offline count: ${OFF}"
if [ $DELTA -gt 3500 ]; then
reboot
fi
if [ $OFF -gt 10 ]; then
reboot
else
echo $NOW >$FFS
echo $((OFF+1)) >$FFS
fi
fi
else
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment