-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-watchtower-testnet
209 lines (166 loc) · 4.97 KB
/
install-watchtower-testnet
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
201
202
203
204
205
206
207
208
209
#!/bin/sh
echo
echo "==================================="
echo " Witnesschain WatchTower installer"
echo "==================================="
echo
cf="watchtower.config.json"
docker_name="--name watchtower"
docker_read_only=":ro"
docker_volume_mounts="-v /$(pwd)/$cf:/watchtower/src/client/config.json$docker_read_only"
docker_security_options="--security-opt=no-new-privileges --pids-limit=128"
docker_w3c_env="-e W3SECRETPASSPHRASE=${W3SECRETPASSPHRASE}"
if [ "${KEYSTORE_PATH}" = "" ]; then
docker_w3_keystore_path="-v ${KEYSTORE_PATH}:/watchtower.ecdsa.key.json"
else
docker_w3_keystore_path=""
fi
docker_options="$docker_security_options $docker_volume_mounts $docker_name"
#---------------- Build the docker-run.sh --------------------------------------
cat <<EOF > docker-run.sh
#!/bin/sh
echo
echo "========================="
echo " Witnesschain WatchTower"
echo "========================="
echo
host_name=\`cat $cf | grep host_name | cut -f4 -d'"'\`
if [ "\$host_name" = "" ]
then
docker_user_option="--user 65534:65534" # nobody user = 65534
else
docker_user_option="" # run as root as we need a certificate
fi
if [ -f $cf ]
then
error="no"
fields=""
fields="\${fields} private_key"
fields="\${fields} eth_testnet_websocket_url"
fields="\${fields} currently_watching_l2"
fields="\${fields} op_geth_rpc_url"
fields="\${fields} op_node_rpc_url"
fields="\${fields} l2oo_address"
fields_not_set=""
for f in \$fields
do
lines=\`cat $cf | grep \"\$f\" -n | tr -d ' '\`
for c in \`echo \$lines | cut -f1- -d,\`
do
line_no=\`echo \$c | cut -f1 -d':'\`
value=\`echo \$c | cut -f4 -d'"'\`
if [ "\$value" = "" ]
then
fields_not_set="\${fields_not_set} \$f:\$line_no"
error="yes"
fi
done
done
if [ "\$error" = "yes" ]
then
echo "❌ Please set the following fields in \"$cf\" at:"
for fl in \$fields_not_set
do
f=\`echo \$fl | cut -f1 -d':'\`
l=\`echo \$fl | cut -f2 -d':'\`
echo "\tLine no. \$l field \"\$f\""
done
echo
echo "🔵 Rerun the \"./docker-run.sh\""
echo
exit
fi
fi
docker run -d \$docker_user_option $docker_options $docker_w3c_env $docker_w3_keystore_path witnesschain/watchtower:1.1.1
EOF
#---------------- End of docker-run.sh -----------------------------------------
chmod +x docker-run.sh
which docker 1>/dev/null 2>/dev/null
if [ "$?" != "0" ]
then
echo
echo "🔵 Please install the \"docker\" engine"
echo " Refer : <https://docs.docker.com/engine/install/ubuntu/>"
echo
fi
user_in_docker_group=`groups $USER | grep docker | wc -l`
if [ "$user_in_docker_group" -eq "0" ]
then
echo "🔵 As \"root\" user:"
echo " 1. Create and add a \"docker\" group"
echo " 2. And add the user \"$USER\" to the group"
echo
echo " Refer : <https://docs.docker.com/engine/install/linux-postinstall/#manage-docker-as-a-non-root-user>"
echo
fi
if [ -f $cf ]
then
error="no"
fields=""
fields="\${fields} private_key"
fields="\${fields} eth_testnet_websocket_url"
fields="\${fields} currently_watching_l2"
fields="\${fields} op_geth_rpc_url"
fields="\${fields} op_node_rpc_url"
fields="\${fields} l2oo_address"
fields_not_set=""
for f in $fields
do
lines=`cat $cf | grep \"$f\" -n | tr -d ' '`
for c in `echo $lines | cut -f1- -d,`
do
line_no=`echo $c | cut -f1 -d':'`
value=`echo $c | cut -f4 -d'"'`
if [ "$value" = "" ]
then
fields_not_set="${fields_not_set} $f:$line_no"
error="yes"
fi
done
done
if [ "$error" = "yes" ]
then
echo "❌ Please set the following fields in \"$cf\" at:"
for fl in $fields_not_set
do
f=`echo $fl | cut -f1 -d':'`
l=`echo $fl | cut -f2 -d':'`
echo "\tLine no. $l field \"$f\""
done
echo
echo "🔵 Finally, run the \"./docker-run.sh\""
echo
exit
fi
./docker-run.sh
else
curl https://raw.githubusercontent.com/witnesschain-com/diligencewatchtower-client/develop/config.json.example > $cf 2>/dev/null
if [ ! -s "$cf" ]
then
echo
echo "❌ The file \"$cf\" could not be downloaded"
echo
exit
fi
echo "✅ Downloaded the \"$cf\""
echo
echo "🔵 Edit the following parameters in \"$cf\":"
echo " 1. private_key"
echo " 2. eth_testnet_websocket_url"
echo " 3. currently_watching_l2"
echo " 4. host_name (optional but recommended for dashboard support)"
echo " 5. watchtower_failure_alert_url (optional but recommended for getting error notification)"
echo
echo "🔵 For each of the L2s in \"$cf\" (e.g. base, optimism, etc.), please provide:"
echo " 1. chain_id (L2 chain id)"
echo " 2. op_geth_rpc_url (op-geth's RPC URL)"
echo " 3. op_node_rpc_url (op-node's RPC URL)"
echo
echo "Set your W3 Passphrase: export W3SECRETPASSPHRASE=your_w3_secret_passphrase"
echo "Set your encrypted key file path (full path): export KEYSTORE_PATH=/path/to/your/encrypted_key
echo
echo "Note, in case if you aren't using the encrypted keys, you can ignore the above two exports
echo
echo "🔵 Finally, run the \"./docker-run.sh\""
echo
fi