Skip to content

Instantly share code, notes, and snippets.

@nojimage
Created April 10, 2014 05:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nojimage/10345363 to your computer and use it in GitHub Desktop.
Save nojimage/10345363 to your computer and use it in GitHub Desktop.
lsyncd with unison example
----
-- 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"}
@nojimage
Copy link
Author

同期後、オーナー、パーミッションの強制修正つき

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment