From 34e60841a44ee688792e87863aa67db469d39fa8 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Tue, 22 Oct 2013 20:40:50 +0200 Subject: wip --- hooks/common | 3 --- hooks/post-commit | 10 ---------- hooks/post-receive | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 13 deletions(-) delete mode 100755 hooks/common delete mode 100755 hooks/post-commit create mode 100755 hooks/post-receive (limited to 'hooks') diff --git a/hooks/common b/hooks/common deleted file mode 100755 index 7a693aa..0000000 --- a/hooks/common +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - - diff --git a/hooks/post-commit b/hooks/post-commit deleted file mode 100755 index 63508c2..0000000 --- a/hooks/post-commit +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -set -e -set -u - -APPSTORE_HOME=$(cd $(dirname "$0")/.. && pwd) - -. $APPSTORE_HOME/hooks/common - -echo "post-commit!!" diff --git a/hooks/post-receive b/hooks/post-receive new file mode 100755 index 0000000..ced1fc4 --- /dev/null +++ b/hooks/post-receive @@ -0,0 +1,55 @@ +#!/bin/bash + +set -e +set -u + +APPSTORE_HOME=$(cd $(dirname "$0")/.. && pwd) + +. $APPSTORE_HOME/lib/common +# HEADER END + +# stdin contains the refs pushed. + +APPS="$(git config appstore.apps)" + +REPO="$(pwd)" + +cd "$APPS" + +unset GIT_DIR +git pull -q "$REPO" master + +IFS=$'\t' +csvtool -u TAB namedcol dir,resolver,resolver_args,version,state apps.csv | \ +while read dir resolver resolver_args version state +do + if [ -d "$dir" ] + then + cd $dir + old_version=$(app conf get app.version) + + if [[ $new_version == $old_version ]] + then + continue + fi + + echo "Updating $dir to $version" + app conf set app.version "$version" + app update + cd .. + else + echo "New application: $dir" + app init -d "$dir" "$resolver" "$resolver_args" + fi + + cd "$dir" + if [[ $state == enabled ]] + then + echo "Starting appliation" + app start + else + echo "Stopping appliation" + app stop + fi +done +unset IFS -- cgit v1.2.3