summaryrefslogtreecommitdiffstats
path: root/libexec
diff options
context:
space:
mode:
authorHolger Weiss <holger@zedat.fu-berlin.de>2013-10-06 23:53:18 (GMT)
committerHolger Weiss <holger@zedat.fu-berlin.de>2013-10-06 23:53:18 (GMT)
commit76af1279d9a4ab574d87e93466166b7b210c2bad (patch)
treebf6340b28aab2e275662b9a6198ded45db8f316c /libexec
parentb2c8b7821e7e4ff82c65f0ab360ae067dded9e94 (diff)
downloadsite-76af1279d9a4ab574d87e93466166b7b210c2bad.tar.gz
Move test site hooks into separate file
Put the code for creating the test instance into a separate hook file in order to make the other files less convoluted.
Diffstat (limited to 'libexec')
-rwxr-xr-xlibexec/post-receive.d/01-git-export22
-rwxr-xr-xlibexec/post-receive.d/04-build-web-site46
-rwxr-xr-xlibexec/post-receive.d/04-build-web-test51
3 files changed, 64 insertions, 55 deletions
diff --git a/libexec/post-receive.d/01-git-export b/libexec/post-receive.d/01-git-export
index 171f05f..37994e2 100755
--- a/libexec/post-receive.d/01-git-export
+++ b/libexec/post-receive.d/01-git-export
@@ -19,26 +19,4 @@ export PATH='/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin'
19 19
20prefix='/home/plugins' 20prefix='/home/plugins'
21 21
22#
23# Check whether the "test" branch of the "site.git" repository has been updated.
24#
25if [ "${PWD##*/}" = 'site.git' ]
26then
27 forty_zeros=$(printf '%.40d' '0')
28
29 while read old new ref
30 do
31 if [ "$ref" = 'refs/heads/test' ]
32 then
33 if [ "$new" != "$forty_zeros" ]
34 then
35 "$prefix/bin/git-export" -b 'test' "$PWD"
36 else
37 rm -rf "$prefix/exported/site-test"
38 fi
39 break
40 fi
41 done
42fi
43
44exec "$prefix/bin/git-export" "$PWD" 22exec "$prefix/bin/git-export" "$PWD"
diff --git a/libexec/post-receive.d/04-build-web-site b/libexec/post-receive.d/04-build-web-site
index 6338968..7c178cf 100755
--- a/libexec/post-receive.d/04-build-web-site
+++ b/libexec/post-receive.d/04-build-web-site
@@ -19,37 +19,17 @@ export PATH='/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin'
19 19
20prefix='/home/plugins' 20prefix='/home/plugins'
21repository=${PWD##*/} 21repository=${PWD##*/}
22plugins_repository='nagios-plugins.git' 22web_repositories='nagios-plugins.git site.git'
23web_repository='site.git' 23web_branch='master'
24prod_branch='master'
25test_branch='test'
26test_directory="$prefix/web/test"
27 24
28if [ "$repository" = "$plugins_repository" ] \ 25for web_repository in $web_repositories
29 || [ "$repository" = "$web_repository" ] 26do
30then 27 if [ "$repository" = "$web_repository" ]
31 forty_zeros=$(printf '%.40d' '0') 28 then
32 29 while read old new ref
33 while read old new ref 30 do
34 do 31 test "${ref#refs/heads/}" = "$web_branch" \
35 branch=${ref#refs/heads/} 32 && exec "$prefix/bin/build-web-site" >'/dev/null'
36 33 done
37 if [ "$branch" = "$prod_branch" ] 34 fi
38 then 35done
39 "$prefix/bin/build-web-site" >'/dev/null'
40 elif [ "$repository" = "$web_repository" ] \
41 && [ "$branch" = "$test_branch" ]
42 then
43 if [ "$new" != "$forty_zeros" ]
44 then
45 "$prefix/bin/build-web-site" -t >'/dev/null'
46 else
47 rm -rf "$test_directory"/*
48 fi
49 cat >>"$test_directory/robots.txt" <<-'EOF'
50 User-agent: *
51 Disallow: /
52 EOF
53 fi
54 done
55fi
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