Browse Source

message formatting and some minor refactoring

pull/7587/head
starbirdtech383 10 months ago
parent
commit
0722881485
  1. 24
      docker-compose/aio/install.sh
  2. 12
      docker-compose/aio/pre-req-check.sh
  3. 23
      docker-compose/aio/prepare_env.sh
  4. 6
      docker-compose/aio/sbin/install_vars.sh
  5. 2
      docker-compose/aio/sbin/util.sh

24
docker-compose/aio/install.sh

@ -11,34 +11,18 @@
# c. docker repo accessiblity quay.io/minio/minio:RELEASE.2023-12-09T18-17-51Z, redis:latest, postgres:14.7, nocodb/nocodb:latest, nginx
# d. licence check (tbd)
## utility functions
asksure() {
echo -n "Are you sure (Y/N)? "
while read -r -n 1 -s answer; do
if [[ $answer = [YyNn] ]]; then
[[ $answer = [Yy] ]] && retval=0
[[ $answer = [Nn] ]] && retval=1
break
fi
done
echo # just a final linefeed, optics...
return $retval
}
# -- main line code starts here
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
## utility functions
source ${SCRIPT_DIR}/sbin/util.sh
${SCRIPT_DIR}/pre-req-check.sh
PRE_REQ_SUCCESS=$?
if [[ ${PRE_REQ_SUCCESS} != 0 ]]
then
echo "Few pre-requisites are failing.\n Recommend to resolve and proceed.\n However you could still proceed to install" >&2
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. Proceed to install.. **"
fi
if asksure; then

12
docker-compose/aio/pre-req-check.sh

@ -17,14 +17,14 @@ 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 " | Check if ports are accessible"
PRE_REQ=0
# d. Check if required tools 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."
echo " | Error: $tool is not installed. Please install it before proceeding."
exit 1
fi
done
@ -36,13 +36,13 @@ done
# echo "NocoDB version: $nocodb_install_version"
# f. Port mapping check
echo "Checking port accessibility..."
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 " | Port $port is in use. Please make sure it is free." >&2
PRE_REQ=1
else
echo "Port $port is free."
echo " | Port $port is free."
fi
done
@ -57,5 +57,5 @@ done
# fi
# done
echo "System check completed successfully."
echo "** System check completed successfully. **"
exit $PRE_REQ

23
docker-compose/aio/prepare_env.sh

@ -18,18 +18,21 @@ fi
function acceptProperty(){
local varDetail="$1"
local promptUser="${2:-true}"
prompt=$(echo "$varDetail" | cut -d '|' -f1)
prop=$(echo "$varDetail" | cut -d '|' -f2)
key=$(echo "$prop" | cut -d'=' -f1)
default_value="${prop#*=}"
prev_value_or_default=${!key:-${default_value}}
# echo prompt: ${prompt}
# echo prop: ${prop}
# echo key: ${key}
# echo default_value: ${default_value}
read -p "Enter value for $key (default: ${prev_value_or_default}): " user_input
if(${promptUser} == "true"); then
read -p " || Enter value for $key (default: ${prev_value_or_default}): " user_input
fi
# Use user input or default value if empty
value=${user_input:-$prev_value_or_default}
@ -38,26 +41,26 @@ function acceptProperty(){
userValues="${userValues}${key}=${value}\n"
}
# Iterate over the properties array and prompt user for input
echo basic_properties : "${basic_properties[@]}"
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}")
# array=("${!multi_property_array}")
echo array : "${array[@]}"
for varDetail in "${array[@]}"; do
echo varDetail : ${varDetail}
prompt=$(echo "$varDetail" | cut -d '|' -f1)
promptUser=true
promptMsg=$(echo "$varDetail" | cut -d '|' -f1)
prop=$(echo "$varDetail" | cut -d '|' -f2)
if [[ ${prompt} == "main" ]]
if [[ ${promptMsg} == "main" ]]
then
echo $prop
if asksure; then
continue
else
# set all defaults here
promptUser=false
# acceptProperty "${varDetail}" "${promptUser}"
break
fi
fi
acceptProperty "${varDetail}"
acceptProperty "${varDetail}" "${promptUser}"
done
done

6
docker-compose/aio/sbin/install_vars.sh

@ -3,9 +3,9 @@ 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, customise ?" "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=false" "|NC_ADMIN_PASSWORD=false")
google_login_properties=("main|Configure google login" "Enter Client ID|NC_GOOGLE_CLIENT_ID=" "Enter Client ID|NC_GOOGLE_CLIENT_SECRET=")
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=" )

2
docker-compose/aio/sbin/util.sh

@ -4,7 +4,7 @@
#
asksure() {
echo -n "Are you sure (Y/N)? "
echo -n " | Press Y to continue or N to skip to next step (Y/N)? "
while read -r -n 1 -s answer; do
if [[ $answer = [YyNn] ]]; then
[[ $answer = [Yy] ]] && retval=0

Loading…
Cancel
Save