Created
April 10, 2014 05:36
-
-
Save nojimage/10345363 to your computer and use it in GitHub Desktop.
lsyncd with unison example
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
---- | |
-- User configuration file for lsyncd. | |
-- | |
settings{ | |
logfile="/var/log/lsyncd/lsyncd.log", | |
statusFile="/var/log/lsyncd/lsyncd.status", | |
maxDelays=15 | |
} | |
--- | |
-- sync using unison | |
unisonCommand=function(event) | |
local cmd = "" | |
if string.find(event.sourcePathname, '.unison') then | |
return | |
end | |
local s=event.sourcePathname | |
local d=event.targetPathname | |
s=string.gsub(s, '//', '/') | |
d=string.gsub(d, '//', '/') | |
cmd = cmd .. 'HOME=/var/log/lsyncd/ /usr/bin/unison -batch -silent "$3" "$4"' | |
cmd = cmd .. '; echo ' | |
cmd = cmd .. "; if [ -e \"$2\" ] ; then chown -R `stat -c '%U:%G' $4` \"$2\"; chmod -R go+w \"$2\"; fi" | |
return spawnShell(event, cmd, s, d, event.source, event.target) | |
end | |
runUnison={ | |
maxProcesses=1, | |
delay=3, | |
-- onStartup=unisonCommand, | |
onCreate=unisonCommand, | |
onDelete=unisonCommand, | |
onModify=unisonCommand, | |
onMove=unisonCommand, | |
} | |
--- | |
sync{runUnuson,source="/src",target="/dest"} | |
sync{runUnuson,source="/dest",target="/src"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
同期後、オーナー、パーミッションの強制修正つき