summaryrefslogtreecommitdiffstats
path: root/libexec/post-receive.d/04-build-web-test
diff options
context:
space:
mode:
Diffstat (limited to 'libexec/post-receive.d/04-build-web-test')
-rwxr-xr-xlibexec/post-receive.d/04-build-web-test51
1 files changed, 51 insertions, 0 deletions
diff --git a/libexec/post-receive.d/04-build-web-test b/libexec/post-receive.d/04-build-web-test
new file mode 100755
index 0000000..39974a5
--- /dev/null
+++ b/libexec/post-receive.d/04-build-web-test
@@ -0,0 +1,51 @@
1#!/bin/sh
2#
3# Copyright (c) 2013 Nagios Plugins Development Team
4#
5# Originally written by Holger Weiss <holger@zedat.fu-berlin.de>.
6#
7# This file is free software; the Nagios Plugins Development Team gives
8# unlimited permission to copy and/or distribute it, with or without
9# modifications, as long as this notice is preserved.
10#
11# This program is distributed in the hope that it will be useful, but WITHOUT
12# ANY WARRANTY, to the extent permitted by law; without even the implied
13# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
15set -e
16set -u
17
18export PATH='/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin'
19
20prefix='/home/plugins'
21test_directory="$prefix/web/test"
22
23#
24# Check whether the "test" branch of the "site.git" repository has been updated.
25#
26if [ "${PWD##*/}" = 'site.git' ]
27then
28 forty_zeros=$(printf '%.40d' '0')
29
30 while read old new ref
31 do
32 if [ "$ref" = 'refs/heads/test' ]
33 then
34 if [ "$new" != "$forty_zeros" ]
35 then
36 "$prefix/bin/git-export" -b 'test' "$PWD"
37 "$prefix/bin/build-web-site" -t >'/dev/null'
38 else
39 rm -rf "$prefix/exported/site-test"
40 rm -rf "$test_directory"/*
41 fi
42
43 # Always put a robots.txt into the $test_directory.
44 cat >>"$test_directory/robots.txt" <<-'EOF'
45 User-agent: *
46 Disallow: /
47 EOF
48 break
49 fi
50 done
51fi