forked from hummingbot/hummingbot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update-gateway.sh
executable file
·104 lines (82 loc) · 2.06 KB
/
update-gateway.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
103
104
#!/bin/bash
# init
# =============================================
# Specify hummingbot version
select_version () {
echo
echo
echo "=============== UPDATE GATEWAY INSTANCE ==============="
echo
echo
echo "ℹ️ Press [ENTER] for default values:"
echo
read -p " Enter Gateway version to update [latest/development] (default = \"latest\") >>> " TAG
if [ "$TAG" == "" ]
then
TAG="latest"
fi
}
# List all docker instances using the same image
list_instances () {
echo
echo "List of all docker containers using the \"$TAG\" version:"
echo
docker ps -a --filter ancestor=coinalpha/gateway-api:$TAG
echo
}
# Execute docker commands
execute_docker () {
if [ ! "$INSTANCE_NAME" == "" ]
then
# 1) Delete instance and old gateway-api image
echo
echo "Stopping container: $INSTANCE_NAME"
docker stop $INSTANCE_NAME
echo "Removing container: $INSTANCE_NAME"
docker rm $INSTANCE_NAME
echo
fi
echo
read -p " Proceed with update? [Y/N] >>> " PROCEED
if [[ ! "$PROCEED" == "Y" && ! "$PROCEED" == "y" ]]
then
echo "Abort"
exit
fi
# 2) Delete old image
echo
read -p " Delete current docker image coinalpha/gateway-api:$TAG? [Y/N] >>> " DELETE_IMAGE
if [[ "$DELETE_IMAGE" == "Y" || "$DELETE_IMAGE" == "y" ]]
then
echo
echo "Deleting old image: coinalpha/gateway-api:$TAG"
docker image rm coinalpha/gateway-api:$TAG
echo
fi
#3 ) Pull docker image
echo
read -p " Pulling docker image coinalpha/gateway-api:$TAG [Y/N] >>> " PULL_IMAGE
if [[ "$PULL_IMAGE" == "Y" || "$PULL_IMAGE" == "y" ]]
then
docker pull coinalpha/gateway-api:$TAG
echo
fi
# 4) Re-create instances with the most recent hummingbot version
echo
echo " Re-creating docker containers with updated image ..."
./create-gateway.sh
echo
echo " Listing current running docker instances"
docker ps
echo
echo
}
select_version
# get container instances
list_instances
# Ask the user for the name of the new Gateway instance
read -p " Enter a name for your new Gateway instance to update >>> " INSTANCE_NAME
execute_docker
#
echo "✅ Update complete!"
echo