2010-10-19 10:20:27 +00:00
|
|
|
----
|
|
|
|
-- User configuration file for lsyncd.
|
|
|
|
--
|
|
|
|
-- TODO documentation-
|
|
|
|
--
|
2010-10-16 18:21:01 +00:00
|
|
|
settings = {
|
2010-10-22 10:35:26 +00:00
|
|
|
-- logfile = "/tmp/lsyncd",
|
2010-11-02 21:04:01 +00:00
|
|
|
-- nodaemon = true,
|
2010-10-28 17:56:33 +00:00
|
|
|
statusfile = "/tmp/lsyncd.stat",
|
2010-10-16 18:21:01 +00:00
|
|
|
}
|
|
|
|
|
2010-11-05 18:20:33 +00:00
|
|
|
----
|
2010-11-01 16:38:39 +00:00
|
|
|
-- for testing purposes. uses bash command to hold local dirs in sync.
|
2010-10-22 10:35:26 +00:00
|
|
|
--
|
2010-10-27 11:31:18 +00:00
|
|
|
prefix = "sleep 1 && "
|
2010-10-22 10:35:26 +00:00
|
|
|
slowbash = {
|
2010-10-24 16:41:58 +00:00
|
|
|
delay = 5,
|
|
|
|
|
2010-11-07 09:53:39 +00:00
|
|
|
init = function(inlet)
|
|
|
|
local c = inlet.getConfig()
|
|
|
|
log("Normal", "cp -r from ", c.source, " -> ", c.target)
|
|
|
|
|
|
|
|
-- collect gets called when spawned process finished
|
|
|
|
local function collect(exitcode)
|
|
|
|
if exitcode == 0 then
|
2010-11-08 12:14:10 +00:00
|
|
|
log("Normal", "Startup of '",c.source,"' finished.")
|
2010-11-07 09:53:39 +00:00
|
|
|
else
|
2010-11-08 12:14:10 +00:00
|
|
|
log("Error", "Failure on startup of '",c.source,"'.")
|
2010-11-07 09:53:39 +00:00
|
|
|
terminate(-1) -- ERRNO
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
spawnShell(inlet.blanketEvent(), collect,
|
2010-11-07 01:06:08 +00:00
|
|
|
[[if [ "$(ls -A $1)" ]; then cp -r "$1"* "$2"; fi]],
|
2010-11-08 12:14:10 +00:00
|
|
|
c.source, c.target)
|
2010-10-22 10:35:26 +00:00
|
|
|
end,
|
|
|
|
|
2010-11-06 17:40:12 +00:00
|
|
|
onCreate = function(event)
|
|
|
|
local s = event.sourcePathname
|
|
|
|
local t = event.targetPathname
|
|
|
|
log("Normal", "create from ", s, " -> ", t)
|
2010-11-07 01:06:08 +00:00
|
|
|
spawnShell(event, "ok", prefix..[[cp -r "$1" "$2"]], s, t)
|
2010-10-23 12:36:55 +00:00
|
|
|
end,
|
|
|
|
|
2010-11-06 17:40:12 +00:00
|
|
|
onModify = function(event)
|
|
|
|
local s = event.sourcePathname
|
|
|
|
local t = event.targetPathname
|
|
|
|
log("Normal", "modify from ", s, " -> ", t)
|
2010-11-07 01:06:08 +00:00
|
|
|
spawnShell(event, "ok", prefix..[[cp -r "$1" "$2"]], s, t)
|
2010-10-22 10:35:26 +00:00
|
|
|
end,
|
|
|
|
|
2010-11-06 17:40:12 +00:00
|
|
|
onDelete = function(event)
|
|
|
|
local t = event.targetPathname
|
|
|
|
log("Normal", "delete ", t)
|
2010-11-07 01:06:08 +00:00
|
|
|
spawnShell(event, "ok", prefix..[[rm -rf "$1"]], t)
|
2010-11-06 17:40:12 +00:00
|
|
|
end,
|
|
|
|
|
|
|
|
onMove = function(event)
|
|
|
|
local t = event.targetPathname
|
|
|
|
local d = event.dest.targetPathname
|
|
|
|
log("Normal", "delete ", t)
|
2010-11-07 01:06:08 +00:00
|
|
|
spawnShell(event, "ok", prefix..[[mv "$1" "$2"]], t, d)
|
2010-10-22 10:35:26 +00:00
|
|
|
end,
|
|
|
|
}
|
|
|
|
|
2010-11-03 11:37:25 +00:00
|
|
|
sync{slowbash, source="s", target="d/"}
|
2010-10-16 18:21:01 +00:00
|
|
|
|