This repository was archived by the owner on Feb 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathutil.sh
executable file
·102 lines (89 loc) · 2.62 KB
/
util.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/bin/bash
set -e
repo="hyperhq/test-installer-debian"
tag="7.11"
image=${repo}:${tag}
container="test-installer-debian-wheezy"
# DOCKER0=$(ifconfig | grep docker0 -A1 | grep "inet " | awk '{print $2}')
# PROXY="http://${DOCKER0}:8118"
function build(){
echo "starting build..."
echo "=============================================================="
CMD="docker build --build-arg http_proxy=${PROXY} --build-arg https_proxy=${PROXY} -t ${image} ."
echo "CMD: [ ${CMD} ]"
eval $CMD
}
function push(){
echo -e "\nstarting push [${image}] ..."
echo "=============================================================="
docker push ${image}
}
function run() {
echo -e "\ncheck old conainer from [${image}] ..."
cnt=`docker ps -a --filter="name=${container}" | wc -l`
if [ $cnt -ne 1 ];then
docker rm -fv ${container}
fi
echo -e "\nrun conainer from [${image}] ..."
docker run -d -t \
--privileged \
--hostname ${container} \
--name ${container} \
--env HTTP_PROXY=$HTTP_PROXY --env HTTPS_PROXY=$HTTPS_PROXY \
-v `pwd`/../../../../hyper-installer:/hyper-installer \
$image sleep infinity
echo "---------------------------------------------------"
docker ps -a --filter="name=${container}"
cat <<EOF
---------------------------------------------------
Run the following command to enter container:
docker exec -it ${container} bash
EOF
}
function test_hyper() {
echo -e "\ncheck conainer from [${image}] ..."
cnt=`docker ps -a --filter="name=${container}" | wc -l`
if [ $cnt -eq 1 ];then
run
fi
docker exec -it ${container} bash -c "curl -sSL https://hyper.sh/install | bash"
}
function test_hypercontainer() {
echo -e "\ncheck conainer from [${image}] ..."
cnt=`docker ps -a --filter="name=${container}" | wc -l`
if [ $cnt -eq 1 ];then
run
fi
docker exec -it ${container} bash -c "curl -sSL https://hypercontainer.io/install | bash"
}
case "$1" in
"build")
build
;;
"push")
build
push
;;
"run")
run
;;
"test_hyper")
test_hyper
;;
"test_hypercontainer")
test_hypercontainer
;;
*)
cat <<EOF
usage:
./util.sh build # build only
./util.sh push # build and push
./util.sh run # run only
./util.sh test_hyper # test install script for hypercli of Hyper.sh
./util.sh test_hypercontainer # test install script for hypercontainer
EOF
exit 1
;;
esac
echo -e "\n=============================================================="
echo "Done!"