summaryrefslogtreecommitdiff
path: root/hooks/post-receive
blob: ced1fc46d730409552eb38a0f781e9877e5ecd0e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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