Browse Source

use all defaults action added

pull/7587/head
starbirdtech383 10 months ago
parent
commit
ab5a89a21b
  1. 1
      docker-compose/aio/docker-compose.yml
  2. 14
      docker-compose/aio/install.sh
  3. 7
      docker-compose/aio/pre-req-check.sh
  4. 30
      docker-compose/aio/prepare_env.sh
  5. 46
      docker-compose/aio/sbin/install_vars.sh
  6. 7
      docker-compose/aio/sbin/util.sh

1
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

14
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

7
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."

30
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

46
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)

7
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

Loading…
Cancel
Save