diff options
Diffstat (limited to 'bin/appstore-init')
-rwxr-xr-x | bin/appstore-init | 57 |
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 *$$ |