From 34e60841a44ee688792e87863aa67db469d39fa8 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Tue, 22 Oct 2013 20:40:50 +0200 Subject: wip --- bin/appstore-init | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100755 bin/appstore-init (limited to 'bin/appstore-init') diff --git a/bin/appstore-init b/bin/appstore-init new file mode 100755 index 0000000..cbbf0f7 --- /dev/null +++ b/bin/appstore-init @@ -0,0 +1,57 @@ +#!/bin/bash + +set -e +set -u + +APPSTORE_HOME=$(cd $(dirname "$0")/.. && pwd) + +. $APPSTORE_HOME/lib/common +# HEADER END + +usage() { + echo "usage [server] [name]" + exit 1 +} + +if [ $# -ne 3 ] +then + usage +fi + +server=$1; shift +repos=$1; shift +name=$1; shift + +if [ -e "$name" ] +then + echo "$name already exist!" + exit 1 +fi + +tmpfile=tmpfile$$ +conffile=conffile$$ +echo "Creating remote appstore..." +set +e +ssh "$server" "$APPSTORE_HOME/libexec/appstore-init-server" "$repos" "$name" > "$tmpfile" 2>&1 +ret=$? +set -e + +sed -n "s,^config: \(.*\),\1,p" $tmpfile > $conffile +repo_path=`app cat-conf -f "$conffile" -n repo.path | cut -f 2- -d =` +repo_ok=`app cat-conf -f "$conffile" -n repo.ok | cut -f 2- -d =` + +if [ "$ret" != 0 ] +then + echo "Initialization failed. Server output:" + cat $tmpfile + exit 1 +fi + +echo "Cloning repository..." +git clone -q "$server:$repo_path" "$name" +cd $name +git remote rename origin cloud +cd .. + +echo "$name is open for cloud business!" +rm *$$ -- cgit v1.2.3