{"body":"#!/bin/bash\n# we check for wifistate and stop/start service based on it.\n\nWIFI_FILE='/var/run/engine/wifiState'\nservice=engine-update\n\nfunction update_onwifi () {\n    if grep -q \"^up\" /var/run/engine/wifiState && \\\n       initctl status engine | grep -q \"start/running\"\n    then\n        start engine-update\n    elif grep -q \"^down\" /var/run/engine/wifiState; then\n        stop engine-update\n    fi\n}\n\n#check if inotify-tools is installed\ntype -P inotifywait &>/dev/null || { echo \"inotifywait command not found.\"; }\n\n\n# it takes some time for wifi status to appear. so we read the directory for changes.\nwhile inotifywait --format '%f' -e modify,attrib,close_write,move,create,delete /var/run/engine/ ; do\n\n\n# file check is not as it takes some time after boot for the file to appear.\nif [ -f \"$WIFI_FILE\" ]; then\n\t# we basically chehck everytime someone touch the directory var/run/engine.\n\tupdate_onwifi\nelse\n\techo \"$WIFI_FILE not found.\"\nfi\n\ndone","name":"","extension":"","url":"https://www.irccloud.com/pastebin/lOfn79W1","modified":1422286526,"id":"lOfn79W1","size":949,"lines":33,"own_paste":false,"theme":"","date":1422286526}