blob: cbbf0f70498a4f1374d9a0573c922f2b26e41eeb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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 *$$
|