I recently setup a vpn on my router everything mostly works fine, the one thing that is nagging me here is that once or twice everyday my VPN connection drops and I have to manually go to VPN >> OpenVPN >> stop/start.
Now, I found a watchdog script:
#!/bin/sh
n=0
while [ $n -lt 10 ]
do
if /bin/ping -c 1 8.8.8.8 >/dev/null
then
exit 0
fi
n=$((n+1))
done
/etc/init.d/network restart
I have made it executable, however, when try to test run it by
sh /root/wan-watchdog.sh
It gives me a
/root/wan-watchdog.sh: line 11: syntax error: unexpected end of file (expecting "then")
Can anyone please provide me any sort of solution as to why this happening.
Problem solved the actual culprit here was drum roll 'Notepad++. After lots searching on the internet I came across this stackexchange thread.
The issue has had something to do with the white spaces. Following the advice mentioned in that thread. After saving my script in Notepad++. I converted my script with the help of this website, and then I uploaded the converted script to my router. And this time I got no syntax error.
P.S.: Although the script so far hasn't been working. But that isn't in the scope of this thread. I believe, as the popularity of OpenWrt is rising. The developers of this project do need to incorporate some everyday users friendly features like "basic connection wizard," (as getting internet connection on my OpenWrt wasn't less of struggle) and "watchdog" script.