summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2013-10-22 20:40:50 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2013-10-22 20:40:50 +0200
commit34e60841a44ee688792e87863aa67db469d39fa8 (patch)
treed4ec57728121d87b029d8b729c98494356015061 /bin
parent4452df33f080c314f9b4c6a6504f254edc500282 (diff)
downloadappstore-34e60841a44ee688792e87863aa67db469d39fa8.tar.gz
appstore-34e60841a44ee688792e87863aa67db469d39fa8.tar.bz2
appstore-34e60841a44ee688792e87863aa67db469d39fa8.tar.xz
appstore-34e60841a44ee688792e87863aa67db469d39fa8.zip
wip
Diffstat (limited to 'bin')
-rwxr-xr-xbin/appstore-init57
1 files changed, 57 insertions, 0 deletions
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 *$$