lsyncd/lsyncd-conf.lua

81 lines
2.1 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-10-17 15:24:55 +00:00
nodaemon,
2010-10-22 10:35:26 +00:00
loglevel = DEBUG,
2010-10-16 18:21:01 +00:00
}
2010-10-22 23:14:11 +00:00
print(bla)
2010-10-22 10:35:26 +00:00
------
-- for testing purposes
--
2010-10-23 12:36:55 +00:00
slower = "sleep 10 && "
2010-10-22 10:35:26 +00:00
slowbash = {
startup = function(source, target)
log(NORMAL, "cp -r from "..source.." -> "..target)
2010-10-23 12:36:55 +00:00
return exec("/bin/bash", "-c", "cp -r \"$1\"* \"$2\"", "/bin/bash",
2010-10-22 10:43:57 +00:00
source, target)
2010-10-22 10:35:26 +00:00
end,
create = function(source, path, name, target)
local src = source..path..name
2010-10-23 12:36:55 +00:00
local trg = target..path..name
log(NORMAL, "create from "..src.." -> "..trg)
return exec("/bin/bash", "-c", slower.."cp \"$1\" \"$2\"", "/bin/bash",
src, trg)
end,
modify = function(source, path, name, target)
local src = source..path..name
local trg = target..path..name
log(NORMAL, "modify from "..src.." -> "..trg)
return exec("/bin/bash", "-c", slower.."cp \"$1\" \"$2\"", "/bin/bash",
src, trg)
2010-10-22 10:35:26 +00:00
end,
attrib = function(source, path, name, target)
-- ignore attribs
return 0
end,
delete = function(source, path, name, target)
log(NORMAL, "delete "..target..path..name)
2010-10-23 12:36:55 +00:00
return exec("/bin/bash", "-c", slower.."rm \"$1\"", "/bin/bash",
2010-10-22 10:35:26 +00:00
target..path..name)
end,
move = function(source, path, name, destpath, destname, target)
log(NORMAL, "move from " .. destination .. "/" .. path)
2010-10-23 12:36:55 +00:00
-- return exec("/bin/bash", "-c", "sleep " .. slowsec .. " && rm $1 $2", "/bin/bash",
-- source .. "/" .. path, target .. "/" .. path)
return 0
2010-10-22 10:35:26 +00:00
end,
}
-----
-- lsyncd classic - sync with rsync
--
-- All functions return the pid of a spawned process
-- or 0 if they didn't exec something.
2010-10-22 08:34:41 +00:00
rsync = {
2010-10-22 10:35:26 +00:00
----
-- Called for every sync/target pair on startup
startup = function(source, target)
log(NORMAL, "startup recursive rsync: " .. source .. " -> " .. target)
return exec("/usr/bin/rsync", "-ltrs", source, target)
end,
default = function(source, target, path)
2010-10-22 08:34:41 +00:00
return exec("/usr/bin/rsync", "--delete", "-ltds", source .. "/" .. path, target .. "/" .. path)
end
}
2010-10-23 12:36:55 +00:00
sync("s", "d/", slowbash)
2010-10-16 18:21:01 +00:00
2010-10-17 17:13:53 +00:00