summaryrefslogtreecommitdiff
path: root/hooks/post-receive
diff options
context:
space:
mode:
Diffstat (limited to 'hooks/post-receive')
-rwxr-xr-xhooks/post-receive84
1 files changed, 58 insertions, 26 deletions
diff --git a/hooks/post-receive b/hooks/post-receive
index e0375c3..c52ac9c 100755
--- a/hooks/post-receive
+++ b/hooks/post-receive
@@ -10,19 +10,28 @@ APPSTORE_HOME=$(git config appstore.home)
# stdin contains the refs pushed.
-APPS="$(git config appstore.apps)"
+conf_get() {
+ name=$1; shift
+ var=$1; shift
+ value=$(app cat-conf -f "$APPS/appstore.config" -k "$var" | cut -f 2- -d =)
+ eval ${name}='${value}'
+}
-REPO="$(pwd)"
+check_app() {
+ local app=$1; shift
-cd "$APPS"
+ dir=$app
+ conf_get resolver "${app}.resolver"
+ conf_get resolver_args "${app}.resolver_args"
+ conf_get version "${app}.version"
+ conf_get state "${app}.state"
-unset GIT_DIR
-git pull -q "$REPO" master
+ if [[ -z $resolver ]] || [[ -z $resolver_args ]] || [[ -z $version ]] || [[ -z $state ]]
+ then
+ echo "$app: invalid configuration, missing one of ${app}.resolver, ${app}.resolver_args, ${app}.version, ${app}.state"
+ return
+ fi
-IFS=$'\t'
-csvtool -u TAB namedcol dir,resolver,resolver_args,version,state apps.csv | \
-while read dir resolver resolver_args version state
-do
cd "$APPS"
if [ -d "$dir" ]
@@ -31,40 +40,63 @@ do
dir=`pwd`
old_version=$(app conf get app.version)
- if [[ $new_version == $old_version ]]
+ if [[ $new_version = $old_version ]]
then
+ echo "$dir: already at $version"
continue
fi
- echo "Updating $dir to $version"
+ echo "$dir: updating to $version"
app conf set app.version "$version"
app update
else
- echo "New application: $dir"
- app init -d "$dir" "$resolver" "$resolver_args"
+ echo "$dir: new app"
+ if [[ -r ${dir}.config ]]
+ then
+ append_config="${dir}.config"
+ fi
+
+ app init \
+ ${append_config:+-c} $append_config \
+ -d "$dir" \
+ "$resolver" "$resolver_args"
cd "$dir"
dir=`pwd`
fi
cd "$dir"
- if [[ $state == enabled ]]
+
+ if [[ $state = enabled ]]
then
- cmd=start
- title="Starting"
+ app start || true
else
- cmd=stop
- title="Stopping"
+ app stop || true
fi
+}
- echo "$title appliation"
- set +e
- app $cmd
- ret=$?
- set -e
+APPS="$(git config appstore.apps)"
- if [[ $ret != 0 ]]
+REPO="$(pwd)"
+
+cd "$APPS"
+
+unset GIT_DIR
+git pull -q "$REPO" master
+
+conf_get apps appstore.apps
+apps=$(echo "$apps" | sed "s/, */,/g")
+
+IFS=,
+for app in $apps
+do
+ if [[ $app = "" ]]
then
- echo "$cmd command failed."
+ continue
fi
+
+ assert_valid_app_name "$app"
+
+ check_app "$app" || true
done
-unset IFS
+
+echo "Done."