From 44b91e98976677421ffefff153c46203fcab265c Mon Sep 17 00:00:00 2001 From: root Date: Sat, 7 Dec 2024 12:42:34 +0100 Subject: [PATCH] Update Reconnect Peers --- ghost.sh | 141 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 79 insertions(+), 62 deletions(-) mode change 100644 => 100755 ghost.sh diff --git a/ghost.sh b/ghost.sh old mode 100644 new mode 100755 index 8548d00..ee2480c --- a/ghost.sh +++ b/ghost.sh @@ -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..."