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-05 15:18:01 +00:00
|
|
|
onStartup = function(config)
|
|
|
|
-- called on startup
|
|
|
|
local source = config.source
|
|
|
|
local target = config.target
|
2010-11-05 13:34:02 +00:00
|
|
|
log("Normal", "cp -r from ", source, " -> ", target)
|
2010-11-07 01:06:08 +00:00
|
|
|
spawnShell("all", {[0]="ok", others="fail"},
|
|
|
|
[[if [ "$(ls -A $1)" ]; then cp -r "$1"* "$2"; fi]],
|
2010-11-05 13:34:02 +00:00
|
|
|
source, 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
|
|
|
|