forked from hummingbot/gateway
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gateway-setup.sh
executable file
·85 lines (75 loc) · 2.04 KB
/
gateway-setup.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
#!/bin/bash
# init
echo
echo
echo "=============== SETUP GATEWAY ==============="
echo
echo
HOST_CONF_PATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )/conf"
TEMPLATE_DIR="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )/src/templates"
CERTS_TO_PATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )/certs"
# Ask for path to Hummingbot certs folder
read -p "Enter path to the Hummingbot certs folder >>> " CERTS_FROM_PATH
if [ ! -d "$CERTS_FROM_PATH" ]; then
echo "Error: $CERTS_FROM_PATH does not exist or is not a directory"
exit
fi
prompt_proceed () {
read -p "Do you want to proceed? [Y/N] >>> " PROCEED
if [ "$PROCEED" == "" ]
then
prompt_proceed
else
if [[ "$PROCEED" != "Y" && "$PROCEED" != "y" ]]
then
PROCEED="N"
fi
fi
}
copy_configs () {
echo
# Make destination folder if needed
mkdir $HOST_CONF_PATH
# Copy all files in the source folder to the destination folder
cp $TEMPLATE_DIR/**.yml $HOST_CONF_PATH
# Confirm that the files were copied
if [ $? -eq 0 ]; then
echo "Files successfully copied from $TEMPLATE_DIR to $HOST_CONF_PATH"
else
echo "Error copying files from $TEMPLATE_DIR to $HOST_CONF_PATH"
exit
fi
}
copy_certs () {
echo
# Make destination folder if needed
mkdir $CERTS_TO_PATH
# Copy all files in the source folder to the destination folder
cp -r $CERTS_FROM_PATH/* $CERTS_TO_PATH/
# Confirm that the files were copied
if [ $? -eq 0 ]; then
echo "Files successfully copied from $CERTS_FROM_PATH to $CERTS_TO_PATH"
else
echo "Error copying files from $CERTS_FROM_PATH to $CERTS_TO_PATH"
exit
fi
}
# Ask user to confirm and proceed
echo
echo "ℹ️ Confirm if this is correct:"
echo
printf "%30s %5s\n" "Copy configs FROM:" "$TEMPLATE_DIR"
printf "%30s %5s\n" "Copy configs TO:" "$HOST_CONF_PATH"
echo
printf "%30s %5s\n" "Copy certs FROM:" "$CERTS_FROM_PATH"
printf "%30s %5s\n" "Copy certs TO:" "$CERTS_TO_PATH"
echo
prompt_proceed
if [[ "$PROCEED" == "Y" || "$PROCEED" == "y" ]]
then
copy_configs
copy_certs
else
echo "Exiting..."
exit
fi