OpenSprinkler Forums Hardware Questions OpenSprinkler Pi (OSPi) Starting ospi.py automatically Re: Re: Starting ospi.py automatically

#24720

Michael
Member

@Dan in CA wrote:

Michael,

That’s interesting. Whenever I try that it never works.

What is your setup like? Wifi, hardwared?

Dan

I am using wifi. I did not know there were defaults if you did not specify anything. That makes sense since it is in the config that way. This is what my rc.local looks like and I have no issues, I have apache running on 80 for samer’s website and the interval program on 8080 so I can access both websites as needed.

#wait to make sure everything is ready to go (probably not needed)
sleep 30
#run a script that periodically makes sure wifi is running
/bin/sh /network-monitor.sh &

# change to the /OSPi directory
cd /OsPi/
# run the interval program
/usr/bin/python ospi.py 0.0.0.0:8080 &

Here is what the network monitor script looks like, This helps because sometimes my router may reboot and I want the pi to reconnect if there is any issue. It checks every 5 minutes for a connection. I found it somewhere on the web I forget who wrote it sorry for not giving credit.

#!/bin/sh

while true ; do
if /sbin/ifconfig wlan0 | grep -q “inet addr:” ; then
sleep 600
else
echo “Network connection down! Attempting reconnection.”
/sbin/ifup –force wlan0
sleep 10
fi
done