-
Notifications
You must be signed in to change notification settings - Fork 2
/
relay.sh
91 lines (73 loc) · 2.18 KB
/
relay.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
#!/bin/bash
set -e
# install docker by default
if [[ -z $NO_DOCKER_INSTALL ]]; then
apt-get remove -y docker docker-engine docker.io containerd runc && \
apt-get update && \
apt-get install -y \
ca-certificates \
curl \
gnupg \
lsb-release
mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
apt-get update
apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
fi
echo "Please enter your private key"
read -sp 'Ambrosus private key: ' AMB_PRIVATE_KEY
while true;
do
echo -e "\n"
if [ ${#AMB_PRIVATE_KEY} -ne 64 ];
then read -sp 'Key length should be 64 characters, type again: ' AMB_PRIVATE_KEY;
else break
fi
done
read -sp 'Ethereum private key: ' ETH_PRIVATE_KEY
while true;
do
echo -e "\n"
if [ ${#ETH_PRIVATE_KEY} -ne 64 ];
then read -sp 'Key length should be 64 characters, type again: ' ETH_PRIVATE_KEY;
else break
fi
done
echo -e "\nPlease enter your token (issued by the bridge developers)"
read -sp 'Token: ' EXTERNALLOGGER_TELEGRAM_TOKEN
while true;
do
echo -e "\n"
if [ ${#EXTERNALLOGGER_TELEGRAM_TOKEN} -ne 46 ];
then read -sp 'Token length should be 46 characters, type again: ' EXTERNALLOGGER_TELEGRAM_TOKEN;
else break
fi
done
set +e
docker rm -f eth-relay
set -e
IMAGE=ghcr.io/ambrosus/ambrosus-bridge
STAGE=${STAGE:-prod}
if [ $STAGE == "prod" ]; then
TAG=latest
elif [ $STAGE == "test" ]; then
TAG=dev
elif [ $STAGE == "dev" ]; then
TAG=dev
fi
docker pull $IMAGE:$TAG
echo "Starting relay..."
docker run -d \
--name eth-relay \
--restart unless-stopped \
-e STAGE=$STAGE \
-e NETWORK=eth-untrustless \
-e NETWORKS_AMB_PRIVATEKEY=$AMB_PRIVATE_KEY \
-e NETWORKS_ETH_PRIVATEKEY=$ETH_PRIVATE_KEY \
-e EXTERNALLOGGER_TELEGRAM_TOKEN=$EXTERNALLOGGER_TELEGRAM_TOKEN \
$IMAGE:$TAG >> /dev/null
sleep 10
docker logs eth-relay