Reputation: 428
I have a app-update service that does the sync to server with its conf as :
start on started engine
stop on stopped engine or firmware_update_mode
Now, i get wifi status on the device at /var/run/engine/wifi
with status up/down. I'm now trying to understand what would be the right way to let this app-update service run only on up wifi and stop it on down wifi. Ofcourse, it will only run when the engine running as well. Hence, it should run as a condition execution i.e.
start on engine and wifi up, stop on wifi down.
Is app-update.conf the right place to put such condition execution (run on wifi up, stop on wifi down)?
Upvotes: 0
Views: 394
Reputation: 616
Add another job:
start on file EVENT=modify FILE=/var/run/engine/wifi or starting app-update
task
script
if grep -q "^up" /var/run/engine/wifi && \
initctl status engine | grep -q "start/running"
then
start app-update
elif grep -q "^down" /var/run/engine/wifi; then
stop app-update
fi
end script
This will check to see if the wifi is up when app-update first starts, and will start and stop app-update when the wifi goes up or down.
This is a little complicated, unfortunately, since Upstart does not have state support (only events).
Upvotes: 2