monotone

monotone Mtn Source Tree

Root/contrib/monotone-inotify.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-- This hook is useful for any system that has a FAM system in
34-- place, such as incrond and gamin. It simply touches a flag
35-- file, that can then be used to detect when scripts such as
36-- monotone-mirror.sh should be executed.
37--
38-- in your server's monotonerc, add the following include:
39--
40--include("/PATH/TO/monotone-inotify.lua")
41--
42-- You may want to change the following variables:
43--
44--MI_flagfile
45--The absolute path for a file that will simply
46--be touched by the note_netsync_end hook.
47--Default: CONFDIR/monotone-netsync-end.flag
48--
49--WARNING! Do not try to store anything in that
50--file, it will get erased...
51-------------------------------------------------------------------------------
52
53-------------------------------------------------------------------------------
54-- Variables
55-------------------------------------------------------------------------------
56MI_default_flagfile = get_confdir() .. "/monotone-netsync-end.flag"
57MI_default_debug = false
58
59
60if not MI_flagfile then MI_flagfile = MI_default_flagfile end
61if not MI_debug then MI_debug = MI_default_debug end
62
63-------------------------------------------------------------------------------
64-- Local hack of the note_netsync_* functions
65-------------------------------------------------------------------------------
66push_netsync_notifier(
67 {
68 ["end"] =
69 function (nonce, status,
70 bytes_in, bytes_out,
71 certs_in, certs_out,
72 revs_in, revs_out,
73 keys_in, keys_out,
74 ...)
75 if MI_debug then
76 io.stderr:write("note_netsync_end: ",
77 string.format("%d certs, %d revs, %d keys",
78 certs_in, revs_in, keys_in),
79 "\n")
80 end
81 if certs_in > 0 or revs_in > 0 or keys_in > 0 then
82 if MI_debug then
83 io.stderr:write("note_netsync_end: touching ", MI_flagfile, "\n")
84 end
85 local handle = io.open(MI_flagfile, "w+")
86 io.close(handle)
87 end
88 end
89 })

Archive Download this file

Branches

Tags

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