From f61db11c7084772d756a2e51598293e05845675f Mon Sep 17 00:00:00 2001 From: chunzhi Date: Mon, 29 Jul 2024 20:16:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20noderedeploy.sh?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- noderedeploy.sh | 69 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 noderedeploy.sh diff --git a/noderedeploy.sh b/noderedeploy.sh new file mode 100644 index 0000000..966881c --- /dev/null +++ b/noderedeploy.sh @@ -0,0 +1,69 @@ +#!/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://dl.naixi.net/cdn/goedge/goedgecn/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 + + # Create or overwrite api_node.yaml from the template + if [ -d "$edge_node_path/configs" ]; then + cp "$edge_node_path/configs/api_node.template.yaml" "$edge_node_path/configs/api_node.yaml" + else + echo "Configuration directory does not exist. Exiting." + exit 1 + 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\"]" > "$edge_node_path/configs/api_node.yaml" + echo "nodeId: \"$node_id\"" >> "$edge_node_path/configs/api_node.yaml" + echo "secret: \"$secret\"" >> "$edge_node_path/configs/api_node.yaml" + + # Navigate to the specified edge-node directory + cd "$edge_node_path" || exit + + # Stop the current edge-node processes + ./bin/edge-node stop + + # Clean up old data + rm -rf ./data + rm -rf ./bin + sudo rm -rf /opt/cache + + # Restart edge-node + ./bin/edge-node restart + + # Clean up downloaded zip file + rm -rf *.zip + \ No newline at end of file