-
Notifications
You must be signed in to change notification settings - Fork 0
/
subspace
196 lines (172 loc) · 6.22 KB
/
subspace
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
#!/bin/bash
while true
do
#Logo
echo "================================================================="
echo "███████╗██╗ ██╗██████╗ ███████╗██████╗ █████╗ ██████╗███████╗"
echo "██╔════╝██║ ██║██╔══██╗██╔════╝██╔══██╗██╔══██╗██╔════╝██╔════╝"
echo "███████╗██║ ██║██████╔╝███████╗██████╔╝███████║██║ █████╗ "
echo "╚════██║██║ ██║██╔══██╗╚════██║██╔═══╝ ██╔══██║██║ ██╔══╝ "
echo "███████║╚██████╔╝██████╔╝███████║██║ ██║ ██║╚██████╗███████╗"
echo "╚══════╝ ╚═════╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝"
echo "================================================================="
echo -e "https://subspace.network/"
echo "================================================================="
# Menu
PS3='Select an action: '
options=(
"Install and run Node 3h"
"Update 11.06.24 - only for 3h"
"Restart Farmer and Node"
"Log Node"
"Log Farmer"
"Search in node logs"
"Search in farmer logs"
"Wipe Farmer"
"Purge-chain"
"Delete Node"
"Exit")
select opt in "${options[@]}"
do
case $opt in
"Install and run Node 3h")
echo "============================================================"
echo "Write the name of your node"
echo "============================================================"
read NODENAME
echo 'export NODENAME='$NODENAME >> $HOME/.bash_profile
echo "============================================================"
echo "Enter your wallet address"
echo "============================================================"
read WALLETADDRESS
echo 'export WALLETADDRESS='$WALLETADDRESS >> $HOME/.bash_profile
echo "============================================================"
echo "Write plot size for farmer(example 10G)"
echo "============================================================"
read PLOTSIZE
echo 'export PLOTSIZE='$PLOTSIZE >> $HOME/.bash_profile
source ~/.bash_profile
apt install jq
mkdir $HOME/subspace; \
cd $HOME/subspace && \
wget https://github.com/subspace/subspace/releases/download/gemini-3h-2024-jun-11/subspace-farmer-ubuntu-x86_64-skylake-gemini-3h-2024-jun-11 -O farmer && \
wget https://github.com/subspace/subspace/releases/download/gemini-3h-2024-jun-11/subspace-node-ubuntu-x86_64-skylake-gemini-3h-2024-jun-11 -O subspace && \
sudo chmod +x * && \
sudo mv * /usr/local/bin/ && \
cd $HOME && \
rm -Rvf $HOME/subspace && \
mkdir $HOME/.local/share/subspace-farmer
sudo tee <<EOF >/dev/null /etc/systemd/system/subspace.service
[Unit]
Description=Subspace Node
After=network.target
[Service]
Type=simple
User=$USER
ExecStart=$(which subspace) run \\
--chain="gemini-3h" \\
--base-path="$HOME/.local/share/subspace-node" \\
--listen-on /ip4/0.0.0.0/tcp/30334 \\
--farmer \\
--name="$NODENAME"
Restart=on-failure
RestartSec=10
LimitNOFILE=1024000
[Install]
WantedBy=multi-user.target
EOF
sudo tee <<EOF >/dev/null /etc/systemd/system/subspacefarm.service
[Unit]
Description=Subspace Farmer
After=network.target
[Service]
Type=simple
User=$USER
ExecStart=$(which farmer) farm --reward-address=$WALLETADDRESS path=$HOME/.local/share/subspace-farmer,size=$PLOTSIZE
Restart=always
RestartSec=10
LimitNOFILE=1024000
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl restart systemd-journald
sudo systemctl daemon-reload
sudo systemctl enable subspace subspacefarm
sudo systemctl restart subspacefarm subspace
break
;;
"Delete Node")
systemctl stop subspace subspacefarm
systemctl disable subspace subspacefarm
rm /etc/systemd/system/subspace.service
rm /etc/systemd/system/subspacefarm.service
rm -r /usr/local/bin/subspace
rm -r /usr/local/bin/farmer
rm -r /root/.local/share/subspace-farmer
rm -r /root/.local/share/subspace-node
break
;;
"Log Node")
sudo journalctl -n 50 -f -u subspace -o cat
break
;;
"Log Farmer")
sudo journalctl -n 50 -f -u subspacefarm -o cat
break
;;
"Wipe Farmer")
systemctl stop subspacefarm
farmer wipe $HOME/.local/share/subspace-farmer
sudo systemctl restart subspacefarm
break
;;
"Purge-chain")
systemctl stop subspace
subspace wipe $HOME/.local/share/subspace-node
sudo systemctl restart subspace
break
;;
"Restart Farmer and Node")
sudo systemctl restart subspacefarm subspace
break
;;
"Update 11.06.24 - only for 3h")
systemctl stop subspacefarm subspace
mkdir $HOME/subspace; \
cd $HOME/subspace && \
wget https://github.com/subspace/subspace/releases/download/gemini-3h-2024-jun-11/subspace-farmer-ubuntu-x86_64-skylake-gemini-3h-2024-jun-11 -O farmer && \
wget https://github.com/subspace/subspace/releases/download/gemini-3h-2024-jun-11/subspace-node-ubuntu-x86_64-skylake-gemini-3h-2024-jun-11 -O subspace && \
sudo chmod +x * && \
sudo mv * /usr/local/bin/ && \
cd $HOME && \
rm -Rvf $HOME/subspace && \
sudo systemctl restart subspacefarm subspace
break
;;
"Search in node logs")
echo "============================================================"
echo "Enter a keyword or phrase to search"
echo "============================================================"
read KEYWORD
echo -e "\n\033[32m =========================SEARCH RESULTS========================= \033[0m"
sudo journalctl -u subspace -o cat | grep "$KEYWORD"
echo -e "\n\033[32m ================================================================ \033[0m"
break
;;
"Search in farmer logs")
echo "============================================================"
echo "Enter a keyword or phrase to search"
echo "============================================================"
read KEYWORD
echo -e "\n\033[32m =========================SEARCH RESULTS========================= \033[0m"
sudo journalctl -u subspacefarm -o cat | grep "$KEYWORD"
echo -e "\n\033[32m ================================================================ \033[0m"
break
;;
"Exit")
exit
;;
*) echo "invalid option $REPLY";;
esac
done
done