This file contains 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/sh | |
# This script is made to run inside a docker container, when we need to watch for changes in the container and build. | |
# Initially used for watching changes and doing a Hugo build, but this should be pretty general purpose. | |
# We simply calculate the md5sum of the entire directory every second, and trigger the build command if something has changed | |
PREV_VALUE="" | |
while : | |
do | |
VALUE=`tar --exclude="dir/to/exclude" --exclude="anotherdir/to/exclude" -cf - . | md5sum` | |
if [ "$VALUE" != "$PREV_VALUE" ]; then | |
./command_to_run # or the script to run | |
fi | |
PREV_VALUE=$VALUE | |
sleep 1 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment