-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnxtp-setup.sh
278 lines (220 loc) · 7.87 KB
/
nxtp-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
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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
#!/bin/bash
echo "=============================================================="
echo -e "\033[0;35m"
echo " ██████╗ ██████╗ ███╗ ██╗███╗ ██╗███████╗██╗ ██╗████████╗";
echo "██╔════╝██╔═══██╗████╗ ██║████╗ ██║██╔════╝╚██╗██╔╝╚══██╔══╝";
echo "██║ ██║ ██║██╔██╗ ██║██╔██╗ ██║█████╗ ╚███╔╝ ██║ ";
echo "██║ ██║ ██║██║╚██╗██║██║╚██╗██║██╔══╝ ██╔██╗ ██║ ";
echo "╚██████╗╚██████╔╝██║ ╚████║██║ ╚████║███████╗██╔╝ ██╗ ██║ ";
echo " ╚═════╝ ╚═════╝ ╚═╝ ╚═══╝╚═╝ ╚═══╝╚══════╝╚═╝ ╚═╝ ╚═╝ ";
echo -e "\e[0m"
echo "=============================================================="
#Made by Haxxana
sleep 3
echo " "
function Installingrequiredtool {
echo -e "\e[1m\e[32mInstalling required tool ... \e[0m" && sleep 1
sudo apt install curl -y < "/dev/null"
apt update && apt install git sudo unzip wget -y < "/dev/null"
}
function Installingdocker {
echo " "
echo -e "\e[1m\e[32mInstalling Docker ... \e[0m" && sleep 1
if ! command -v docker &> /dev/null
then
echo " "
echo -e "\e[1m\e[32mInstalling Docker ... \e[0m" && sleep 1
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh < "/dev/null"
fi
echo " "
docker compose version
if [ $? -ne 0 ]
then
echo -e "\e[1m\e[32mInstalling Docker Compose v2.5.1 ... \e[0m" && sleep 1
curl -SL https://github.com/docker/compose/releases/download/v2.5.1/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo chown $USER /var/run/docker.sock
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
fi
}
function backupPK {
echo " "
echo -e "\e[1m\e[32mPreparing to backup router private key ... \e[0m" && sleep 1
cd $HOME/connext/nxtp-router-docker-compose
cat key.yaml |grep privateKey | awk -F'"' '{print $2}' > $HOME/connext/router_private_key.json
echo -e "\e[1m\e[92mYour Private Key: \e[0m" $(cat $HOME/connext/router_private_key.json)
pkBkpPath="$HOME/connext/router_private_key.json"
echo -e "\e[7mYour Private Key on $pkBkpPath\e[0m"
cd $HOME
}
function createpk {
echo " "
echo -e "\e[1m\e[32mCreate Private Key ... \e[0m" && sleep 1
openssl rand -hex 32 > $HOME/connext/router_private_key.json
echo -e "\e[1m\e[92mYour Private Key: \e[0m" $(cat $HOME/connext/router_private_key.json)
}
function installnxtp {
echo " "
echo -e "\e[1m\e[32mPreparing to install Router ... \e[0m" && sleep 1
mkdir -p $HOME/connext
cd $HOME/connext
git clone https://github.com/connext/nxtp-router-docker-compose.git
}
function coreversion_amarok {
echo " "
echo -e "\e[1m\e[32mSwitch to amarok version ... \e[0m" && sleep 1
cd $HOME/connext/nxtp-router-docker-compose
git checkout amarok
}
function createConfig {
cd $HOME/connext/nxtp-router-docker-compose
cp config.example.json config.json
}
#function upvernxtp {
#cd $HOME/connext/nxtp-router-docker-compose
#read -p "Insert Router Version: " nxtpv
#cp .env.example .env
#curl -fsSLI -o /dev/null -w %{url_effective} https://github.com/connext/nxtp/releases/latest | awk 'BEGIN{FS="v"} {print $2}' > nxtp.version
#echo " "
#echo -e "\e[1m\e[32mLast NXTP Version : $(cat $HOME/connext/nxtp-router-docker-compose/nxtp.version)\e[0m" && sleep 1
#sed -i 's/latest/'$(cat $HOME/connext/nxtp-router-docker-compose/nxtp.version)'/g' .env
#docker pull ghcr.io/connext/router:$(cat $HOME/connext/nxtp-router-docker-compose/nxtp.version)
#}
function upvernxtp {
cd $HOME/connext/nxtp-router-docker-compose
cp .env.example .env
docker image ls --all ghcr.io/connext/router |head -2 | tail -1 |awk {'print $2'} > nxtp.version
echo " "
echo -e "\e[1m\e[32mLast NXTP Version : $(cat $HOME/connext/nxtp-router-docker-compose/nxtp.version)\e[0m" && sleep 1
sed -i 's/latest/'$(cat $HOME/connext/nxtp-router-docker-compose/nxtp.version)'/g' .env
docker pull ghcr.io/connext/router:$(cat $HOME/connext/nxtp-router-docker-compose/nxtp.version)
}
function manupvernxtp {
cd $HOME/connext/nxtp-router-docker-compose
read -p "Insert Router Version: " nxtpv
cp .env.example .env
echo " "
echo -e "\e[1m\e[32mInstall NXTP Version : ${nxtpv}\e[0m" && sleep 1
sed -i 's/latest/'${nxtpv}'/g' .env
docker pull ghcr.io/connext/router:${nxtpv}
}
function setautokeyfile {
cd $HOME/connext/nxtp-router-docker-compose
cp key.example.yaml key.yaml
sed -i 's/dkadkjasjdlkasdladadasda/'$(cat $HOME/connext/router_private_key.json)'/g' key.yaml
}
function setyourkeyfile {
echo " "
echo -e "\e[1m\e[32mPreparing your Private Key ... \e[0m" && sleep 1
cd $HOME/connext/nxtp-router-docker-compose
cp key.example.yaml key.yaml
read -p "Insert your Private Key with out 0x: " yourpk
sed -i 's/dkadkjasjdlkasdladadasda/'${yourpk}'/g' key.yaml
}
function setlastver {
echo " "
cd $HOME/connext/nxtp-router-docker-compose
cp .env.example .env
echo " "
echo -e "\e[1m\e[32mLast NXTP Version : sha-498913b \e[0m" && sleep 1
sed -i 's/latest/sha-498913b/g' .env
docker pull ghcr.io/connext/router:sha-498913b
}
function dockerpull {
echo " "
echo -e "\e[1m\e[32mPreparing pull docker ... \e[0m" && sleep 1
cd $HOME/connext/nxtp-router-docker-compose
docker-compose pull
}
function dockerdown {
echo " "
echo -e "\e[1m\e[32mPreparing down Router ... \e[0m" && sleep 1
cd $HOME/connext/nxtp-router-docker-compose
docker-compose down
}
function dockerup {
echo " "
echo -e "\e[1m\e[32mPreparing Start Router ... \e[0m" && sleep 1
cd $HOME/connext/nxtp-router-docker-compose
docker-compose up -d
}
function delete {
echo " "
echo -e "\e[1m\e[32mPreparing Delete Router ... \e[0m" && sleep 1
cd $HOME/connext/nxtp-router-docker-compose
docker-compose down
cd $HOME
rm -rf $HOME/connext/nxtp-router-docker-compose
}
PS3='Please enter your choice (input your option number and press enter): '
options=("Install + Auto PKey" "Install + Your PKey" "Auto Upgrade" "Manual Upgrade" "Backup PKey" "Delete" "Quit")
select opt in "${options[@]}"
do
case $opt in
"Install + Auto PKey")
echo -e '\e[1m\e[32mYou choose Install Router with auto Private Key ...\e[0m' && sleep 1
Installingrequiredtool
Installingdocker
installnxtp
coreversion_amarok
#setlastver
upvernxtp
createConfig
createpk
setautokeyfile
dockerpull
dockerup
echo -e "\e[1m\e[32mYour Router was Install!\e[0m" && sleep 1
echo -e "\e[1m\e[92mYour Private Key: \e[0m" $(cat $HOME/connext/router_private_key.json)&& sleep 1
break
;;
"Install + Your PKey")
echo -e '\e[1m\e[32mYou choose Install Router with your Private Key ...\e[0m' && sleep 1
Installingrequiredtool
Installingdocker
installnxtp
coreversion_amarok
#setlastver
upvernxtp
createConfig
setyourkeyfile
dockerpull
dockerup
echo -e "\e[1m\e[32mYour Router was Install!\e[0m" && sleep 1
break
;;
"Auto Upgrade")
echo -e '\e[1m\e[32mYou choose Upgrade Version ...\e[0m' && sleep 1
dockerdown
upvernxtp
dockerpull
dockerup
echo -e "\e[1m\e[32mYour Router was upgraded to : $(cat $HOME/connext/nxtp-router-docker-compose/nxtp.version)\e[0m" && sleep 1
break
;;
"Manual Upgrade")
echo -e '\e[1m\e[32mYou choose Manual Upgrade Version ...\e[0m' && sleep 1
dockerdown
manupvernxtp
dockerpull
dockerup
echo -e "\e[1m\e[32mYour Router was upgraded to : ${nxtpv} \e[0m" && sleep 1
break
;;
"Backup PKey")
echo -e '\e[1m\e[32mYou choose Backup Private Key ...\e[0m' && sleep 1
backupPK
break
;;
"Delete")
echo -e '\e[1m\e[32mYou choose Delete All Router File and Data ...\e[0m' && sleep 1
delete
break
;;
"Quit")
break
;;
*) echo -e "\e[91minvalid option $REPLY\e[0m";;
esac
done