adding ssh.identityFile and ssh.options options

This commit is contained in:
Axel Kittenberger 2013-07-30 11:16:29 +02:00
parent 1dacb68745
commit 6f4613c53a
2 changed files with 167 additions and 41 deletions

View File

@ -462,7 +462,7 @@ rsync.prepare = function(
computedN = computedN + 1 computedN = computedN + 1
end end
end end
if crsync.bwlimit then if crsync.bwlimit then
computed[ computedN ] = '--bwlimit=' .. crsync.bwlimit computed[ computedN ] = '--bwlimit=' .. crsync.bwlimit
computedN = computedN + 1 computedN = computedN + 1

View File

@ -50,9 +50,11 @@ rsyncssh.checkgauge = {
-- ssh settings -- ssh settings
ssh = { ssh = {
binary = true, binary = true,
port = true, identityFile = true,
_extra = true options = true,
port = true,
_extra = true
}, },
-- xargs settings -- xargs settings
@ -68,13 +70,21 @@ rsyncssh.checkgauge = {
-- --
rsyncssh.action = function( inlet ) rsyncssh.action = function( inlet )
local event, event2 = inlet.getEvent() local event, event2 = inlet.getEvent( )
local config = inlet.getConfig()
local config = inlet.getConfig( )
-- makes move local on target host -- makes move local on target host
-- if the move fails, it deletes the source -- if the move fails, it deletes the source
if event.etype == 'Move' then if event.etype == 'Move' then
log('Normal', 'Moving ',event.path,' -> ',event2.path)
log(
'Normal',
'Moving ',
event.path,
' -> ',
event2.path
)
spawn( spawn(
event, event,
@ -85,7 +95,9 @@ rsyncssh.action = function( inlet )
'\"' .. config.targetdir .. event.path .. '\"', '\"' .. config.targetdir .. event.path .. '\"',
'\"' .. config.targetdir .. event2.path .. '\"', '\"' .. config.targetdir .. event2.path .. '\"',
'||', 'rm', '-rf', '||', 'rm', '-rf',
'\"' .. config.targetdir .. event.path .. '\"') '\"' .. config.targetdir .. event.path .. '\"'
)
return return
end end
@ -155,7 +167,7 @@ rsyncssh.action = function( inlet )
-- for everything else a rsync is spawned -- for everything else a rsync is spawned
-- --
local elist = inlet.getEvents( local elist = inlet.getEvents(
function(e) function( e )
-- TODO use a table -- TODO use a table
return e.etype ~= 'Move' and return e.etype ~= 'Move' and
e.etype ~= 'Delete' and e.etype ~= 'Delete' and
@ -170,16 +182,19 @@ rsyncssh.action = function( inlet )
-- removes trailing slashes from dirs. -- removes trailing slashes from dirs.
-- --
for k, v in ipairs( paths ) do for k, v in ipairs( paths ) do
if string.byte(v, -1) == 47 then if string.byte( v, -1 ) == 47 then
paths[k] = string.sub(v, 1, -2) paths[k] = string.sub( v, 1, -2 )
end end
end end
local sPaths = table.concat(paths, '\n') local sPaths = table.concat( paths, '\n' )
local zPaths = table.concat(paths, '\000') local zPaths = table.concat( paths, '\000' )
log('Normal', 'Rsyncing list\n', sPaths) log(
'Normal',
'Rsyncing list\n',
sPaths
)
spawn( spawn(
elist, elist,
@ -288,30 +303,117 @@ rsyncssh.prepare = function( config, level )
) )
end end
local cssh = config.ssh; local cssh =
cssh._computed = { } config.ssh;
local computed = cssh._computed
local computedN = 1
if cssh._extra then cssh._computed =
for k, v in ipairs( cssh._extra ) do { }
computed[ computedN ] = v
computedN = computedN + 1 local computed =
cssh._computed
local computedN =
1
local rsyncc =
config.rsync._computed
if cssh.identityFile then
computed[ computedN ] =
'-i'
computed[ computedN + 1 ] =
cssh.identityFile
computedN =
computedN + 2
if not config.rsync._rshIndex then
config.rsync._rshIndex =
#rsyncc + 1
rsyncc[ config.rsync._rshIndex ] =
'--rsh=ssh'
end
rsyncc[ config.rsync._rshIndex ] =
rsyncc[ config.rsync._rshIndex ] ..
' -i ' ..
cssh.identityFile
end
if cssh.options then
for k, v in pairs( cssh.options ) do
computed[ computedN ] =
'-o'
computed[ computedN + 1 ] =
k .. '=' .. v
computedN =
computedN + 2
if not config.rsync._rshIndex then
config.rsync._rshIndex =
#rsyncc + 1
rsyncc[ config.rsync._rshIndex ] =
'--rsh=ssh'
end
rsyncc[ config.rsync._rshIndex ] =
table.concat(
{
rsyncc[ config.rsync._rshIndex ],
' -o ',
k,
'=',
v
},
''
)
end end
end end
if cssh.port then if cssh.port then
computed[ computedN ] = '-p' computed[ computedN ] =
computed[ computedN + 1 ] = cssh.port '-p'
computedN = computedN + 2
local rsyncc = config.rsync._computed computed[ computedN + 1 ] =
rsyncc[ #rsyncc + 1 ] = '--rsh=ssh -p ' .. cssh.port cssh.port
computedN =
computedN + 2
if not config.rsync._rshIndex then
config.rsync._rshIndex =
#rsyncc + 1
rsyncc[ config.rsync._rshIndex ] =
'--rsh=ssh'
end
rsyncc[ config.rsync._rshIndex ] =
rsyncc[ config.rsync._rshIndex ] .. ' -p ' .. cssh.port
end
if cssh._extra then
for k, v in ipairs( cssh._extra ) do
computed[ computedN ] =
v
computedN =
computedN + 1
end
end end
-- appends a slash to the targetdir if missing -- appends a slash to the targetdir if missing
if string.sub( config.targetdir, -1 ) ~= '/' then if string.sub( config.targetdir, -1 ) ~= '/' then
config.targetdir = config.targetdir .. '/' config.targetdir =
config.targetdir .. '/'
end end
end end
@ -319,33 +421,39 @@ end
-- --
-- allow processes -- allow processes
-- --
rsyncssh.maxProcesses = 1 rsyncssh.maxProcesses =
1
-- --
-- The core should not split move events -- The core should not split move events
-- --
rsyncssh.onMove = true rsyncssh.onMove =
true
-- --
-- default delay -- default delay
-- --
rsyncssh.delay = 15 rsyncssh.delay =
15
-- --
-- no default exit codes -- no default exit codes
-- --
rsyncssh.exitcodes = false rsyncssh.exitcodes =
false
-- --
-- rsync exit codes -- rsync exit codes
-- --
rsyncssh.rsyncExitCodes = default.rsyncExitCodes rsyncssh.rsyncExitCodes =
default.rsyncExitCodes
-- --
-- ssh exit codes -- ssh exit codes
-- --
rsyncssh.sshExitCodes = default.sshExitCodes rsyncssh.sshExitCodes =
default.sshExitCodes
-- --
-- xargs calls configuration -- xargs calls configuration
@ -357,16 +465,19 @@ rsyncssh.xargs = {
-- --
-- the binary called (on target host) -- the binary called (on target host)
binary = '/usr/bin/xargs', binary =
'/usr/bin/xargs',
-- --
-- delimiter, uses null by default, you might want to override this for older -- delimiter, uses null by default, you might want to override this for older
-- by for example '\n' -- by for example '\n'
delimiter = '\000', delimiter =
'\000',
-- --
-- extra parameters -- extra parameters
_extra = { '-0', 'rm -rf' } _extra =
{ '-0', 'rm -rf' }
} }
-- --
@ -379,16 +490,31 @@ rsyncssh.ssh = {
-- --
-- the binary called -- the binary called
-- --
binary = '/usr/bin/ssh', binary =
'/usr/bin/ssh',
--
-- if set adds this key to ssh
--
identityFile =
nil,
--
-- if set adds this special options to ssh
--
options =
nil,
-- --
-- if set connect to this port -- if set connect to this port
-- --
port = nil, port =
nil,
-- --
-- extra parameters -- extra parameters
-- --
_extra = { } _extra =
{ }
} }