-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy patht3rn.sh
More file actions
207 lines (169 loc) · 6.19 KB
/
t3rn.sh
File metadata and controls
207 lines (169 loc) · 6.19 KB
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
#!/bin/bash
# Script save path
SCRIPT_PATH="$HOME/t3rn.sh"
LOGFILE="$HOME/executor/executor.log"
EXECUTOR_DIR="$HOME/executor"
# Check if the script is run as root user
if [ "$(id -u)" != "0" ]; then
echo "This script needs to be run with root privileges."
echo "Please try to switch to the root user using the 'sudo -i' command and then run this script again."
exit 1
fi
# Main menu function
function main_menu() {
while true; do
clear
echo "The script was written by the big gambling community hahahaha, Twitter @ferdie_jhovie, free and open source, please don't believe in the charges"
echo "If you have any questions, please contact Twitter. There is only one number for this."
echo "================================================ ================"
echo "To exit the script, press ctrl + C on your keyboard to exit"
echo "Please select the action to perform:"
echo "1) Execute the script"
echo "2) View the log"
echo "3) Delete node"
echo "4) Restart the node (to be used after receiving water)"
echo "5) Exit"
read -p "Please enter your choice [1-4]: " choice
case $choice in
1)
execute_script
;;
2)
view_logs
;;
3)
delete_node
;;
4)
restart_node
;;
5)
echo "Exiting script."
exit 0
;;
*)
echo "Invalid selection, please re-enter."
;;
esac
done
}
# Restart node function
function restart_node() {
echo "Restarting node process..."
# Find the executor process and terminate it
pkill -f executor
# Change directory and execute the script
echo "Change directory and execute ./executor..."
cd ~/executor/executor/bin
# Setting environment variables
export NODE_ENV=testnet
export LOG_LEVEL=debug
export LOG_PRETTY=false
export RPC_ENDPOINTS_L1RN='https://brn.rpc.caldera.xyz/'
export EXECUTOR_PROCESS_PENDING_ORDERS_FROM_API=false
export EXECUTOR_MAX_L3_GAS_PRICE=100
# New environment variables
export EXECUTOR_PROCESS_ORDERS=true
export EXECUTOR_PROCESS_CLAIMS=true
# Prompt the user to enter a private key
read -p "Please enter the value of PRIVATE_KEY_LOCAL: " PRIVATE_KEY_LOCAL
# Set private key variables
export PRIVATE_KEY_LOCAL="$PRIVATE_KEY_LOCAL"
# Redirect log output
./executor > "$LOGFILE" 2>&1 &
# Display background process PID
echo "The executor process has been restarted, PID: $!"
echo "Reboot operation completed."
# Prompt the user to press any key to return to the main menu
read -n 1 -s -r -p "Press any key to return to the main menu..."
main_menu
}
# Execute script function
function execute_script() {
# Download the file
echo "Downloading executor-linux-v0.29.0.tar.gz..."
wget https://github.com/t3rn/executor-release/releases/download/v0.29.0/executor-linux-v0.29.0.tar.gz
# Check if the download was successful
if [ $? -eq 0 ]; then
echo "Download successful."
else
echo "Download failed, please check the network connection or download address."
exit 1
fi
# Unzip the file to the current directory
echo "Unzipping files..."
tar -xvzf executor-linux-v0.29.0.tar.gz
# Check if the decompression is successful
if [ $? -eq 0 ]; then
echo "Decompression successful."
else
echo "Unzip failed, please check the tar.gz file."
exit 1
fi
# Check if the decompressed file name contains 'executor'
echo "Checking if the decompressed file or directory name contains 'executor'..."
if ls | grep -q 'executor'; then
echo "Check passed, found a file or directory containing 'executor'."
else
echo "The file or directory containing 'executor' was not found. The file name may be incorrect."
exit 1
fi
# Setting environment variables
export NODE_ENV=testnet
export LOG_LEVEL=debug
export LOG_PRETTY=false
export ENABLED_NETWORKS='arbitrum-sepolia,base-sepolia,blast-sepolia,optimism-sepolia,l1rn'
export RPC_ENDPOINTS_L1RN='https://brn.rpc.caldera.xyz/'
export EXECUTOR_PROCESS_PENDING_ORDERS_FROM_API=false
export EXECUTOR_MAX_L3_GAS_PRICE=100
# New environment variables
export EXECUTOR_PROCESS_ORDERS=true
export EXECUTOR_PROCESS_CLAIMS=true
# Prompt the user to enter a private key
read -p "Please enter the value of PRIVATE_KEY_LOCAL: " PRIVATE_KEY_LOCAL
# Set private key variables
export PRIVATE_KEY_LOCAL="$PRIVATE_KEY_LOCAL"
# Delete compressed files
echo "Delete compressed file..."
rm executor-linux-v0.29.0.tar.gz
# Change directory and execute the script
echo "Change directory and execute ./executor..."
cd ~/executor/executor/bin
# Redirect log output
./executor > "$LOGFILE" 2>&1 &
# Display background process PID
echo "executor process started, PID: $!"
echo "Operation completed."
# Prompt the user to press any key to return to the main menu
read -n 1 -s -r -p "Press any key to return to the main menu..."
main_menu
}
# View log function
function view_logs() {
if [ -f "$LOGFILE" ]; then
echo "Real-time display of log file contents (press Ctrl+C to exit):"
tail -f "$LOGFILE" # Use tail -f to track the log file in real time
else
echo "The log file does not exist."
fi
}
# Delete node function
function delete_node() {
echo "Stopping node process..."
# Find the executor process and terminate it
pkill -f executor
# Delete the node directory
if [ -d "$EXECUTOR_DIR" ]; then
echo "Deleting node directory..."
rm -rf "$EXECUTOR_DIR"
echo "Node directory has been deleted."
else
echo "The node directory does not exist and may have been deleted."
fi
echo "Node deletion completed."
# Prompt the user to press any key to return to the main menu
read -n 1 -s -r -p "Press any key to return to the main menu..."
main_menu
}
# Start the main menu
main_menu