Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/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