Last active
December 18, 2015 03:59
-
-
Save kofemann/5722445 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
----- | |
-- Sync into dCache with dccp | |
-- usage: | |
-- lsyncd -nodaemon ldccp.lua | |
-- | |
dcap = { | |
maxProcesses = 32, | |
delay = 1, | |
action = function(inlet) | |
local event, event2 = inlet.getEvent() | |
local config = inlet.getConfig() | |
if event.etype == "Create" or event.etype == "Modify" then | |
local localPath = config.mount.. | |
event.targetPath | |
local prefix = '' | |
if event.isdir then | |
spawn(event, | |
"/bin/mkdir", | |
localPath) | |
else | |
if event.etype == "Modify" then | |
prefix = "/bin/rm -f ".. | |
localPath.. ' ; ' | |
end | |
local cmd = prefix..config.dccp..' '.. | |
event.sourcePath..' '.. | |
config.door.. | |
event.targetPath | |
log('Normal', cmd) | |
spawnShell(event, cmd) | |
end | |
elseif event.etype == "Move" then | |
local localSource = config.mount..event.targetPath | |
local localDest = config.mount..event2.targetPath | |
spawn(event, | |
"/bin/mv", | |
localSource, | |
localDest) | |
elseif event.etype == 'Delete' then | |
local localSource = config.mount..event.targetPath | |
spawn(event, | |
"/bin/rm", | |
"-f", | |
localSource) | |
else | |
log('Normal', event.etype) | |
end | |
end, | |
prepare = function(config) | |
end | |
} | |
-- | |
-- expexted that path onder mount will be equal to target path | |
-- | |
sync{dcap, | |
dccp="dccp -u", | |
source="/tmp/src", | |
door="dcap://dcache-lab000", | |
target="/exports/data/p11-test", | |
mount='/mnt' | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment