summaryrefslogtreecommitdiff
path: root/hooks/post-receive
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2013-10-22 20:40:50 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2013-10-22 20:40:50 +0200
commit34e60841a44ee688792e87863aa67db469d39fa8 (patch)
treed4ec57728121d87b029d8b729c98494356015061 /hooks/post-receive
parent4452df33f080c314f9b4c6a6504f254edc500282 (diff)
downloadappstore-34e60841a44ee688792e87863aa67db469d39fa8.tar.gz
appstore-34e60841a44ee688792e87863aa67db469d39fa8.tar.bz2
appstore-34e60841a44ee688792e87863aa67db469d39fa8.tar.xz
appstore-34e60841a44ee688792e87863aa67db469d39fa8.zip
wip
Diffstat (limited to 'hooks/post-receive')
-rwxr-xr-xhooks/post-receive55
1 files changed, 55 insertions, 0 deletions
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