Last active
July 5, 2017 11:21
-
-
Save douglascodes/90e3d0e331ec8fe739960c0e3156d63c to your computer and use it in GitHub Desktop.
Script to update web directory on change. A -> B Watch using inotifywait.
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/sh | |
# Syncs files from directory A to B. With the 'chown' this will need to be run as root. | |
# Drop that to run as unprivileged user. | |
if [ $# -lt 2 ] ; then | |
echo "usage: $0 <dir to watch> <sync to>" | |
fi | |
source="$1" | |
destination="$2" | |
echo "Watching: ${source}" | |
echo "Destination: ${destination}" | |
while /usr/bin/inotifywait -r -e delete,move,modify "${source}" --exclude ".idea" | |
do | |
# Change to http user. Delete missing. Ignore jetbrains directories. Ignore git/cvs/sub. Recursive | |
/usr/bin/rsync --chown=http:http --delete --exclude=".idea" -C -rv -- ${source}/* ${destination}/; | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The inotifywait package is usually called inotify-tools. Binary paths are from Arch, adjust as needed.