diff --git a/hdb_keymanager.sh b/hdb_keymanager.sh index b37816d..7907908 100644 --- a/hdb_keymanager.sh +++ b/hdb_keymanager.sh @@ -52,19 +52,32 @@ create_new_key() { read -p "Enter the Key Name [CRONKEY]: " key_name read -p "Enter the HANA Host [${current_hostname}]: " hdb_host read -p "Enter the Instance Number [00]: " hdb_instance - read -p "Enter the Tenant DB [NDB]: " hdb_tenant + + # Ask if connecting to SYSTEMDB to format the connection string correctly. + read -p "Is this for the SYSTEMDB tenant? (y/n) [n]: " is_systemdb + + # Set default values for prompts + key_name=${key_name:-"CRONKEY"} + hdb_host=${hdb_host:-$current_hostname} + hdb_instance=${hdb_instance:-"00"} + is_systemdb=${is_systemdb:-"n"} + + # Conditionally build the connection string + if [[ "$is_systemdb" =~ ^[Yy]$ ]]; then + CONNECTION_STRING="${hdb_host}:3${hdb_instance}15" + echo -e "${COLOR_YELLOW}💡 Connecting to SYSTEMDB. Tenant name will be omitted from the connection string.${COLOR_NC}" + else + read -p "Enter the Tenant DB [NDB]: " hdb_tenant + hdb_tenant=${hdb_tenant:-"NDB"} + CONNECTION_STRING="${hdb_host}:3${hdb_instance}15@${hdb_tenant}" + fi + read -p "Enter the Database User [SYSTEM]: " hdb_user read -sp "Enter the Database Password: " hdb_pass echo "" - key_name=${key_name:-"CRONKEY"} - hdb_host=${hdb_host:-$current_hostname} - hdb_instance=${hdb_instance:-"00"} - hdb_tenant=${hdb_tenant:-"NDB"} hdb_user=${hdb_user:-"SYSTEM"} - CONNECTION_STRING="${hdb_host}:3${hdb_instance}15@${hdb_tenant}" - echo -e "\n${COLOR_YELLOW}📝 Review the command below (password is hidden):" echo "------------------------------------------------------" printf "${HDB_USERSTORE_EXEC} SET \"%s\" \"%s\" \"%s\" \"\"\n" "$key_name" "$CONNECTION_STRING" "$hdb_user" @@ -177,3 +190,4 @@ while true; do ;; esac done +