Created
July 22, 2010 12:20
-
-
Save IanVaughan/485897 to your computer and use it in GitHub Desktop.
monitor.sh - checks for any file changes within a folder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| sha=0 | |
| previous_sha=0 | |
| update_sha() | |
| { | |
| sha=`ls -lR . | sha1sum` | |
| } | |
| build () { | |
| ## Build/make commands here | |
| echo | |
| echo "--> Monitor: Monitoring filesystem... (Press enter to force a build/update)" | |
| } | |
| changed () { | |
| echo "--> Monitor: Files changed, Building..." | |
| build | |
| previous_sha=$sha | |
| } | |
| compare () { | |
| update_sha | |
| if [[ $sha != $previous_sha ]] ; then changed; fi | |
| } | |
| run () { | |
| while true; do | |
| compare | |
| read -s -t 1 && ( | |
| echo "--> Monitor: Forced Update..." | |
| build | |
| ) | |
| done | |
| } | |
| echo "--> Monitor: Init..." | |
| echo "--> Monitor: Monitoring filesystem... (Press enter to force a build/update)" | |
| run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment