From 4f05bac898136a82620d7101ce3dac3d5cdb874f Mon Sep 17 00:00:00 2001 From: DarshanBPatel Date: Wed, 20 Nov 2024 16:06:27 +0530 Subject: [PATCH] chore: add more transpercery and suggestion while dogfooding --- interactive-cli.sh | 63 +++++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 28 deletions(-) diff --git a/interactive-cli.sh b/interactive-cli.sh index b8fea71..cfc69eb 100755 --- a/interactive-cli.sh +++ b/interactive-cli.sh @@ -119,17 +119,7 @@ setup() { echo -e "${BOLD}šŸš€ Starting Waku Node Setup${NC}\n" # Check if .env already exists - if [ -f .env ]; then - read -p "šŸ’” .env file already exists. Do you want to reconfigure? (y/N): " confirm - if [[ $confirm != [yY] ]]; then - echo -e "${YELLOW}Keeping existing configuration${NC}" - read -p $'\n'"Ready to start the node? (Y/n): " start_confirm - if [[ $start_confirm != [nN] ]]; then - start_node - fi - return - fi - else + if [ ! -f .env ]; then # Note the space after [ and before ] # Copy .env.example to .env if it doesn't exist cp .env.example .env if [ $? -ne 0 ]; then @@ -138,29 +128,46 @@ setup() { fi fi - setup_sepolia_rpc - - # Get RLN password - read -s -p "šŸ”’ Create a password for your RLN membership: " rln_password - echo - sed -i.bak "s|RLN_RELAY_CRED_PASSWORD=.*|RLN_RELAY_CRED_PASSWORD=\"$rln_password\"|" .env - - # Show configuration summary - echo -e "\n${BOLD}Configuration Summary:${NC}" - echo -e "RPC URL: $rpc_url" - echo -e "Private Key: ****${eth_key: -4}" - echo -e "RLN Password: ********" + read -p "šŸ’” .env file already exists. Do you want to reconfigure? (y/N): " reconfigure_confirmation + if [[ $reconfigure_confirmation == [yY] ]]; then + setup_sepolia_rpc + + # Get RLN password + read -s -p "šŸ”’ Create a password for your RLN membership: " rln_password + echo + sed -i.bak "s|RLN_RELAY_CRED_PASSWORD=.*|RLN_RELAY_CRED_PASSWORD=\"$rln_password\"|" .env + # Show configuration summary + echo -e "\n${BOLD}Configuration Summary:${NC}" + echo -e "RPC URL: $rpc_url" + echo -e "Private Key: ****${eth_key: -4}" + echo -e "RLN Password: ********" + else + echo -e "${YELLOW}Keeping existing configuration${NC}" + fi + # Confirm before proceeding - read -p $'\n'"Ready to start the node? (Y/n): " start_confirm - if [[ $start_confirm == [nN] ]]; then - echo -e "${YELLOW}Setup completed. Run './waku-cli.sh start' when you're ready to start the node.${NC}" + read -p $'\n'"Ready to start the node? (Y/n): " start_confirmation + if [[ $start_confirmation == [nN] ]]; then + echo -e "${YELLOW}Setup completed. Run './interactive-cli.sh start' or use the 'Start Node' option from the main menu when you're ready to start the node.${NC}" return fi # Register RLN membership - echo -e "\nšŸ“ Registering RLN membership..." - ./register_rln.sh + echo -e "\nšŸ“ RLN Membership Registration Status:" + if [ ! -d "keystore" ]; then + echo -e "${YELLOW}āž¤ Initiating registration: No existing keystore found${NC}" + ./register_rln.sh + elif [ "$reconfigure_confirmation" == [yY] ]; then + echo -e "${YELLOW}āž¤ Initiating registration: Reconfiguration requested by user${NC}" + ./register_rln.sh + else + if [ $reconfigure_confirmation == [nN] ]; then + echo -e "${YELLOW}āž¤ Registration skipped: User chose to keep existing configuration${NC}" + else + echo -e "${YELLOW}āž¤ Registration skipped: Valid keystore directory already exists${NC}" + fi + fi # Start the node start_node