lsyncd/lsyncd-conf.lua

71 lines
1.8 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
--
slower = "sleep 10"
slowbash = {
startup = function(source, target)
log(NORMAL, "cp -r from "..source.." -> "..target)
2010-10-22 10:43:57 +00:00
return exec("/bin/bash", "-c", "cp -r \"$1\" \"$2\"", "/bin/bash",
source, target)
2010-10-22 10:35:26 +00:00
end,
create = function(source, path, name, target)
local src = source..path..name
log(NORMAL, "create from "..source..path..name.." -> "..target..path..name)
return exec("/bin/bash", "-c", slower.."&& cp '$1' '$2'", "/bin/bash",
source..path..name, target..path..name)
end,
attrib = function(source, path, name, target)
-- ignore attribs
return 0
end,
delete = function(source, path, name, target)
log(NORMAL, "delete "..target..path..name)
return exec("/bin/bash", "-c", slower.." && rm $1", "/bin/bash",
target..path..name)
end,
move = function(source, path, name, destpath, destname, target)
log(NORMAL, "move from " .. destination .. "/" .. path)
return exec("/bin/bash", "-c", "sleep " .. slowsec .. " && rm $1 $2", "/bin/bash",
source .. "/" .. path, target .. "/" .. path)
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-22 10:40:59 +00:00
sync("s", "d", slowbash)
2010-10-16 18:21:01 +00:00
2010-10-17 17:13:53 +00:00