monotone

monotone Mtn Source Tree

Root/contrib/monotone-mirror.lua

1-- Copyright (c) 2007 by Richard Levitte <richard@levitte.org>
2-- All rights reserved.
3--
4-- Redistribution and use in source and binary forms, with or without
5-- modification, are permitted provided that the following conditions
6-- are met:
7--
8-- 1. Redistributions of source code must retain the above copyright
9-- notice, this list of conditions and the following disclaimer.
10--
11-- 2. Redistributions in binary form must reproduce the above copyright
12-- notice, this list of conditions and the following disclaimer in the
13-- documentation and/or other materials provided with the distribution.
14--
15-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16-- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19-- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
27-------------------------------------------------------------------------------
28-- Usage:
29--
30-- NOTE: THIS SOFTWARE IS ONLY MEANT FOR SERVER PROCESSES!
31-- Anything else will fail miserably!
32--
33-- in your server's monotonerc, add the following include:
34--
35--include("/PATH/TO/monotone-mirror.lua")
36--
37-- You may want to change the following variables:
38--
39--MM_mirror_dirThe absolute path to the directory where all
40--the mirroring scripts and database are stored.
41--MM_mirror_rcfile
42--The absolute path to the configuration file used
43--by MM_script.
44--
45-- You may also want to change the following variables, but I wouldn't
46-- recommend it:
47--
48--MM_mirror_script
49--The absolute path to the mirroring shell script,
50--monotone-mirror.sh.
51--Depends on MM_mirror_dir by default, and should
52--probably not be changed in itself.
53--MM_mirror_database
54--The absolute path to the mirror database.
55--Depends on MM_mirror_dir by default.
56-------------------------------------------------------------------------------
57
58-------------------------------------------------------------------------------
59-- Variables
60-------------------------------------------------------------------------------
61MM_default_mirror_dir = get_confdir()
62MM_default_mirror_rcfile = MM_default_mirror_dir.."/mirror.rc"
63MM_default_mirror_script_dir = MM_default_mirror_dir
64
65-- These should normally not be touched.
66-- If you have to, make damn sure you know what you do.
67if not MM_mirror_dir then MM_mirror_dir = MM_default_mirror_dir end
68if not MM_mirror_script_dir then MM_mirror_dir = MM_default_mirror_script_dir end
69if not MM_mirror_rcfile then MM_mirror_rcfile = MM_default_mirror_rcfile end
70MM_mirror_script = MM_mirror_script_dir .. "/monotone-mirror.sh"
71MM_mirror_database = MM_mirror_dir .. "/mirror.mtn"
72MM_mirror_log = MM_mirror_dir .. "/mirror.log"
73MM_mirror_errlog = MM_mirror_dir .. "/mirror.err"
74
75-------------------------------------------------------------------------------
76-- Local hack of the note_netsync_end function
77-------------------------------------------------------------------------------
78do
79 local notifier = {
80 ["end"] =
81 function (session_id, status,
82 bytes_in, bytes_out,
83 certs_in, certs_out,
84 revs_in, revs_out,
85 keys_in, keys_out,
86 ...)
87 if certs_in > 0 or revs_in > 0 or keys_in > 0 then
88 spawn_redirected("/dev/null", MM_mirror_log, MM_mirror_errlog,
89MM_mirror_script,MM_mirror_database,MM_mirror_rcfile)
90 end
91 return "continue",nil
92 end }
93 push_hook_functions(notifier)
94end

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status