From 5dd16e14dd41f1565687142ba7cefa7c4cf64658 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Tue, 12 Nov 2013 13:39:41 +0100 Subject: wip --- libexec/appstore-init-server | 50 ---------------------- libexec/appstore-server-init | 50 ++++++++++++++++++++++ libexec/appstore-server-sync | 99 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 149 insertions(+), 50 deletions(-) delete mode 100755 libexec/appstore-init-server create mode 100755 libexec/appstore-server-init create mode 100755 libexec/appstore-server-sync (limited to 'libexec') diff --git a/libexec/appstore-init-server b/libexec/appstore-init-server deleted file mode 100755 index 1417469..0000000 --- a/libexec/appstore-init-server +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/bash - -set -e -set -u - -APPSTORE_HOME=$(cd $(dirname "$0")/.. && pwd) - -. $APPSTORE_HOME/lib/common -# HEADER END - -root=$1; shift -name=$1; shift - -echo "Creating appstore $name" - -repo="$root/repos/$name" -apps="$root/appstores/$name" - -if [ -e "$repo" ] -then - echo "$name already exist!" - exit 1 -fi - -# Create the git repository -git init -q --bare "$repo" - -# Clone the repository -git init -q "$apps" -cd "$apps" - -# Copy the template project -cp -r "$APPSTORE_HOME/template/"* . -git add -A -git config user.name "Appstore Bot" -git config user.email nobody@example.org -git commit -q -m "Created new appstore: $name." -git push -q "$repo" master -cd .. - -# Install the hooks -cd "$repo" -pwd -rm hooks/* -rmdir hooks -ln -s "$APPSTORE_HOME/hooks" hooks -git config appstore.home "$APPSTORE_HOME" -git config appstore.apps "$apps" - -echo "config: repo.path=$repo" diff --git a/libexec/appstore-server-init b/libexec/appstore-server-init new file mode 100755 index 0000000..a220f83 --- /dev/null +++ b/libexec/appstore-server-init @@ -0,0 +1,50 @@ +#!/bin/bash + +set -e +set -u + +APPSTORE_HOME=$(cd $(dirname "$0")/.. && pwd) + +. $APPSTORE_HOME/lib/common +# HEADER END + +repos=$1; shift +appstores=$1; shift +name=$1; shift + +echo "Creating appstore: $name" + +repo="$repos/$name" +appstore="$appstores/$name" + +if [ -e "$repo" ] +then + echo "$name already exist!" + exit 1 +fi + +# Create the git repository +git init -q --bare "$repo" + +# Clone the repository +git init -q "$appstore" +cd "$appstore" + +# Copy the template project +cp -r "$APPSTORE_HOME/template/"* . +git add -A +git config user.name "Appstore Bot" +git config user.email nobody@example.org +git commit -q -m "Created new appstore: $name." +git push -q "$repo" master +cd .. + +# Install the hooks +cd "$repo" +rm hooks/* +rmdir hooks +ln -s "$APPSTORE_HOME/hooks" hooks +git config appstore.home "$APPSTORE_HOME" +git config appstore.apps "$appstore" + +echo "config: repo.path=$repo" diff --git a/libexec/appstore-server-sync b/libexec/appstore-server-sync new file mode 100755 index 0000000..5938962 --- /dev/null +++ b/libexec/appstore-server-sync @@ -0,0 +1,99 @@ +#!/bin/bash + +set -e +set -u + +APPSTORE_HOME=$(cd $(dirname "$0")/.. && pwd) + +. $APPSTORE_HOME/lib/common +# HEADER END + +conf_get() { + name=$1; shift + var=$1; shift + value=$(app cat-conf -f "$APPSTORE/appstore.config" -k "$var" | cut -f 2- -d =) + eval ${name}='${value}' +} + +check_app() { + local app=$1; shift + + dir=$app + conf_get resolver "${app}.resolver" + conf_get resolver_args "${app}.resolver_args" + conf_get version "${app}.version" + conf_get state "${app}.state" + + 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 + + cd "$APPSTORE" + + if [[ -d $dir ]] + then + cd "$dir" + dir=`pwd` + + if [[ -r $APPSTORE/$app.config ]] + then + app conf import $APPSTORE/$app.config + fi + app conf set app.version "$version" + app upgrade + else + 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 ]] + then + app start || true + else + app stop || true + fi +} + +REPO="$1"; shift +APPSTORE="$1"; shift + +make_absolute REPO +make_absolute APPSTORE + +cd "$APPSTORE" + +# This should probably be a git fetch && checkout origin/HEAD --force +# or whatever. +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 + continue + fi + + assert_valid_app_name "$app" + + check_app "$app" || true +done + +echo "Done." -- cgit v1.2.3