From 532da7f0b66acaad2b365a17be5c55a0948e8718 Mon Sep 17 00:00:00 2001 From: Rohit T P Date: Tue, 23 Apr 2024 19:16:27 +0000 Subject: [PATCH 1/3] fix: fixed input ordering --- docker-compose/setup-script/noco.sh | 61 ++++++++++++++++------------- 1 file changed, 33 insertions(+), 28 deletions(-) diff --git a/docker-compose/setup-script/noco.sh b/docker-compose/setup-script/noco.sh index d3abc82ba5..581dea6052 100755 --- a/docker-compose/setup-script/noco.sh +++ b/docker-compose/setup-script/noco.sh @@ -194,29 +194,31 @@ cd "$FOLDER_NAME" || exit # ******************** INPUTS FROM USER START ******************************** # ****************************************************************************** -echo "Choose Community or Enterprise Edition [CE/EE] (default: CE): " -read EDITION +echo "Enter the IP address or domain name for the NocoDB instance (default: $PUBLIC_IP): " +read DOMAIN_NAME -echo "Do you want to configure SSL [Y/N] (default: N): " -read SSL_ENABLED +echo "Show Advanced Options [Y/N] (default: N): " +read -r ADVANCED_OPTIONS +if [ "$ADVANCED_OPTIONS" == "Y" ]; then + ADVANCED_OPTIONS="y" +fi -if [ -n "$SSL_ENABLED" ] && { [ "$SSL_ENABLED" = "Y" ] || [ "$SSL_ENABLED" = "y" ]; }; then - SSL_ENABLED='y' - echo "Enter the domain name for the SSL certificate: " - read DOMAIN_NAME - if [ -z "$DOMAIN_NAME" ]; then - echo "Domain name is required for SSL configuration" - exit 1 - fi - message_arr+=("Domain: $DOMAIN_NAME") +if [ -n "$DOMAIN_NAME" ]; then + if [ "$ADVANCED_OPTIONS" == "y" ]; then + echo "Do you want to configure SSL [Y/N] (default: N): " + read SSL_ENABLED + message_arr+=("SSL: ${SSL_ENABLED}") + fi else - # prompt for ip address and if left empty use extracted public ip - echo "Enter the IP address or domain name for the NocoDB instance (default: $PUBLIC_IP): " - read DOMAIN_NAME - if [ -z "$DOMAIN_NAME" ]; then - DOMAIN_NAME="$PUBLIC_IP" - fi + DOMAIN_NAME="$PUBLIC_IP" +fi + +message_arr+=("Domain: $PUBLIC_IP") + +if [ "$ADVANCED_OPTIONS" == "y" ]; then + echo "Choose Community or Enterprise Edition [CE/EE] (default: CE): " + read EDITION fi if [ -n "$EDITION" ] && { [ "$EDITION" = "EE" ] || [ "$EDITION" = "ee" ]; }; then @@ -229,8 +231,10 @@ if [ -n "$EDITION" ] && { [ "$EDITION" = "EE" ] || [ "$EDITION" = "ee" ]; }; the fi -echo "Do you want to enabled Redis for caching [Y/N] (default: Y): " -read REDIS_ENABLED +if [ "$ADVANCED_OPTIONS" == "y" ]; then + echo "Do you want to enabled Redis for caching [Y/N] (default: Y): " + read REDIS_ENABLED +fi if [ -z "$REDIS_ENABLED" ] || { [ "$REDIS_ENABLED" != "N" ] && [ "$REDIS_ENABLED" != "n" ]; }; then message_arr+=("Redis: Enabled") @@ -239,8 +243,10 @@ else fi -echo "Do you want to enabled Watchtower for automatic updates [Y/N] (default: Y): " -read WATCHTOWER_ENABLED +if [ "$ADVANCED_OPTIONS" == "y" ]; then + echo "Do you want to enabled Watchtower for automatic updates [Y/N] (default: Y): " + read WATCHTOWER_ENABLED +fi if [ -z "$WATCHTOWER_ENABLED" ] || { [ "$WATCHTOWER_ENABLED" != "N" ] && [ "$WATCHTOWER_ENABLED" != "n" ]; }; then message_arr+=("Watchtower: Enabled") @@ -248,21 +254,20 @@ else message_arr+=("Watchtower: Disabled") fi -echo "Show Advanced Options [Y/N] (default: N): " -read -r ADVANCED_OPTIONS -if [ -n "$ADVANCED_OPTIONS" ] && { [ "$ADVANCED_OPTIONS" = "Y" ] || [ "$ADVANCED_OPTIONS" = "y" ]; }; then + +if [ "$ADVANCED_OPTIONS" = "Y" ] ; then NUM_CORES=$(nproc || sysctl -n hw.ncpu || echo 1) echo "How many instances of NocoDB do you want to run (Maximum: ${NUM_CORES}) ? (default: 1): " NUM_INSTANCES=$(read_number_range 1 "$NUM_CORES") - - message_arr+=("Number of instances: $NUM_INSTANCES") fi if [ -z "$NUM_INSTANCES" ]; then NUM_INSTANCES=1 fi +message_arr+=("Number of instances: $NUM_INSTANCES") + # ****************************************************************************** # *********************** INPUTS FROM USER END ******************************** From be82192e8728732cf7f94c1650b785ece54cd8d8 Mon Sep 17 00:00:00 2001 From: Rohit T P Date: Tue, 23 Apr 2024 19:20:37 +0000 Subject: [PATCH 2/3] fix: fixed typo --- docker-compose/setup-script/noco.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docker-compose/setup-script/noco.sh b/docker-compose/setup-script/noco.sh index 581dea6052..bc258050a6 100755 --- a/docker-compose/setup-script/noco.sh +++ b/docker-compose/setup-script/noco.sh @@ -254,9 +254,7 @@ else message_arr+=("Watchtower: Disabled") fi - - -if [ "$ADVANCED_OPTIONS" = "Y" ] ; then +if [ "$ADVANCED_OPTIONS" = "y" ] ; then NUM_CORES=$(nproc || sysctl -n hw.ncpu || echo 1) echo "How many instances of NocoDB do you want to run (Maximum: ${NUM_CORES}) ? (default: 1): " NUM_INSTANCES=$(read_number_range 1 "$NUM_CORES") From 707224ecb353d1132a2ad400c2d15976b0511041 Mon Sep 17 00:00:00 2001 From: Rohit <45072928+rohittp0@users.noreply.github.com> Date: Wed, 24 Apr 2024 00:51:28 +0530 Subject: [PATCH 3/3] Apply suggestions from code review Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- docker-compose/setup-script/noco.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docker-compose/setup-script/noco.sh b/docker-compose/setup-script/noco.sh index bc258050a6..4b6e7abc80 100755 --- a/docker-compose/setup-script/noco.sh +++ b/docker-compose/setup-script/noco.sh @@ -195,7 +195,7 @@ cd "$FOLDER_NAME" || exit # ****************************************************************************** echo "Enter the IP address or domain name for the NocoDB instance (default: $PUBLIC_IP): " -read DOMAIN_NAME +read -r DOMAIN_NAME echo "Show Advanced Options [Y/N] (default: N): " read -r ADVANCED_OPTIONS @@ -207,7 +207,7 @@ fi if [ -n "$DOMAIN_NAME" ]; then if [ "$ADVANCED_OPTIONS" == "y" ]; then echo "Do you want to configure SSL [Y/N] (default: N): " - read SSL_ENABLED + read -r SSL_ENABLED message_arr+=("SSL: ${SSL_ENABLED}") fi else @@ -218,7 +218,7 @@ message_arr+=("Domain: $PUBLIC_IP") if [ "$ADVANCED_OPTIONS" == "y" ]; then echo "Choose Community or Enterprise Edition [CE/EE] (default: CE): " - read EDITION + read -r EDITION fi if [ -n "$EDITION" ] && { [ "$EDITION" = "EE" ] || [ "$EDITION" = "ee" ]; }; then @@ -233,7 +233,7 @@ fi if [ "$ADVANCED_OPTIONS" == "y" ]; then echo "Do you want to enabled Redis for caching [Y/N] (default: Y): " - read REDIS_ENABLED + read -r REDIS_ENABLED fi if [ -z "$REDIS_ENABLED" ] || { [ "$REDIS_ENABLED" != "N" ] && [ "$REDIS_ENABLED" != "n" ]; }; then @@ -245,7 +245,7 @@ fi if [ "$ADVANCED_OPTIONS" == "y" ]; then echo "Do you want to enabled Watchtower for automatic updates [Y/N] (default: Y): " - read WATCHTOWER_ENABLED + read -r WATCHTOWER_ENABLED fi if [ -z "$WATCHTOWER_ENABLED" ] || { [ "$WATCHTOWER_ENABLED" != "N" ] && [ "$WATCHTOWER_ENABLED" != "n" ]; }; then