From ab5a89a21b8d7f1bf9b8b5533a2e0f2b1e768577 Mon Sep 17 00:00:00 2001 From: starbirdtech383 Date: Wed, 7 Feb 2024 10:56:50 +0530 Subject: [PATCH] use all defaults action added --- docker-compose/aio/docker-compose.yml | 1 + docker-compose/aio/install.sh | 14 +++++--- docker-compose/aio/pre-req-check.sh | 7 ++-- docker-compose/aio/prepare_env.sh | 30 +++++++--------- docker-compose/aio/sbin/install_vars.sh | 46 ++++++++++++++++++++++--- docker-compose/aio/sbin/util.sh | 7 +++- 6 files changed, 73 insertions(+), 32 deletions(-) diff --git a/docker-compose/aio/docker-compose.yml b/docker-compose/aio/docker-compose.yml index f0b69d7e01..5ecbb7f203 100644 --- a/docker-compose/aio/docker-compose.yml +++ b/docker-compose/aio/docker-compose.yml @@ -98,6 +98,7 @@ services: cpus: '1' memory: 1000M certbot: + container_name: nocodb_certbot image: certbot/certbot:latest volumes: - ${NC_INSTALL_ROOT:-/opt/nocodb}/conf/nginx/certbot/www:/var/www/certbot/:rw diff --git a/docker-compose/aio/install.sh b/docker-compose/aio/install.sh index 0e2019984d..a1c566edab 100755 --- a/docker-compose/aio/install.sh +++ b/docker-compose/aio/install.sh @@ -22,16 +22,20 @@ if [[ ${PRE_REQ_SUCCESS} != 0 ]] then echo "** Few pre-requisites are failing. Recommend to resolve and proceed. However you could still proceed to install **" >&2 else - echo "** All pre-requistites are taken care of. Proceed to install.. **" + echo "** All pre-requistites are taken care of. Proceeding to install.. **" fi +# ask do you want to proceed with all defaults, +# if yes, then no prompts if asksure; then echo "Preparing environment file before install.." - ${SCRIPT_DIR}/prepare_env.sh + promptUser=true + if asksure " | Press Y to continue with defaults or N to customise app properties (Y/N)"; then + promptUser=false + fi + ${SCRIPT_DIR}/prepare_env.sh ${promptUser} echo "Installing docker containers" docker-compose -f ${SCRIPT_DIR}/docker-compose.yml up -d else echo "Exiting without install. You can install using docker-compose -f ${SCRIPT_DIR}/docker-compose.yml up -d " -fi - - +fi \ No newline at end of file diff --git a/docker-compose/aio/pre-req-check.sh b/docker-compose/aio/pre-req-check.sh index 529298dbe1..6f54865fda 100755 --- a/docker-compose/aio/pre-req-check.sh +++ b/docker-compose/aio/pre-req-check.sh @@ -16,12 +16,11 @@ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) source ${SCRIPT_DIR}/sbin/util.sh source ${SCRIPT_DIR}/sbin/install_vars.sh -echo "Performing nocodb system check and setup. This step may require sudo permissions to" -echo " | Check if ports are accessible" +echo "** Performing nocodb system check and setup. This step may require sudo permissions" PRE_REQ=0 # d. Check if required tools are installed -echo "Checking if required tools (docker, docker-compose, jq, lsof) are installed..." +echo " | Checking if required tools (docker, docker-compose, jq, lsof) are installed..." for tool in docker docker-compose lsof; do if ! command -v "$tool" &> /dev/null; then echo " | Error: $tool is not installed. Please install it before proceeding." @@ -39,7 +38,7 @@ done echo " | Checking port accessibility..." for port in "${REQUIRED_PORTS[@]}"; do if lsof -Pi :$port -sTCP:LISTEN -t >/dev/null; then - echo " | Port $port is in use. Please make sure it is free." >&2 + echo " | WARNING: Port $port is in use. Please make sure it is free." >&2 PRE_REQ=1 else echo " | Port $port is free." diff --git a/docker-compose/aio/prepare_env.sh b/docker-compose/aio/prepare_env.sh index ffb8cc4a86..357270bfa2 100755 --- a/docker-compose/aio/prepare_env.sh +++ b/docker-compose/aio/prepare_env.sh @@ -19,18 +19,17 @@ fi function acceptProperty(){ local varDetail="$1" local promptUser="${2:-true}" - prompt=$(echo "$varDetail" | cut -d '|' -f1) - prop=$(echo "$varDetail" | cut -d '|' -f2) + prompt=$(echo "$varDetail" | cut -d '|' -f2) + prop=$(echo "$varDetail" | cut -d '|' -f1) key=$(echo "$prop" | cut -d'=' -f1) default_value="${prop#*=}" prev_value_or_default=${!key:-${default_value}} - # echo prompt: ${prompt} + echo promptUser: ${promptUser} # echo prop: ${prop} # echo key: ${key} # echo default_value: ${default_value} - - if(${promptUser} == "true"); then + if [[ ${promptUser} == "true" ]]; then read -p " || Enter value for $key (default: ${prev_value_or_default}): " user_input fi @@ -44,21 +43,18 @@ function acceptProperty(){ for multi_property_array in basic_properties invite_only_signup_priorities google_login_properties email_properties s3_attachment_properties ; do array_name="$multi_property_array[@]" # Name of the array to process array=("${!array_name}") - for varDetail in "${array[@]}"; do - promptUser=true - promptMsg=$(echo "$varDetail" | cut -d '|' -f1) - prop=$(echo "$varDetail" | cut -d '|' -f2) - if [[ ${promptMsg} == "main" ]] + promptUser="${1}" + for varDetail in "${array[@]}"; do + promptMsg=$(echo "$varDetail" | cut -d '|' -f2) + prop=$(echo "$varDetail" | cut -d '|' -f1) + if [[ ${promptUser} == "true" ]] && [[ ${prop} == "main" ]] then - echo $prop - if asksure; then - continue - else + echo $promptMsg + if ! asksure; then # set all defaults here - promptUser=false - # acceptProperty "${varDetail}" "${promptUser}" - break + promptUser=false fi + continue fi acceptProperty "${varDetail}" "${promptUser}" done diff --git a/docker-compose/aio/sbin/install_vars.sh b/docker-compose/aio/sbin/install_vars.sh index 609722c3ed..5fd059729f 100644 --- a/docker-compose/aio/sbin/install_vars.sh +++ b/docker-compose/aio/sbin/install_vars.sh @@ -3,11 +3,47 @@ REQUIRED_PORTS=(80 443) DOCKER_IMAGES=("redis:latest" "postgres:14.7" "nocodb/nocodb:latest" "nginx" "certbot/certbot:latest" ) # Array of properties with default values -basic_properties=("main|Basic Configurations" "Username for postgres database|POSTGRES_USER=postgres" "|POSTGRES_PASSWORD=test123" "|POSTGRES_DB=nocodb" "|NC_REDIS_URL=redis://redis:6379/4" '|NC_DB=pg://postgres:5432?u=postgres&password=${POSTGRES_PASSWORD:-nocodb}&d=postgres' "Are you using custom DNS, configure NC_PUBLIC_URL to reflect in the invite emails?|NC_PUBLIC_URL=$(hostname)" "Disable connecting to external db?|NC_CONNECT_TO_EXTERNAL_DB_DISABLED=false") -invite_only_signup_priorities=("main|Allow invite only sign-up" "invite only signup?|NC_INVITE_ONLY_SIGNUP=false" "|NC_ADMIN_EMAIL=admin@nocodb.com" "|NC_ADMIN_PASSWORD=nocodb123") -google_login_properties=("main|Configure Google Login" "Enter Client ID|NC_GOOGLE_CLIENT_ID=" "Enter Client ID|NC_GOOGLE_CLIENT_SECRET=") -email_properties=("main|Configure smtp properties" "|NC_SMTP_FROM=" "|NC_SMTP_HOST=" "|NC_SMTP_PORT=" "|NC_SMTP_USERNAME=" "|NC_SMTP_PASSWORD=" "|NC_SMTP_SECURE=" "|NC_SMTP_IGNORE_TLS=" ) -s3_attachment_properties=("main|Do you want to configure s3 for attachements?" "|NC_S3_BUCKET_NAME=nocodb-attachements" "|NC_S3_REGION=" "|NC_S3_ACCESS_KEY=" "|NC_S3_ACCESS_SECRET=" ) +basic_properties=( +"main|Basic Configurations" +"POSTGRES_USER=postgres | Username for postgres database" +"POSTGRES_PASSWORD=test123 | " +"POSTGRES_DB=nocodb | " +"NC_REDIS_URL=redis://redis:6379/4 | default to redis container" +'NC_DB=pg://postgres:5432?u=postgres&password=${POSTGRES_PASSWORD:-nocodb}&d=postgres | hide' +"NC_PUBLIC_URL=$(hostname) | Are you using custom DNS, configure NC_PUBLIC_URL to reflect in the invite emails?" +"NC_CONNECT_TO_EXTERNAL_DB_DISABLED=false | Disable connecting to external db?" +) + +invite_only_signup_priorities=( +"main|Allow invite only sign-up" +"NC_INVITE_ONLY_SIGNUP=false | invite only signup?" +"NC_ADMIN_EMAIL=admin@nocodb.com | " +"NC_ADMIN_PASSWORD=nocodb123 | " +) + +google_login_properties=( +"main|Configure Google Login" +"NC_GOOGLE_CLIENT_ID= | Enter Client ID" +"NC_GOOGLE_CLIENT_SECRET= | Enter Client ID") + +email_properties=( +"main|Configure smtp properties" +"NC_SMTP_FROM= |" +"NC_SMTP_HOST= |" +"NC_SMTP_PORT= |" +"NC_SMTP_USERNAME= |" +"NC_SMTP_PASSWORD= |" +"NC_SMTP_SECURE= |" +"NC_SMTP_IGNORE_TLS= |" +) + +s3_attachment_properties=( +"main|Do you want to configure s3 for attachements?" +"NC_S3_BUCKET_NAME=nocodb-attachements |" +"NC_S3_REGION= |" +"NC_S3_ACCESS_KEY= | " +"NC_S3_ACCESS_SECRET= |" +) multi_property_array=(basic_properties invite_only_signup_priorities google_login_properties email_properties s3_attachment_properties) diff --git a/docker-compose/aio/sbin/util.sh b/docker-compose/aio/sbin/util.sh index c192043b2a..b65d4696c5 100644 --- a/docker-compose/aio/sbin/util.sh +++ b/docker-compose/aio/sbin/util.sh @@ -4,7 +4,12 @@ # asksure() { -echo -n " | Press Y to continue or N to skip to next step (Y/N)? " +local custom_msg="${@}" +if [[ ${custom_msg} ]]; then + echo -n "${custom_msg}" +else + echo -n " | Press Y to continue or N to skip (Y/N)? " +fi while read -r -n 1 -s answer; do if [[ $answer = [YyNn] ]]; then [[ $answer = [Yy] ]] && retval=0