summaryrefslogtreecommitdiff
path: root/hooks
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2013-10-27 15:14:18 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2013-10-27 15:14:18 +0100
commit0d92ff5fd34d79b54c30c38ac41bc600acf7b7c4 (patch)
tree7807b9d017e44bc522a75f40c7a4589d994455f8 /hooks
parent5821a949035a5e098a2c6b395818f5efa1c66f8e (diff)
downloadappstore-0d92ff5fd34d79b54c30c38ac41bc600acf7b7c4.tar.gz
appstore-0d92ff5fd34d79b54c30c38ac41bc600acf7b7c4.tar.bz2
appstore-0d92ff5fd34d79b54c30c38ac41bc600acf7b7c4.tar.xz
appstore-0d92ff5fd34d79b54c30c38ac41bc600acf7b7c4.zip
o Dropping the CSV file for using a native app config file instead.
o Using apache as an example app. o Adding appstore-add-app as a utility to register appliations.
Diffstat (limited to 'hooks')
-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."