-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsnapshotter_autofill.sh
executable file
·200 lines (150 loc) · 6.94 KB
/
snapshotter_autofill.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
#!/bin/bash
source .env
echo 'populating setting from environment values...';
if [ -z "$SOURCE_RPC_URL" ]; then
echo "RPC URL not found, please set this in your .env!";
exit 1;
fi
if [ -z "$SIGNER_ACCOUNT_ADDRESS" ]; then
echo "SIGNER_ACCOUNT_ADDRESS not found, please set this in your .env!";
exit 1;
fi
if [ -z "$PROST_RPC_URL" ]; then
echo "PROST_RPC_URL not found, please set this in your .env!";
exit 1;
fi
if [ -z "$SLOT_ID" ]; then
echo "SLOT_ID not found, please set this in your .env!";
exit 1;
fi
if [ -z "$PROTOCOL_STATE_CONTRACT" ]; then
echo "PROTOCOL_STATE_CONTRACT not found, please set this in your .env!";
exit 1;
fi
if [ -z "$SIGNER_ACCOUNT_PRIVATE_KEY" ]; then
echo "SIGNER_ACCOUNT_PRIVATE_KEY not found, please set this in your .env!";
exit 1;
fi
echo "Found SOURCE RPC URL ${SOURCE_RPC_URL}";
echo "Found SIGNER ACCOUNT ADDRESS ${SIGNER_ACCOUNT_ADDRESS}";
if [ "$IPFS_URL" ]; then
echo "Found IPFS_URL ${IPFS_URL}";
fi
if [ "$SLACK_REPORTING_URL" ]; then
echo "Found SLACK_REPORTING_URL ${SLACK_REPORTING_URL}";
fi
if [ "$DATA_MARKET_CONTRACT" ]; then
echo "Found DATA_MARKET_CONTRACT ${DATA_MARKET_CONTRACT}";
fi
if [ "$POWERLOOM_REPORTING_URL" ]; then
echo "Found POWERLOOM_REPORTING_URL ${POWERLOOM_REPORTING_URL}";
fi
if [ "$TELEGRAM_REPORTING_URL" ]; then
echo "Found TELEGRAM_REPORTING_URL ${TELEGRAM_REPORTING_URL}";
fi
if [ "$TELEGRAM_CHAT_ID" ]; then
echo "Found TELEGRAM_CHAT_ID ${TELEGRAM_CHAT_ID}";
fi
if [ "$NAMESPACE" ]; then
echo "Found NAMESPACE ${NAMESPACE}";
fi
if [ "$REDIS_HOST" ]; then
echo "Found REDIS_HOST ${REDIS_HOST}";
fi
if [ "$REDIS_PORT" ]; then
echo "Found REDIS_PORT ${REDIS_PORT}";
fi
if [ "$REDIS_PASSWORD" ]; then
echo "Found REDIS_PASSWORD. Not echoing back.";
fi
if [ "$IPFS_S3_CONFIG_ENABLED" = "true" ]; then
echo "Found IPFS_S3_CONFIG_ENABLED ${IPFS_S3_CONFIG_ENABLED}";
export ipfs_s3_config_enabled="${IPFS_S3_CONFIG_ENABLED}";
export ipfs_s3_config_endpoint_url="${IPFS_S3_CONFIG_ENDPOINT_URL}";
export ipfs_s3_config_bucket_name="${IPFS_S3_CONFIG_BUCKET_NAME}";
export ipfs_s3_config_access_key="${IPFS_S3_CONFIG_ACCESS_KEY}";
export ipfs_s3_config_secret_key="${IPFS_S3_CONFIG_SECRET_KEY}";
else
export ipfs_s3_config_enabled="false";
export ipfs_s3_config_endpoint_url="";
export ipfs_s3_config_bucket_name="";
export ipfs_s3_config_access_key="";
export ipfs_s3_config_secret_key="";
fi
cp config/projects.example.json config/projects.json
cp config/settings.example.json config/settings.json
cp config/auth_settings.example.json config/auth_settings.json
cp config/aggregator.example.json config/aggregator.json
export namespace="${NAMESPACE:-namespace_hash}"
export ipfs_url="${IPFS_URL:-}"
export ipfs_api_key="${IPFS_API_KEY:-}"
export ipfs_api_secret="${IPFS_API_SECRET:-}"
export local_collector_port="${LOCAL_COLLECTOR_PORT:-50051}"
export slack_reporting_url="${SLACK_REPORTING_URL:-}"
export powerloom_reporting_url="${POWERLOOM_REPORTING_URL:-}"
export telegram_reporting_url="${TELEGRAM_REPORTING_URL:-}"
export telegram_chat_id="${TELEGRAM_CHAT_ID:-}"
# If IPFS_URL is empty, clear IPFS API key and secret
if [ -z "$IPFS_URL" ]; then
ipfs_api_key=""
ipfs_api_secret=""
fi
echo "Using Namespace: ${namespace}"
echo "Using Prost RPC URL: ${PROST_RPC_URL}"
echo "Using IPFS URL: ${ipfs_url}"
echo "Using IPFS API KEY: ${ipfs_api_key}"
echo "Using protocol state contract: ${PROTOCOL_STATE_CONTRACT}"
echo "Using data market contract: ${DATA_MARKET_CONTRACT}"
echo "Using slack reporting url: ${slack_reporting_url}"
echo "Using powerloom reporting url: ${powerloom_reporting_url}"
echo "Using telegram reporting url: ${telegram_reporting_url}"
echo "Using telegram chat id: ${telegram_chat_id}"
echo "Using REDIS_HOST: ${REDIS_HOST}"
echo "Using REDIS_PORT: ${REDIS_PORT}"
sed -i'.backup' "s#relevant-namespace#$namespace#" config/settings.json
sed -i'.backup' "s#account-address#$SIGNER_ACCOUNT_ADDRESS#" config/settings.json
sed -i'.backup' "s#slot-id#$SLOT_ID#" config/settings.json
sed -i'.backup' "s#https://rpc-url#$SOURCE_RPC_URL#" config/settings.json
sed -i'.backup' "s#https://prost-rpc-url#$PROST_RPC_URL#" config/settings.json
sed -i'.backup' "s#ipfs-writer-url#$ipfs_url#" config/settings.json
sed -i'.backup' "s#ipfs-writer-key#$ipfs_api_key#" config/settings.json
sed -i'.backup' "s#ipfs-writer-secret#$ipfs_api_secret#" config/settings.json
sed -i'.backup' "s#ipfs-reader-url#$ipfs_url#" config/settings.json
sed -i'.backup' "s#ipfs-reader-key#$ipfs_api_key#" config/settings.json
sed -i'.backup' "s#ipfs-reader-secret#$ipfs_api_secret#" config/settings.json
sed -i'.backup' "s#protocol-state-contract#$PROTOCOL_STATE_CONTRACT#" config/settings.json
sed -i'.backup' "s#data-market-contract#$DATA_MARKET_CONTRACT#" config/settings.json
sed -i'.backup' "s#https://slack-reporting-url#$slack_reporting_url#" config/settings.json
sed -i'.backup' "s#https://powerloom-reporting-url#$powerloom_reporting_url#" config/settings.json
sed -i'.backup' "s#signer-account-private-key#$SIGNER_ACCOUNT_PRIVATE_KEY#" config/settings.json
sed -i'.backup' "s#local-collector-port#$local_collector_port#" config/settings.json
sed -i'.backup' "s#https://telegram-reporting-url#$telegram_reporting_url#" config/settings.json
sed -i'.backup' "s#telegram-chat-id#$telegram_chat_id#" config/settings.json
sed -i'.backup' "s#redis-host#$REDIS_HOST#" config/settings.json
sed -i'.backup' "s#\"redis-port\"#$REDIS_PORT#" config/settings.json
if [ "$REDIS_PASSWORD" ]; then
sed -i'.backup' "s#\"redis-password\"#\"$REDIS_PASSWORD\"#" config/settings.json
else
sed -i'.backup' "s#\"redis-password\"#null#" config/settings.json
fi
sed -i'.backup' "s#ipfs-s3-config-enabled#$ipfs_s3_config_enabled#" config/settings.json
sed -i'.backup' "s#ipfs-s3-endpoint-url#$ipfs_s3_config_endpoint_url#" config/settings.json
sed -i'.backup' "s#ipfs-s3-bucket-name#$ipfs_s3_config_bucket_name#" config/settings.json
sed -i'.backup' "s#ipfs-s3-access-key#$ipfs_s3_config_access_key#" config/settings.json
sed -i'.backup' "s#ipfs-s3-secret-key#$ipfs_s3_config_secret_key#" config/settings.json
# Add the same replacements for auth_settings.json
sed -i'.backup' "s#redis-host#$REDIS_HOST#" config/auth_settings.json
sed -i'.backup' "s#\"redis-port\"#$REDIS_PORT#" config/auth_settings.json
if [ "$REDIS_PASSWORD" ]; then
sed -i'.backup' "s#\"redis-password\"#\"$REDIS_PASSWORD\"#" config/auth_settings.json
else
sed -i'.backup' "s#\"redis-password\"#null#" config/auth_settings.json
fi
# Set default rate limits
SOURCE_RPC_RATE_LIMIT="${SOURCE_RPC_RATE_LIMIT:-10}"
PROST_RPC_RATE_LIMIT="${PROST_RPC_RATE_LIMIT:-10}"
echo "Using SOURCE RPC Rate Limit: ${SOURCE_RPC_RATE_LIMIT}"
echo "Using PROST RPC Rate Limit: ${PROST_RPC_RATE_LIMIT}"
sed -i'.backup' "s/\"source-rpc-rate-limit\"/$SOURCE_RPC_RATE_LIMIT/" config/settings.json
sed -i'.backup' "s/\"prost-rpc-rate-limit\"/$PROST_RPC_RATE_LIMIT/" config/settings.json
echo 'settings has been populated!'