-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
110 lines (97 loc) · 2.29 KB
/
install.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
#!/bin/bash
cd ~
mkdir -p ubuntu-node
cd ubuntu-node
get_key()
{
key=$(bash manager.sh key | tail -n 1)
echo "$key"
}
node_up() {
bash manager.sh up > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo "节点已启动"
return 0
else
echo "启动节点失败"
return 1
fi
}
node_down() {
bash manager.sh down > /dev/null 2>&1
echo "节点已停止"
}
node_key() {
key=$(get_key)
echo "节点key为: $key"
}
install_network3() {
cd ~
apt update && apt install -y net-tools jq
curl -O https://network3.io/ubuntu-node-v2.1.1.tar.gz
tar -xzf ubuntu-node-v2.1.1.tar.gz
rm ubuntu-node-v2.1.1.tar.gz
cd ubuntu-node
node_up
if [ $? -ne 0 ]; then
return 1
fi
priKey=$(get_key)
# 自动绑定
if [ -n "$1" ]; then
sleep 2
pubKey=$(curl -s http://localhost:8080/refresh | jq -r '.k')
response=$(curl -sX POST \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "X-Requested-With: XMLHttpRequest" \
--data-urlencode "e=$1" \
--data-urlencode "k=$pubKey" \
--data-urlencode "p=$priKey" \
http://account.network3.ai:8080/api/bind_email_node)
result=$(echo "$response" | jq '.s')
if [ $result -eq "0" ]; then
echo "绑定成功,请前往network3后台查看"
return 0
fi
fi
# 手动绑定
ip=$(curl -s4 https://ifconfig.me)
echo "请访问 https://account.network3.ai/main?o=$ip:8080 进行绑定,key为: $priKey"
}
# 有传入email直接进行安装,不再显示菜单
if [ -n "$1" ]; then
install_network3 $1
exit 0
fi
while true; do
echo "请选择:"
echo "1) 安装network3"
echo "2) 启动节点"
echo "3) 停止节点"
echo "4) 查看节点key"
echo "5) 退出"
read -p "请输入选项(1-5): " choice
clear
case $choice in
1)
install_network3
;;
2)
node_up
;;
3)
node_down
;;
4)
node_key
;;
5)
break
;;
*)
echo "无效选项,请重新输入。"
;;
esac
echo ""
done
exit 0