Last active
September 6, 2016 11:08
-
-
Save hamishforbes/ccb3106fe9a381cb59904fe02bc3b617 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
settings { | |
logfile = "/var/log/lsyncd/lsyncd.log", | |
maxProcesses = 20, | |
pidfile = "/var/run/lsyncd.pid", | |
statusFile = "/tmp/lsyncd.status", | |
--nodaemon = true | |
} | |
local function clamScan(event, path) | |
local host = event.config.host | |
local port = event.config.port | |
-- Build command: echo "SCAN <filepath>" | nc <host <port> | |
local cmd = { | |
[[echo "SCAN ]], | |
path, | |
[[" | nc ]], | |
host, | |
" ", | |
port | |
} | |
cmd = table.concat(cmd, "") | |
log("Normal", cmd) | |
spawnShell(event, cmd) | |
return | |
end | |
local function clamHandler(event) | |
if event.isdir then | |
-- ignores events on dirs | |
return | |
end | |
local path = event.source .. event.pathname | |
return clamScan(event, path) | |
end | |
clamscan = { | |
-- Enable the extra config options | |
checkgauge = { | |
["host"] = true, | |
["port"] = true, | |
["exclude"] = true, | |
["on_start"] = true, | |
}, | |
delay = 0, | |
maxProcesses = 20, | |
-- Default host/port | |
host = "127.0.0.1", | |
port = 3310, | |
onCreate = clamHandler, | |
onModify = clamHandler, | |
onStartup = function(event) | |
-- TODO: apply excludes here | |
if event.config.on_start ~= false then | |
log("Normal", "Scanning target dir: "..event.source) | |
clamScan(event, event.source) | |
end | |
end | |
} | |
sync { | |
clamscan, | |
--on_start = false, | |
source = '/tmp/clamtest/', | |
exclude = 'tmp/' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment