File: monotone-mirror.lua

package info (click to toggle)
monotone 1.1-4%2Bdeb8u2
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 20,664 kB
  • ctags: 8,113
  • sloc: cpp: 86,443; sh: 6,906; perl: 924; makefile: 838; python: 517; lisp: 379; sql: 118; exp: 91; ansic: 52
file content (94 lines) | stat: -rw-r--r-- 3,981 bytes parent folder | download | duplicates (4)
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
-- Copyright (c) 2007 by Richard Levitte <richard@levitte.org>
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions
-- are met:
--
-- 1. Redistributions of source code must retain the above copyright
--    notice, this list of conditions and the following disclaimer.
--
-- 2. Redistributions in binary form must reproduce the above copyright
--    notice, this list of conditions and the following disclaimer in the
--    documentation and/or other materials provided with the distribution.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

-------------------------------------------------------------------------------
-- Usage:
--
--    NOTE: THIS SOFTWARE IS ONLY MEANT FOR SERVER PROCESSES!
--    Anything else will fail miserably!
--
--    in your server's monotonerc, add the following include:
--
--	include("/PATH/TO/monotone-mirror.lua")
--
--    You may want to change the following variables:
--
--	MM_mirror_dir	The absolute path to the directory where all
--			the mirroring scripts and database are stored.
--	MM_mirror_rcfile
--			The absolute path to the configuration file used
--			by MM_script.
--
--    You may also want to change the following variables, but I wouldn't
--    recommend it:
--
--	MM_mirror_script
--			The absolute path to the mirroring shell script,
--			monotone-mirror.sh.
--			Depends on MM_mirror_dir by default, and should
--			probably not be changed in itself.
--	MM_mirror_database
--			The absolute path to the mirror database.
--			Depends on MM_mirror_dir by default.
-------------------------------------------------------------------------------

-------------------------------------------------------------------------------
-- Variables
-------------------------------------------------------------------------------
MM_default_mirror_dir = get_confdir()
MM_default_mirror_rcfile = MM_default_mirror_dir.."/mirror.rc"
MM_default_mirror_script_dir = MM_default_mirror_dir

-- These should normally not be touched.
-- If you have to, make damn sure you know what you do.
if not MM_mirror_dir then MM_mirror_dir = MM_default_mirror_dir end
if not MM_mirror_script_dir then MM_mirror_dir = MM_default_mirror_script_dir end
if not MM_mirror_rcfile then MM_mirror_rcfile = MM_default_mirror_rcfile end
MM_mirror_script = MM_mirror_script_dir .. "/monotone-mirror.sh"
MM_mirror_database = MM_mirror_dir .. "/mirror.mtn"
MM_mirror_log = MM_mirror_dir .. "/mirror.log"
MM_mirror_errlog = MM_mirror_dir .. "/mirror.err"

-------------------------------------------------------------------------------
-- Local hack of the note_netsync_end function
-------------------------------------------------------------------------------
do
   local notifier = {
      ["end"] =
	 function (session_id, status,
		   bytes_in, bytes_out,
		   certs_in, certs_out,
		   revs_in, revs_out,
		   keys_in, keys_out,
		   ...)
	    if certs_in > 0 or revs_in > 0 or keys_in > 0 then
	       spawn_redirected("/dev/null", MM_mirror_log, MM_mirror_errlog,
				MM_mirror_script,MM_mirror_database,MM_mirror_rcfile)
	    end
	    return "continue",nil
	 end }
   push_hook_functions(notifier)
end