74 lines
3.4 KiB
Bash
74 lines
3.4 KiB
Bash
#!/bin/bash
|
|
|
|
# Block specific hosts
|
|
echo "127.0.0.1 goedge.cloud" | sudo tee -a /etc/hosts > /dev/null
|
|
echo "127.0.0.1 goedge.cn" | sudo tee -a /etc/hosts > /dev/null
|
|
echo "127.0.0.1 dl.goedge.cloud" | sudo tee -a /etc/hosts > /dev/null
|
|
echo "127.0.0.1 dl.goedge.cn" | sudo tee -a /etc/hosts > /dev/null
|
|
echo "127.0.0.1 global.dl.goedge.cloud" | sudo tee -a /etc/hosts > /dev/null
|
|
echo "127.0.0.1 global.dl.goedge.cn" | sudo tee -a /etc/hosts > /dev/null
|
|
|
|
# Display the contents of the /etc/hosts file
|
|
cat /etc/hosts
|
|
|
|
# Ask for the edge-node installation path
|
|
read -p "Enter the path to the edge-node installation directory: " edge_node_path
|
|
|
|
# Remove the existing edge-node directory
|
|
sudo rm -rf "$edge_node_path"
|
|
|
|
# Ensure /usr/local/goedge directory exists or create it
|
|
if [ ! -d "/usr/local/goedge" ]; then
|
|
sudo mkdir -p /usr/local/goedge
|
|
fi
|
|
|
|
# Navigate to the edge-node software directory
|
|
cd /usr/local/goedge || exit
|
|
|
|
# Download the edge-node software
|
|
curl -L "https://git.18g.me/chunzhi/goedge-green/raw/branch/main/edge-node-linux-amd64-plus-v1.3.9.zip" --insecure -o edge-node-linux-amd64-plus.zip -C - -#
|
|
|
|
# Unzip the new version
|
|
unzip -o edge-node-linux-amd64-plus.zip
|
|
|
|
# Define the config directory path
|
|
config_dir="/usr/local/goedge/edge-node/configs"
|
|
|
|
# Create or overwrite api_node.yaml from the template
|
|
if [ -d "$config_dir" ]; then
|
|
cp "$config_dir/api_node.template.yaml" "$config_dir/api_node.yaml"
|
|
else
|
|
echo "Configuration directory does not exist. Creating directory."
|
|
mkdir -p "$config_dir"
|
|
# Ensure template exists or exit
|
|
if [ ! -f "$config_dir/api_node.template.yaml" ]; then
|
|
echo "Template file does not exist. Exiting."
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
# Ask the user to input the required configuration values
|
|
echo "Please enter the required configuration values."
|
|
read -p "Enter rpc.endpoints: " rpc_endpoints
|
|
read -p "Enter nodeId: " node_id
|
|
read -p "Enter secret: " secret
|
|
|
|
# Insert configuration into api_node.yaml
|
|
echo "rpc.endpoints: [\"$rpc_endpoints\"]" > "$config_dir/api_node.yaml"
|
|
echo "nodeId: \"$node_id\"" >> "$config_dir/api_node.yaml"
|
|
echo "secret: \"$secret\"" >> "$config_dir/api_node.yaml"
|
|
|
|
# Navigate to the specified edge-node directory
|
|
cd /usr/local/goedge/edge-node
|
|
# Stop the current edge-node processes
|
|
./bin/edge-node stop
|
|
|
|
# Clean up old data
|
|
sudo rm -rf /opt/cache
|
|
|
|
# Restart edge-node
|
|
./bin/edge-node restart
|
|
|
|
# Clean up downloaded zip file
|
|
rm -rf *.zip
|