Skip to content

Instantly share code, notes, and snippets.

@mshuler
Forked from kashyapp/lrsync.lua
Created December 3, 2020 16:41
Show Gist options
  • Save mshuler/94e7ea89c48048797674c37876945a84 to your computer and use it in GitHub Desktop.
Save mshuler/94e7ea89c48048797674c37876945a84 to your computer and use it in GitHub Desktop.
lsyncd and configuration
local hostname = os.getenv("HOSTNAME")
local package = os.getenv("PACKAGE")
assert(hostname, "HOSTNAME env variable is not set")
assert(package, "PACKAGE env variable is not set")
local privateKey = "/usr/share/" .. package .. "/etc/id_rsa"
settings {
statusFile = "/var/run/" .. package .. "/lsyncd.stat",
statusInterval = 60,
nodaemon = true,
-- maxDelays = 100,
-- maxProcesses = 2,
}
-- OPS-STORAGE
local storage_enabled = false
if (storage_enabled) then
sync {
default.rsync,
source = "/var/lib/fk-pf-cfgsvc/data",
target = "storage::fk-storage/ConfigServiceData/" .. hostname,
exclude = {
"*.tmp",
},
rsync = {
verbose = false,
timeout = 120,
},
-- delete = false,
}
end
-- PEER SERVER
local peers = {
["pf-config-manage-1"] = "pf-config-manage-2",
["pf-config-manage-2"] = "pf-config-manage-1",
["stage-pf-config-manage-1"] = "stage-pf-config-manage-2",
["stage-pf-config-manage-2"] = "stage-pf-config-manage-1",
}
if (peers[hostname]) then
sync {
default.rsync,
source = "/var/lib/fk-pf-cfgsvc/data",
target = peers[hostname] .. ":/var/lib/fk-pf-cfgsvc/" .. hostname,
exclude = {
"*.tmp",
},
rsync = {
verbose = false,
timeout = 120,
_extra = {
"-e ssh -i " .. privateKey .. " -l fk-pf-cfgsvc -o StrictHostKeyChecking=no"
},
},
}
end
$ wget https://lsyncd.googlecode.com/files/lsyncd-2.1.4.tar.gz
$ sudo apt-get install lua5.1 liblua5.1-dev
$ ./configure
# comment out the check for asciidoc if it errors out and run configure again
$ make
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment