Update Reconnect Peers

This commit is contained in:
root 2024-12-07 12:42:34 +01:00
parent 1ae874e50b
commit 44b91e9897

141
ghost.sh Normal file → Executable file
View File

@ -777,6 +777,9 @@ stop_service() {
reconnect_peers() {
GHOST_NODE_DIR="/root/ghost/ghost-node"
# Step 1: Stop the running Ghost node service
echo "Stopping the Ghost node..."
sudo systemctl stop ghost-node
@ -786,94 +789,108 @@ reconnect_peers() {
sleep 1
# Step 2: Navigate to the Ghost node folder or exit if not found
echo "Navigating to the Ghost node folder..."
cd ghost/ghost-node || { echo "Ghost node folder not found. Exiting."; exit 1; }
if [ -d "$GHOST_NODE_DIR" ]; then
echo "Directory $GHOST_NODE_DIR exists."
cd "$GHOST_NODE_DIR"
# Inform the user and add a delay for better clarity
print_info "Please wait ..."
sleep 1
# Inform the user and add a delay for better clarity
print_info "Please wait ..."
sleep 1
# Step 3: Clean up old Ghost node data by removing the folder
echo "Cleaning up existing Ghost node data..."
sudo rm -rf /var/lib/ghost
# Step 3: Clean up old Ghost node data by removing the folder
echo "Cleaning up existing Ghost node data..."
sudo rm -rf /var/lib/ghost
# Inform the user and add a delay for better clarity
print_info "Please wait ..."
sleep 1
# Inform the user and add a delay for better clarity
print_info "Please wait ..."
sleep 1
# Step 4: Switch to the 'main' branch in the Git repository
echo "Switching to the 'main' branch..."
git switch main
# Step 4: Switch to the 'main' branch in the Git repository
echo "Switching to the 'main' branch..."
git switch main
# Step 5: Pull the latest updates from the Git repository
echo "Pulling the latest updates from the repository..."
git pull origin main
# Step 5: Pull the latest updates from the Git repository
echo "Pulling the latest updates from the repository..."
git pull origin main
# Inform the user and add a delay for better clarity
print_info "Please wait ..."
sleep 1
# Inform the user and add a delay for better clarity
print_info "Please wait ..."
sleep 1
# Step 6: Start the setup process with release and global options
echo "Starting the setup process..."
./scripts/starter.sh --release --make-global
# Rust Installation with rust_setup function
print_info "ReChecking Rust..."
rust_setup || { echo "Rust setup failed! Exiting."; exit 1; }
# Inform the user and add a delay for better clarity
print_info "Please wait ..."
sleep 1
# Inform the user and add a delay for better clarity
print_info "Please wait ..."
sleep 1
# Step 7: Verify the SHA256 checksum of the Casper JSON file
echo "Checking SHA256 checksum of the Casper JSON..."
sha256sum /etc/ghost/casper.json
# Step 6: Start the setup process with release and global options
echo "Starting the setup process..."
./scripts/starter.sh --release --make-global
# Inform the user and add a delay for better clarity
print_info "Please wait ..."
sleep 1
# Inform the user and add a delay for better clarity
print_info "Please wait ..."
sleep 1
# Step 8: Set the unit file arguments for the service
echo "Setting unit file arguments..."
./scripts/starter.sh --unit-file --set-arguments
# Step 7: Verify the SHA256 checksum of the Casper JSON file
echo "Checking SHA256 checksum of the Casper JSON..."
sha256sum /etc/ghost/casper.json
# Step 9: Perform a keys check
echo "Checking keys..."
./scripts/starter.sh --check-keys
# Inform the user and add a delay for better clarity
print_info "Please wait ..."
sleep 1
# Step 10: Start the Ghost node service
echo "Starting the Ghost node..."
sudo systemctl start ghost-node
# Step 8: Set the unit file arguments for the service
echo "Setting unit file arguments..."
./scripts/starter.sh --unit-file --set-arguments
# Add a delay to allow the service to stabilize
print_info "Please wait 1 minute ..."
sleep 60
# Step 9: Perform a keys check
echo "Checking keys..."
./scripts/starter.sh --check-keys
# Step 11: Insert keys into the node
echo "Inserting keys..."
./scripts/starter.sh --check-keys --insert-keys
# Step 10: Start the Ghost node service
echo "Starting the Ghost node..."
sudo systemctl start ghost-node
# Inform the user and add a delay for better clarity
print_info "Please wait ..."
sleep 1
# Add a delay to allow the service to stabilize
print_info "Please wait 1 minute ..."
sleep 60
# Step 12: Restart the Ghost node service
echo "Restarting the Ghost node..."
sudo systemctl restart ghost-node
# Step 11: Insert keys into the node
echo "Inserting keys..."
./scripts/starter.sh --check-keys --insert-keys
# Inform the user and add a delay for better clarity
print_info "Please wait ..."
sleep 1
# Inform the user and add a delay for better clarity
print_info "Please wait ..."
sleep 1
# Step 13: Enable the Ghost node service for auto-start on boot
echo "Enabling the Ghost node service..."
sudo systemctl enable ghost-node
# Step 12: Restart the Ghost node service
echo "Restarting the Ghost node..."
sudo systemctl restart ghost-node
# Final step: Notify the user of successful completion
echo "Reconnect process completed successfully!"
# Inform the user and add a delay for better clarity
print_info "Please wait ..."
sleep 1
# Step 13: Enable the Ghost node service for auto-start on boot
echo "Enabling the Ghost node service..."
sudo systemctl enable ghost-node
# Final step: Notify the user of successful completion
echo "Reconnect process completed successfully!"
else
echo "Error: Directory $GHOST_NODE_DIR does not exist."
echo "Please run the setup_node function first."
exit 1
fi
# Call the Master function to display the menu
master
}
enable_service() {
echo "Enabling the ghost-node service to start at boot..."