-
Notifications
You must be signed in to change notification settings - Fork 5
/
start_my.sh
executable file
·73 lines (60 loc) · 2.71 KB
/
start_my.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
export FED_ENV=$1
export FED_ID=$2
# Error out early if there's any error in the script.
# Otherwise the errors can get uncaught and this wastes development time.
set -e
if [ -z "$FED_ENV" ]
then
echo "ERROR: please choose the federator env config as first cmd arg."
exit
fi
if [ -z "$FED_ID" ]
then
echo "ERROR: please provide uniqe id for this federator as second cmd arg."
exit
fi
./stop.sh
./reset_my.sh
echo "Enter pm2-public-key:"
read PM2_PUBLIC_KEY_VAL
echo "Enter pm2-secret-key:"
read PM2_SECRET_KEY_VAL
export PM2_PUBLIC_KEY=$PM2_PUBLIC_KEY_VAL
export PM2_SECRET_KEY=$PM2_SECRET_KEY_VAL
rm -rf /home/ubuntu/Bridge-SC/federator-env/$FED_ENV/telegram.key
echo "Enter telegram key:"
read TELEGRAM_KEY
echo "$TELEGRAM_KEY" > /home/ubuntu/Bridge-SC/federator-env/$FED_ENV/telegram.key
sed -i 's/federatorInstanceId_replace_this/'"$FED_ID-$FED_ENV"'/g' /home/ubuntu/Bridge-SC/federator-env/$FED_ENV/config.js
if [ "$FED_ENV" = "mainnet-ETH-RSK" ]; then
echo "Enter etherium mainnet RPC url:"
read ETHER_RPC
echo $(cat /home/ubuntu/Bridge-SC/federator-env/$FED_ENV/mainnet.json | jq --arg args "$ETHER_RPC" '."host"=$args') > /home/ubuntu/Bridge-SC/federator-env/$FED_ENV/mainnet.json
fi
if [ "$FED_ENV" = "testnet-ETH-RSK" ]; then
echo "Enter etherium testnet RPC url:"
read ETHER_RPC
echo $(cat /home/ubuntu/Bridge-SC/federator-env/$FED_ENV/ropsten.json | jq --arg args "$ETHER_RPC" '."host"=$args') > /home/ubuntu/Bridge-SC/federator-env/$FED_ENV/ropsten.json
fi
if [ "$FED_ENV" = "rinkeby-ETH-RSK" ]; then
echo "Enter etherium testnet RPC url:"
read ETHER_RPC
echo $(cat /home/ubuntu/Bridge-SC/federator-env/$FED_ENV/rinkeby.json | jq --arg args "$ETHER_RPC" '."host"=$args') > /home/ubuntu/Bridge-SC/federator-env/$FED_ENV/rinkeby.json
fi
echo "starting federator on $ED_ENV.. this should take 30 sec, please wait"
mkdir -p /home/ubuntu/Bridge-SC/federator-env/$FED_ENV/db
echo "createing db folder.."
echo "getting fed secret:"
FED_KEY_NAME=`aws ec2 describe-instances --filters Name=instance-id,Values=$(wget -qO- http://instance-data/latest/meta-data/instance-id
) --query "Reservations[].Instances[].Tags[?Key == 'Name'].Value" --output text`
FED_KEY=`aws secretsmanager get-secret-value --secret-id $FED_KEY_NAME --region us-east-2 | jq -r .SecretString`
echo using key named: $FED_KEY_NAME
cat << EOF > /home/ubuntu/Bridge-SC/federator-env/$FED_ENV/federator.key
$FED_KEY
EOF
echo "starting federator please wait..."
nohup 2>&1 docker-compose -f docker-compose-prod.yml up > federator.log &
sleep 30
echo "federator logs: /home/ubuntu/Bridge-SC/federator.log"
rm -rf /home/ubuntu/Bridge-SC/federator-env/$FED_ENV/federator.key
tail -f /home/ubuntu/Bridge-SC/federator.log