ah, I forgot the set the script's file permission.

On 2015-01-26 21:17, Suvir Bhargav wrote:
> Hi,
>
> I have a update job for updating the system (let's say it engine for now). 
> Now i need to invoke it during wifi up only. On other states, update job must 
> be in stop state.
> The problem is my system is pretty old and i don't have access to nice 
> upstart-file-bridge. Hence i'm calling a script from the job to chehck for 
> status and controlling the update job from the script itself.
>
> For the whole sc, i have two jobs and one script. as:
>
> The engine job .conf file:
> ------------------------------------------------------------------------------
>
> # engine update
> #
> # Takes care of updating of the system.
>
> description     "engine update"
>
> # removing start, it will be started by wifi-job
> #start on file FILE_PATH=/var/run/engine/wifiState and started engine
> stop on stopped engine or rw_mode
>
> respawn# sinnce its a network job, hence keeping it respawn
> respawn limit 10 5
>
> ------------------------------------------------------------------------------
>
>
> Chechk wifi_status job
> ------------------------------------------------------------------------------
>
> start on started engine
> stop on stopped engine or rw_mode
>
>
>
> respawn
> respawn limit 10 5
>
> script
>         sleep 10;
>         /etc/engine/wifi_update.sh
> end script
>
> ------------------------------------------------------------------------------
>
>
>
> And, finally the wifi_update.sh script which basically chehcks for the status 
> and calls engine update job.
> ------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>
> #!/bin/bash
> # we check for wifistate and stop/start service based on it.
>
> WIFI_FILE='/var/run/engine/wifiState' #chehck the status here
>
> function update_onwifi () {
>     if grep -q "^up" /var/run/engine/wifiState && \
>        initctl status engine | grep -q "start/running"
>     then
>         start engine-update
>     elif grep -q "^down" /var/run/engine/wifiState; then
>         stop engine-update
>     fi
> }
>
> #check if inotify-tools is installed
> type -P inotifywait &>/dev/null || { echo "inotifywait command not found."; }
>
>
> # it takes some time for wifi status to appear. so we read the directory for 
> changes.
> while inotifywait --format '%f' -e 
> modify,attrib,close_write,move,create,delete /var/run/engine/ ; do
>
>
> # it takes some time after boot for the file to appear, hence check.
> if [ -f "$WIFI_FILE" ]; then
>         # we basically chehck everytime someone touch the directory 
> var/run/engine.
>         update_onwifi
> else
>         echo "$WIFI_FILE not found."
> fi
>
> done
> ------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>
> Upon boot, my wifi status job keeps respwaning as it says it has been 
> terminated. I tested the script independently and it works fine.
> May be my appraoch to handle inotify case isn't the right one. Would be happy 
> if someone has any suggestion
>
>
> /Suvir
>
> ________________________________
>
> NOTE FROM MOBITEC: This e-mail message stream in its entirety, including any 
> attachments, is confidential and proprietary and intended only for the person 
> or persons originally addressed, or originally intended to be addressed. 
> Further, it may be protected by certain agreements, legal privilege, legal 
> precedent or law. It must not be read by or disclosed to any person other 
> than the intended recipient without the express permission of the sender. Any 
> confidential or proprietary interests are not waived or lost by reason of 
> delivery to you. If this e-mail message is received by anyone other than the 
> designated recipient, please delete it, including all attachments, and notify 
> the sender immediately by return e-mail.
>


-- 
upstart-devel mailing list
upstart-devel@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/upstart-devel

Reply via email to