From 656d003d528d9da07df2f77c02c1cc56c70fb9ed Mon Sep 17 00:00:00 2001 From: Rohit T P Date: Wed, 17 Apr 2024 08:40:09 +0000 Subject: [PATCH 01/18] feat: Added advanced options --- docker-compose/setup-script/noco.sh | 47 +++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/docker-compose/setup-script/noco.sh b/docker-compose/setup-script/noco.sh index 45e070ff74..540881c4e1 100755 --- a/docker-compose/setup-script/noco.sh +++ b/docker-compose/setup-script/noco.sh @@ -62,6 +62,42 @@ check_for_docker_compose_sudo() { fi } +# Function to read a number from the user +read_number() { + local number + read -p "$1" number + + # Ensure the input is a number or empty + while ! [[ $number =~ ^[0-9]+$ ]] && [ -n "$number" ] ; do + read -p "Please enter a valid number: " number + done + + echo $number +} + +# Function to read a number within a range from the user +read_number_range() { + local number, min, max + + # Check if there are 3 arguments + if [ "$#" -ne 3 ]; then + number=$(read_number) + min=$1 + max=$2 + else + number=$(read_number "$1") + min=$2 + max=$3 + fi + + # Ensure the input is in the specified range + while [[ -n "$number" && ($number -lt $min || $number -gt $max) ]]; do + number=$(read_number "Please enter a number between $min and $max: ") + done + + echo $number +} + # ***************** HELPER FUNCTIONS END *********************************** # ****************************************************************************** @@ -213,7 +249,18 @@ else message_arr+=("Watchtower: Disabled") fi +echo "Show Advanced Options [Y/N] (default: N): " +read ADVANCED_OPTIONS +if [ -n "$ADVANCED_OPTIONS" ] && { [ "$ADVANCED_OPTIONS" = "Y" ] || [ "$ADVANCED_OPTIONS" = "y" ]; }; then + NUM_CORES=$(nproc) + echo "How many instances of NocoDB do you want to run? (Maximum: ${NUM_CORES} (default: 1): " + NUM_INSTANCES=$(read_number_range 1 $NUM_CORE +fi + +if [ -z "$NUM_INSTANCES" ]; then + NUM_INSTANCES=1 +fi # ****************************************************************************** # *********************** INPUTS FROM USER END ******************************** From 586f715d4f18d93f0c79b7d448959303cda7071a Mon Sep 17 00:00:00 2001 From: Rohit T P Date: Wed, 17 Apr 2024 09:12:17 +0000 Subject: [PATCH 02/18] chore: upgrade from docker-compose to docker compose --- docker-compose/setup-script/noco.sh | 57 +++++++++++++++-------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/docker-compose/setup-script/noco.sh b/docker-compose/setup-script/noco.sh index 540881c4e1..e4112b2212 100755 --- a/docker-compose/setup-script/noco.sh +++ b/docker-compose/setup-script/noco.sh @@ -53,9 +53,9 @@ install_package() { fi } -# Function to check if sudo is required for Docker Compose command -check_for_docker_compose_sudo() { - if docker-compose ps >/dev/null 2>&1; then +# Function to check if sudo is required for Docker command +check_for_docker_sudo() { + if docker ps >/dev/null 2>&1; then echo "n" else echo "y" @@ -107,7 +107,7 @@ read_number_range() { # ******************** SYSTEM REQUIREMENTS CHECK START ************************* # Check if the following requirements are met: -# a. docker, docker-compose, jq installed +# a. docker, jq installed # b. port mapping check : 80,443 are free or being used by nginx container REQUIRED_PORTS=(80 443) @@ -121,14 +121,11 @@ if ! command_exists wget; then fi # d. Check if required tools are installed -echo " | Checking if required tools (docker, docker-compose, lsof) are installed..." -for tool in docker docker-compose lsof openssl; do +echo " | Checking if required tools (docker, lsof) are installed..." +for tool in docker lsof openssl; do if ! command_exists "$tool"; then echo "$tool is not installed. Setting up for installation..." - if [ "$tool" = "docker-compose" ]; then - sudo -E curl -L https://github.com/docker/compose/releases/download/1.29.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose - sudo chmod +x /usr/local/bin/docker-compose - elif [ "$tool" = "docker" ]; then + if [ "$tool" = "docker" ]; then wget -qO- https://get.docker.com/ | sh elif [ "$tool" = "lsof" ]; then install_package lsof @@ -306,6 +303,10 @@ services: nocodb: image: ${IMAGE} env_file: docker.env + deploy: + mode: replicated + replicas: ${NUM_INSTANCES} + endpoint_mode: dnsrr depends_on: - db ${DEPENDS_ON} @@ -524,20 +525,20 @@ server { EOF fi -IS_DOCKER_COMPOSE_REQUIRE_SUDO=$(check_for_docker_compose_sudo) +IS_DOCKER_REQUIRE_SUDO=$(check_for_docker_sudo) # Generate the update.sh file for upgrading images -if [ "$IS_DOCKER_COMPOSE_REQUIRE_SUDO" = "y" ]; then +if [ "$IS_DOCKER_REQUIRE_SUDO" = "y" ]; then cat > ./update.sh < ./update.sh < Date: Wed, 17 Apr 2024 09:44:58 +0000 Subject: [PATCH 03/18] feat: added multiple nocodb instance option --- docker-compose/setup-script/noco.sh | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/docker-compose/setup-script/noco.sh b/docker-compose/setup-script/noco.sh index e4112b2212..df0111018d 100755 --- a/docker-compose/setup-script/noco.sh +++ b/docker-compose/setup-script/noco.sh @@ -77,7 +77,9 @@ read_number() { # Function to read a number within a range from the user read_number_range() { - local number, min, max + local number + local min + local max # Check if there are 3 arguments if [ "$#" -ne 3 ]; then @@ -251,8 +253,8 @@ read ADVANCED_OPTIONS if [ -n "$ADVANCED_OPTIONS" ] && { [ "$ADVANCED_OPTIONS" = "Y" ] || [ "$ADVANCED_OPTIONS" = "y" ]; }; then NUM_CORES=$(nproc) - echo "How many instances of NocoDB do you want to run? (Maximum: ${NUM_CORES} (default: 1): " - NUM_INSTANCES=$(read_number_range 1 $NUM_CORE + echo "How many instances of NocoDB do you want to run (Maximum: ${NUM_CORES}) ? (default: 1): " + NUM_INSTANCES=$(read_number_range 1 $NUM_CORES) fi if [ -z "$NUM_INSTANCES" ]; then @@ -297,8 +299,6 @@ fi # Write the Docker Compose file with the updated password cat < docker-compose.yml -version: '3' - services: nocodb: image: ${IMAGE} @@ -306,7 +306,6 @@ services: deploy: mode: replicated replicas: ${NUM_INSTANCES} - endpoint_mode: dnsrr depends_on: - db ${DEPENDS_ON} @@ -492,6 +491,12 @@ mkdir -p ./nginx-post-config # Create nginx config with the provided domain name cat > ./nginx-post-config/default.conf < Date: Wed, 17 Apr 2024 11:38:27 +0000 Subject: [PATCH 04/18] chore: refactored code to avoid multipe if conditions --- docker-compose/setup-script/noco.sh | 45 ++++++----------------------- 1 file changed, 9 insertions(+), 36 deletions(-) diff --git a/docker-compose/setup-script/noco.sh b/docker-compose/setup-script/noco.sh index df0111018d..7513b91f8a 100755 --- a/docker-compose/setup-script/noco.sh +++ b/docker-compose/setup-script/noco.sh @@ -531,36 +531,18 @@ EOF fi IS_DOCKER_REQUIRE_SUDO=$(check_for_docker_sudo) +DOCKER_COMMAND=([ "$IS_DOCKER_REQUIRE_SUDO" = "y" ] && echo "sudo docker" || echo "docker") - -# Generate the update.sh file for upgrading images -if [ "$IS_DOCKER_REQUIRE_SUDO" = "y" ]; then - cat > ./update.sh < ./update.sh < ./update.sh < Date: Wed, 17 Apr 2024 11:59:21 +0000 Subject: [PATCH 05/18] feat: generate help.sh to manage installed nocobd --- docker-compose/setup-script/noco.sh | 103 +++++++++++++++++++++++++++- 1 file changed, 102 insertions(+), 1 deletion(-) diff --git a/docker-compose/setup-script/noco.sh b/docker-compose/setup-script/noco.sh index 7513b91f8a..adb34f51b8 100755 --- a/docker-compose/setup-script/noco.sh +++ b/docker-compose/setup-script/noco.sh @@ -531,7 +531,108 @@ EOF fi IS_DOCKER_REQUIRE_SUDO=$(check_for_docker_sudo) -DOCKER_COMMAND=([ "$IS_DOCKER_REQUIRE_SUDO" = "y" ] && echo "sudo docker" || echo "docker") +DOCKER_COMMAND=$([ "$IS_DOCKER_REQUIRE_SUDO" = "y" ] && echo "sudo docker" || echo "docker") + +# Generate help script +cat > ./help.sh < ./update.sh < Date: Wed, 17 Apr 2024 12:38:25 +0000 Subject: [PATCH 06/18] chore: added i/o formatting for help script --- docker-compose/setup-script/noco.sh | 39 ++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/docker-compose/setup-script/noco.sh b/docker-compose/setup-script/noco.sh index adb34f51b8..97860e5038 100755 --- a/docker-compose/setup-script/noco.sh +++ b/docker-compose/setup-script/noco.sh @@ -537,12 +537,18 @@ DOCKER_COMMAND=$([ "$IS_DOCKER_REQUIRE_SUDO" = "y" ] && echo "sudo docker" || ec cat > ./help.sh < Date: Wed, 17 Apr 2024 13:13:34 +0000 Subject: [PATCH 07/18] fix: fixed coderabbitai suggestions --- docker-compose/setup-script/noco.sh | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/docker-compose/setup-script/noco.sh b/docker-compose/setup-script/noco.sh index 97860e5038..22fd8cd6a0 100755 --- a/docker-compose/setup-script/noco.sh +++ b/docker-compose/setup-script/noco.sh @@ -65,14 +65,14 @@ check_for_docker_sudo() { # Function to read a number from the user read_number() { local number - read -p "$1" number + read -rp "$1" number # Ensure the input is a number or empty while ! [[ $number =~ ^[0-9]+$ ]] && [ -n "$number" ] ; do - read -p "Please enter a valid number: " number + read -rp "Please enter a valid number: " number done - echo $number + echo "$number" } # Function to read a number within a range from the user @@ -97,7 +97,7 @@ read_number_range() { number=$(read_number "Please enter a number between $min and $max: ") done - echo $number + echo "$number" } # ***************** HELPER FUNCTIONS END *********************************** @@ -249,12 +249,14 @@ else fi echo "Show Advanced Options [Y/N] (default: N): " -read ADVANCED_OPTIONS +read -r ADVANCED_OPTIONS if [ -n "$ADVANCED_OPTIONS" ] && { [ "$ADVANCED_OPTIONS" = "Y" ] || [ "$ADVANCED_OPTIONS" = "y" ]; }; then NUM_CORES=$(nproc) echo "How many instances of NocoDB do you want to run (Maximum: ${NUM_CORES}) ? (default: 1): " - NUM_INSTANCES=$(read_number_range 1 $NUM_CORES) + NUM_INSTANCES=$(read_number_range 1 "$NUM_CORES") + + message_arr+=("Number of instances: $NUM_INSTANCES") fi if [ -z "$NUM_INSTANCES" ]; then @@ -580,6 +582,9 @@ show_logs() { echo "2. db" echo "3. nginx" echo "4. redis" + echo "5. watchtower" + echo "6. All" + echo "0. Back to main menu" echo "Enter your choice: " read -n 1 log_choise @@ -589,6 +594,9 @@ show_logs() { 2) $DOCKER_COMMAND compose logs -f db ;; 3) $DOCKER_COMMAND compose logs -f nginx ;; 4) $DOCKER_COMMAND compose logs -f redis ;; + 5) $DOCKER_COMMAND compose logs -f watchtower ;; + 6) $DOCKER_COMMAND compose logs -f ;; + 0) return ;; *) echo "Invalid choice. Returning to main menu." ;; esac } @@ -649,6 +657,8 @@ while true; do done EOF +message_arr+=("Help script: help.sh") + cat > ./update.sh < Date: Thu, 18 Apr 2024 19:55:44 +0000 Subject: [PATCH 08/18] feat: added separate logging for replicas --- docker-compose/setup-script/noco.sh | 80 ++++++++++++++++++++++------- 1 file changed, 62 insertions(+), 18 deletions(-) diff --git a/docker-compose/setup-script/noco.sh b/docker-compose/setup-script/noco.sh index 22fd8cd6a0..14841c4a6a 100755 --- a/docker-compose/setup-script/noco.sh +++ b/docker-compose/setup-script/noco.sh @@ -536,7 +536,7 @@ IS_DOCKER_REQUIRE_SUDO=$(check_for_docker_sudo) DOCKER_COMMAND=$([ "$IS_DOCKER_REQUIRE_SUDO" = "y" ] && echo "sudo docker" || echo "docker") # Generate help script -cat > ./help.sh < nocodb_20240417_131051/help.sh < Date: Thu, 18 Apr 2024 19:57:18 +0000 Subject: [PATCH 09/18] fix: fixed typo --- docker-compose/setup-script/noco.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose/setup-script/noco.sh b/docker-compose/setup-script/noco.sh index 14841c4a6a..c65841789d 100755 --- a/docker-compose/setup-script/noco.sh +++ b/docker-compose/setup-script/noco.sh @@ -705,7 +705,7 @@ message_arr+=("Help script: help.sh") cat > ./update.sh < Date: Fri, 19 Apr 2024 01:32:46 +0530 Subject: [PATCH 10/18] Apply suggestions from code review Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- docker-compose/setup-script/noco.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose/setup-script/noco.sh b/docker-compose/setup-script/noco.sh index c65841789d..566b6c8a58 100755 --- a/docker-compose/setup-script/noco.sh +++ b/docker-compose/setup-script/noco.sh @@ -721,7 +721,7 @@ sleep 5 if [ "$SSL_ENABLED" = 'y' ] || [ "$SSL_ENABLED" = 'Y' ]; then echo 'Starting Letsencrypt certificate request...'; - $DOCKER_COMMAND compose exec certbot certbot certonly --webroot --webroot-path=/var/www/certbot -d "$DOMAIN_NAME" --email contact@"$DOMAIN_NAME" --agree-tos --no-eff-email && echo "Certificate request successful" || echo "Certificate request failed" + $DOCKER_COMMAND compose exec certbot certbot certonly --webroot --webroot-path=/var/www/certbot -d "$DOMAIN_NAME" --email "contact@$DOMAIN_NAME" --agree-tos --no-eff-email && echo "Certificate request successful" || echo "Certificate request failed" # Initial Let's Encrypt certificate request # Update the nginx config to use the new certificates From 242a8e391248b8d084151e1b89ca29b76d0a1c96 Mon Sep 17 00:00:00 2001 From: Rohit T P Date: Fri, 19 Apr 2024 15:24:44 +0000 Subject: [PATCH 11/18] fix: fixed typo --- docker-compose/setup-script/noco.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose/setup-script/noco.sh b/docker-compose/setup-script/noco.sh index 566b6c8a58..4c68e6c717 100755 --- a/docker-compose/setup-script/noco.sh +++ b/docker-compose/setup-script/noco.sh @@ -536,7 +536,7 @@ IS_DOCKER_REQUIRE_SUDO=$(check_for_docker_sudo) DOCKER_COMMAND=$([ "$IS_DOCKER_REQUIRE_SUDO" = "y" ] && echo "sudo docker" || echo "docker") # Generate help script -cat > nocodb_20240417_131051/help.sh < help.sh < Date: Fri, 19 Apr 2024 16:52:20 +0000 Subject: [PATCH 12/18] feat: improved menu action on INT --- docker-compose/setup-script/noco.sh | 71 +++++++++++++++-------------- 1 file changed, 38 insertions(+), 33 deletions(-) diff --git a/docker-compose/setup-script/noco.sh b/docker-compose/setup-script/noco.sh index 4c68e6c717..4a05d009ad 100755 --- a/docker-compose/setup-script/noco.sh +++ b/docker-compose/setup-script/noco.sh @@ -539,16 +539,13 @@ DOCKER_COMMAND=$([ "$IS_DOCKER_REQUIRE_SUDO" = "y" ] && echo "sudo docker" || ec cat > help.sh < Date: Fri, 19 Apr 2024 16:56:56 +0000 Subject: [PATCH 13/18] fix: fixed nproc not available on mac --- docker-compose/setup-script/noco.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/docker-compose/setup-script/noco.sh b/docker-compose/setup-script/noco.sh index 4a05d009ad..0d9eeb6766 100755 --- a/docker-compose/setup-script/noco.sh +++ b/docker-compose/setup-script/noco.sh @@ -252,7 +252,7 @@ echo "Show Advanced Options [Y/N] (default: N): " read -r ADVANCED_OPTIONS if [ -n "$ADVANCED_OPTIONS" ] && { [ "$ADVANCED_OPTIONS" = "Y" ] || [ "$ADVANCED_OPTIONS" = "y" ]; }; then - NUM_CORES=$(nproc) + 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") @@ -640,9 +640,7 @@ show_logs() { elif [ "\$log_choice" == "A" ] || [ "\$log_choice" == "a" ]; then trap 'show_logs' INT $DOCKER_COMMAND compose logs -f - elif [ "\$log_choice" == "0" ]; then - return - else + elif [ "\$log_choice" != "0" ]; then show_logs fi @@ -665,7 +663,7 @@ upgrade_service() { # Function to scale the service scale_service() { - num_cores=\$(nproc) + num_cores=\$(nproc || sysctl -n hw.ncpu || echo 1) current_scale=\$($DOCKER_COMMAND compose ps -q nocodb | wc -l) echo -e "\nCurrent number of instances: \$current_scale" echo "How many instances of NocoDB do you want to run (Maximum: \${num_cores}) ? (default: 1): " From ad4a720272aac6b4ae43a62ff9d290123ef9d9e3 Mon Sep 17 00:00:00 2001 From: Rohit T P Date: Sat, 20 Apr 2024 12:03:17 +0000 Subject: [PATCH 14/18] fix: fixed ctrl + c not working --- docker-compose/setup-script/noco.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/docker-compose/setup-script/noco.sh b/docker-compose/setup-script/noco.sh index 0d9eeb6766..d5e0af7b66 100755 --- a/docker-compose/setup-script/noco.sh +++ b/docker-compose/setup-script/noco.sh @@ -686,6 +686,7 @@ monitoring_service() { # Main program loop while true; do + trap - INT show_menu echo "Enter your choice: " From 402ce802a06da377a0e7ce6ea085c7d7b782228b Mon Sep 17 00:00:00 2001 From: Rohit T P Date: Sat, 20 Apr 2024 13:16:43 +0000 Subject: [PATCH 15/18] fix: removed associative arrays be keep mac os compatibility --- docker-compose/setup-script/noco.sh | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/docker-compose/setup-script/noco.sh b/docker-compose/setup-script/noco.sh index d5e0af7b66..6685c0efe4 100755 --- a/docker-compose/setup-script/noco.sh +++ b/docker-compose/setup-script/noco.sh @@ -601,20 +601,26 @@ show_logs() { echo "Select a container for logs:" # Fetch the list of services - mapfile -t services < <($DOCKER_COMMAND compose ps --services) - declare -A service_replicas + services=() + while IFS= read -r service; do + services+=("\$service") + done < <($DOCKER_COMMAND compose ps --services) + + service_replicas=() + count=0 # For each service, count the number of running instances for service in "\${services[@]}"; do # Count the number of lines that have the service name, which corresponds to the number of replicas replicas=\$($DOCKER_COMMAND compose ps \$service | grep "\$service" | wc -l) - service_replicas["\$service"]=\$replicas + service_replicas["\$count"]=\$replicas + count=\$((count + 1)) done count=1 for service in "\${services[@]}"; do - echo "\$count. \$service (\${service_replicas[\$service]} replicas)" + echo "\$count. \$service (\${service_replicas[((\$count - 1))]} replicas)" count=\$((count + 1)) done @@ -627,7 +633,7 @@ show_logs() { if [[ "\$log_choice" =~ ^[0-9]+\$ ]] && [ "\$log_choice" -gt 0 ] && [ "\$log_choice" -lt "\$count" ]; then service_index=\$((log_choice-1)) service="\${services[\$service_index]}" - num_replicas="\${service_replicas[\$service]}" + num_replicas="\${service_replicas[\$service_index]}" if [ "\$num_replicas" -gt 1 ]; then trap 'show_logs_sub_menu "\$service" "\$num_replicas"' INT @@ -640,7 +646,9 @@ show_logs() { elif [ "\$log_choice" == "A" ] || [ "\$log_choice" == "a" ]; then trap 'show_logs' INT $DOCKER_COMMAND compose logs -f - elif [ "\$log_choice" != "0" ]; then + elif [ "\$log_choice" == "0" ]; then + return + else show_logs fi From 3634e71264aac1ab1d625bafcd31da1fedeffc8b Mon Sep 17 00:00:00 2001 From: Rohit T P Date: Sat, 20 Apr 2024 13:18:01 +0000 Subject: [PATCH 16/18] chore: proceed only after enter is pressed --- docker-compose/setup-script/noco.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose/setup-script/noco.sh b/docker-compose/setup-script/noco.sh index 6685c0efe4..36c13833de 100755 --- a/docker-compose/setup-script/noco.sh +++ b/docker-compose/setup-script/noco.sh @@ -580,7 +580,7 @@ show_logs_sub_menu() { echo "A. All" echo "0. Back to Logs Menu" echo "Enter replica number: " - read -n 1 replica_choice + read replica_choice if [[ "\$replica_choice" =~ ^[0-9]+\$ ]] && [ "\$replica_choice" -gt 0 ] && [ "\$replica_choice" -le "\$2" ]; then container_id=\$($DOCKER_COMMAND compose ps | grep "\$1-\$replica_choice" | cut -d " " -f 1) @@ -627,7 +627,7 @@ show_logs() { echo "A. All" echo "0. Back to main menu" echo "Enter your choice: " - read -n 1 log_choice + read log_choice echo if [[ "\$log_choice" =~ ^[0-9]+\$ ]] && [ "\$log_choice" -gt 0 ] && [ "\$log_choice" -lt "\$count" ]; then From 6d2155ef95077ebf1b64c136ee6a77365687ad9b Mon Sep 17 00:00:00 2001 From: Rohit T P Date: Sat, 20 Apr 2024 13:41:43 +0000 Subject: [PATCH 17/18] feat: warn if docker is not running --- docker-compose/setup-script/noco.sh | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/docker-compose/setup-script/noco.sh b/docker-compose/setup-script/noco.sh index 36c13833de..33dcd194e5 100755 --- a/docker-compose/setup-script/noco.sh +++ b/docker-compose/setup-script/noco.sh @@ -543,9 +543,25 @@ $(declare -f read_number) $(declare -f read_number_range) +check_if_docker_is_running() { + yellow="\033[1;33m" + nocolor="\033[0m" + blue="\033[1;34m" + + if ! $DOCKER_COMMAND ps >/dev/null 2>&1; then + echo "+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+" + echo -e "| \${yellow}Warning ! \${nocolor} |" + echo "| Docker is not running. Most of the commands will not work without Docker. |" + echo "| Use the following command to start Docker: |" + echo -e "| \${blue} sudo systemctl start docker \${nocolor} |" + echo "+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+" + fi +} + # Function to display the menu show_menu() { -# clear + clear + check_if_docker_is_running echo "" echo \$MSG echo "Service Management Menu:" From 24bede8f06f1a9c49f13053eb8af0c61ec31ff27 Mon Sep 17 00:00:00 2001 From: Rohit T P Date: Sat, 20 Apr 2024 13:57:16 +0000 Subject: [PATCH 18/18] feat: added colors --- docker-compose/setup-script/noco.sh | 38 +++++++++++++++++------------ 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/docker-compose/setup-script/noco.sh b/docker-compose/setup-script/noco.sh index 33dcd194e5..d3abc82ba5 100755 --- a/docker-compose/setup-script/noco.sh +++ b/docker-compose/setup-script/noco.sh @@ -543,17 +543,23 @@ $(declare -f read_number) $(declare -f read_number_range) -check_if_docker_is_running() { - yellow="\033[1;33m" - nocolor="\033[0m" - blue="\033[1;34m" +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +MAGENTA='\033[0;35m' +CYAN='\033[0;36m' +ORANGE='\033[0;33m' +BOLD='\033[1m' +NC='\033[0m' +check_if_docker_is_running() { if ! $DOCKER_COMMAND ps >/dev/null 2>&1; then echo "+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+" - echo -e "| \${yellow}Warning ! \${nocolor} |" + echo -e "| \${BOLD}\${YELLOW}Warning ! \${NC} |" echo "| Docker is not running. Most of the commands will not work without Docker. |" echo "| Use the following command to start Docker: |" - echo -e "| \${blue} sudo systemctl start docker \${nocolor} |" + echo -e "| \${BLUE} sudo systemctl start docker \${NC} |" echo "+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+" fi } @@ -564,15 +570,15 @@ show_menu() { check_if_docker_is_running echo "" echo \$MSG - echo "Service Management Menu:" - echo "1. Start Service" - echo "2. Stop Service" - echo "3. Logs" - echo "4. Restart" - echo "5. Upgrade" - echo "6. Scale" - echo "7. Monitoring" - echo "0. Exit" + echo -e "\t\t\${BOLD}Service Management Menu\${NC}" + echo -e " \${GREEN}1. Start Service" + echo -e " \${ORANGE}2. Stop Service" + echo -e " \${CYAN}3. Logs" + echo -e " \${MAGENTA}4. Restart" + echo -e " \${BLUE}5. Upgrade" + echo -e " 6. Scale" + echo -e " 7. Monitoring" + echo -e " \${RED}0. Exit\${NC}" } # Function to start the service @@ -714,7 +720,7 @@ while true; do show_menu echo "Enter your choice: " - read -n 1 choice + read choice case \$choice in 1) start_service && MSG="NocoDB Started" ;; 2) stop_service && MSG="NocoDB Stopped" ;;