From d60d2edd9f8491a64932ea7ee406cf95722f0c29 Mon Sep 17 00:00:00 2001 From: CryptoBureau Date: Tue, 17 Dec 2024 06:00:44 +0100 Subject: [PATCH] Updated ghost.sh file with new changes --- README.md | 7 +++++-- ghost.sh | 37 ++++++++++++++++++++++++++++++++----- 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 1a41859..e4c65eb 100644 --- a/README.md +++ b/README.md @@ -180,10 +180,13 @@ The script provides an interactive menu with the following options: 20. **Status-Checker** Checks the status of the Ghost node service. -21. **Logs-Checker** +21. **Account-ID** + The function sends a curl request to the local node and uses jq to extract the result field Account ID (Peer ID). + +22. **Logs-Checker** Displays the latest logs to monitor the Ghost node's performance or troubleshoot issues. -22. **Exit** +23. **Exit** Exits the script and ends the session. diff --git a/ghost.sh b/ghost.sh index ee2480c..f02806f 100755 --- a/ghost.sh +++ b/ghost.sh @@ -945,6 +945,29 @@ restart_service() { } +# Function to fetch and display the Peer ID (Account ID) +account_id() { + # Check if jq is installed + if ! command -v jq &> /dev/null; then + echo "'jq' is not installed. Installing jq now..." + # Install jq if not present + sudo apt update && sudo apt install -y jq + echo "jq has been installed." + else + echo "jq is already installed. Proceeding with fetching the Peer ID..." + fi + + # Fetch the Peer ID using curl and jq + peer_id=$(curl -s -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "system_localPeerId", "params":[]}' http://localhost:9945 | jq -r '.result') + + # Return the Peer ID (Account ID) + echo "Account ID: $peer_id" + + # Call the Master function to display the menu + master +} + + logs_checker() { echo "Checking logs for the ghost-node service..." @@ -984,15 +1007,16 @@ master() { print_info "18. Reconnect-Peers" print_info "19. Restart-Service" print_info "20. Status-Checker" - print_info "21. Logs-Checker" - print_info "22. Exit" + print_info "21. Account-ID" + print_info "22. Logs-Checker" + print_info "23. Exit" print_info "" print_info "===============================" print_info " Created By : CB-Master " print_info "===============================" print_info "" - read -p "Enter your choice (1 or 22): " user_choice + read -p "Enter your choice (1 or 23): " user_choice case $user_choice in 1) @@ -1056,13 +1080,16 @@ master() { status_service ;; 21) - logs_checker + account_id ;; 22) + logs_checker + ;; + 23) exit 0 # Exit the script after breaking the loop ;; *) - print_error "Invalid choice. Please enter 1 or 22 : " + print_error "Invalid choice. Please enter 1 or 23 : " ;; esac }