File: lbash.lua

package info (click to toggle)
lsyncd 2.1.5-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 732 kB
  • ctags: 363
  • sloc: ansic: 2,549; sh: 1,134; makefile: 48
file content (47 lines) | stat: -rw-r--r-- 1,057 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
-----
-- User configuration file for lsyncd.
--
-- This example uses local bash commands to keep two local
-- directory trees in sync.
--
settings = {
	logfile         = "/tmp/lsyncd.log",
	statusFile      = "/tmp/lsyncd.stat",
	statusIntervall = 1,
	nodaemon        = true,
}

-----
-- for testing purposes. prefix can be used to slow commands down.
-- prefix = "sleep 5 && "
--
prefix = ""

-----
-- for testing purposes. uses bash command to hold local dirs in sync.
--
bash = {
	delay = 0,

	maxProcesses = 1,

	-- calls `cp -r SOURCE/* TARGET` only when there is something in SOURCE
	-- otherwise it deletes contents in the target if there.
	onStartup = [[
if [ "$(ls -A ^source)" ]; then
	cp -r ^source* ^target;
else
	if [ "$(ls -A ^target)" ]; then rm -rf ^target/*; fi
fi]],

	onCreate = prefix..[[cp -r ^sourcePath ^targetPathdir]],

	onModify = prefix..[[cp -r ^sourcePath ^targetPathdir]],

	onDelete = prefix..[[rm -rf ^targetPath]],

	onMove   = prefix..[[mv ^o.targetPath ^d.targetPath]],
}

sync{bash, source="src", target="/path/to/trg/"}