lsyncd/lsyncd-conf.lua

55 lines
1.5 KiB
Lua
Raw Normal View History

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-10-22 10:35:26 +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)
return shell([[if [ "$(ls -A $1)" ]; then cp -r "$1"* "$2"; fi]],
source, target)
2010-10-22 10:35:26 +00:00
end,
2010-11-05 15:18:01 +00:00
onCreate = function(config, event)
-- concats the source and the target with the file/dirs path and name
-- basename removes the trailing '/' on dirs.
local source = config.source .. event.pathbasename
local target = config.target .. event.pathbasename
log("Normal", "create from ", source, " -> ", target)
2010-11-05 18:04:29 +00:00
return shell(prefix..[[cp -r "$1" "$2"]], source, target)
2010-10-23 12:36:55 +00:00
end,
2010-11-05 15:18:01 +00:00
onModify = function(config, event)
-- same game for modifies
local source = config.source .. event.pathbasename
local target = config.target .. event.pathbasename
log("Normal", "modify from ", source, " -> ", target)
2010-11-05 18:04:29 +00:00
return shell(prefix..[[cp -r "$1" "$2"]], source, target)
2010-10-22 10:35:26 +00:00
end,
2010-11-05 15:18:01 +00:00
onDelete = function(config, event)
-- similar for deletes
local target = config.target .. event.pathbasename
log("Normal", "delete ", target)
2010-11-05 18:04:29 +00:00
return shell(prefix..[[rm -rf "$1"]], target)
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