forked from yunionio/ocboot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathocboot.sh
executable file
·44 lines (34 loc) · 877 Bytes
/
ocboot.sh
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
#!/bin/bash
set -e
REGISTRY=${REGISTRY:-registry.cn-beijing.aliyuncs.com/yunionio}
VERSION=${VERSION:-v3.11-buildah.1}
OCBOOT_IMAGE="$REGISTRY/ocboot:$VERSION"
CUR_DIR="$(pwd)"
CONTAINER_NAME="buildah-ocboot"
buildah_from_image() {
if buildah ps | grep $CONTAINER_NAME; then
buildah rm $CONTAINER_NAME
fi
local img="$1"
echo "Using buildah pull $img"
buildah from --name $CONTAINER_NAME "$img"
}
buildah_from_image "$OCBOOT_IMAGE"
mkdir -p "$HOME/.ssh"
CMD=""
is_ocboot_subcmd() {
local subcmds="install upgrade add-node add-lbagent backup restore"
for subcmd in $subcmds; do
if [[ "$1" == "$subcmd" ]]; then
return 0
fi
done
return 1
}
if is_ocboot_subcmd $1; then
CMD="ocboot.py"
fi
buildah run -t \
-v "$HOME/.ssh:/root/.ssh" \
-v "$(pwd):/ocboot" \
"$CONTAINER_NAME" $CMD $@