From 84c4a5d24cbef536b8248a3d8ff72bb2b4248c29 Mon Sep 17 00:00:00 2001 From: Holger Weiss Date: Sat, 5 Oct 2013 00:56:26 +0200 Subject: Add test instance of the web site Serve https://www.nagios-plugins.org:444/ from the "test" branch of this repository. --- libexec/post-receive.d/01-git-export | 22 +++++++++++++++ libexec/post-receive.d/04-build-web-site | 46 +++++++++++++++++++++++--------- 2 files changed, 55 insertions(+), 13 deletions(-) (limited to 'libexec/post-receive.d') diff --git a/libexec/post-receive.d/01-git-export b/libexec/post-receive.d/01-git-export index 37994e2..171f05f 100755 --- a/libexec/post-receive.d/01-git-export +++ b/libexec/post-receive.d/01-git-export @@ -19,4 +19,26 @@ export PATH='/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin' prefix='/home/plugins' +# +# Check whether the "test" branch of the "site.git" repository has been updated. +# +if [ "${PWD##*/}" = 'site.git' ] +then + forty_zeros=$(printf '%.40d' '0') + + while read old new ref + do + if [ "$ref" = 'refs/heads/test' ] + then + if [ "$new" != "$forty_zeros" ] + then + "$prefix/bin/git-export" -b 'test' "$PWD" + else + rm -rf "$prefix/exported/site-test" + fi + break + fi + done +fi + exec "$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 7c178cf..6338968 100755 --- a/libexec/post-receive.d/04-build-web-site +++ b/libexec/post-receive.d/04-build-web-site @@ -19,17 +19,37 @@ export PATH='/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin' prefix='/home/plugins' repository=${PWD##*/} -web_repositories='nagios-plugins.git site.git' -web_branch='master' +plugins_repository='nagios-plugins.git' +web_repository='site.git' +prod_branch='master' +test_branch='test' +test_directory="$prefix/web/test" -for web_repository in $web_repositories -do - if [ "$repository" = "$web_repository" ] - then - while read old new ref - do - test "${ref#refs/heads/}" = "$web_branch" \ - && exec "$prefix/bin/build-web-site" >'/dev/null' - done - fi -done +if [ "$repository" = "$plugins_repository" ] \ + || [ "$repository" = "$web_repository" ] +then + forty_zeros=$(printf '%.40d' '0') + + while read old new ref + do + branch=${ref#refs/heads/} + + if [ "$branch" = "$prod_branch" ] + then + "$prefix/bin/build-web-site" >'/dev/null' + elif [ "$repository" = "$web_repository" ] \ + && [ "$branch" = "$test_branch" ] + then + if [ "$new" != "$forty_zeros" ] + then + "$prefix/bin/build-web-site" -t >'/dev/null' + else + rm -rf "$test_directory"/* + fi + cat >>"$test_directory/robots.txt" <<-'EOF' + User-agent: * + Disallow: / + EOF + fi + done +fi -- cgit v1.2.3-74-g34f1