Skip to content

Commit

Permalink
qto-200622175852 renaming 2-create-db.sh, fixing importing do_flush_s…
Browse files Browse the repository at this point in the history
…creen, renamed unit_run_dir to original_dir
  • Loading branch information
Diverdi committed Jun 24, 2020
1 parent 52afec2 commit 2c3f606
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 24 deletions.
File renamed without changes.
6 changes: 3 additions & 3 deletions src/bash/deploy-vagrant-vm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ do_set_vars(){
set +e
export app_to_deploy=${1:-qto}
app_owner=$USER || exit 1
unit_run_dir=$(perl -e 'use File::Basename; use Cwd "abs_path"; print dirname(abs_path(@ARGV[0]));' -- "$0")
export product_base_dir=$(cd $unit_run_dir/../../..; echo `pwd`)
export product_dir=$(cd $unit_run_dir/../..; echo `pwd`)
original_dir=$(perl -e 'use File::Basename; use Cwd "abs_path"; print dirname(abs_path(@ARGV[0]));' -- "$0")
export product_base_dir=$(cd $original_dir/../../..; echo `pwd`)
export product_dir=$(cd $original_dir/../..; echo `pwd`)
source "$product_dir/.env"
PRODUCT_INSTANCE_DIR="$product_dir/$app_to_deploy.$VERSION.$ENV_TYPE.$app_owner"
source $PRODUCT_INSTANCE_DIR/lib/bash/funcs/flush-screen.sh
Expand Down
42 changes: 28 additions & 14 deletions src/bash/deployer/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,16 @@ do_set_vars(){
export host_name="$(hostname -s)"
export bash_opts_file=~/.bash_opts.$host_name
export user_at_host=$USER@$host_name || exit 1
export unit_run_dir=$(perl -e 'use File::Basename; use Cwd "abs_path"; print dirname(abs_path(@ARGV[0]));' -- "$0")
export original_dir=$(perl -e 'use File::Basename; use Cwd "abs_path"; print dirname(abs_path(@ARGV[0]));' -- "$0") # formerly known as unit_run_dir

# check on where the installation was started from
# if started via opt/qto/src/bash/deployer/run.sh, then go 3 directory levels up to opt/qto
# otherwise assume that opt/1-setup.sh was used and go to opt/qto
if [ ! "$unit_run_dir" == *"deployer"* ] ;
if [ ! "$original_dir" == *"deployer"* ] ;
then
export product_dir=$(cd $unit_run_dir/$app_to_deploy; echo `pwd`) # ~/opt/qto/
export product_dir=$(cd $original_dir/$app_to_deploy; echo `pwd`) # ~/opt/qto/
else
export product_dir=$(cd $unit_run_dir/../../..; echo `pwd`)
export product_dir=$(cd $original_dir/../../..; echo `pwd`)
fi

# ALWAYS !!! bootstrap a dev instance, for tst and prd use -a to-env=tst , -a to-env=prd
Expand All @@ -88,9 +88,9 @@ do_initial_message(){
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
QTO installation has started.
You can abort it at any time using Ctrl+C.
After the installation please run these commands one by one to continue with the database creation:
bash ;
./2-db-creation.sh
After the installation please run this command to create the database:
./2-create-db.sh
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
EOF_INIT_MSG
}
Expand All @@ -111,15 +111,27 @@ usage_info(){
# 1. Install components necessary for QTO:
# Perl modules, Python, Postgres, nginx, redis, etc.
#
# On completion the directory will change to an instance directory with the name similar to this
# ~/opt/qto/qto.0.7.7.dev.username@hostname
#
# Alternatively you can run the deployer directly, then go to the PRODUCT_INSTANCE_DIR yourself
# . ./qto/src/bash/deployer/run.sh
# source $(find . -name '.env') && cd ~/opt/qto/qto.$VERSION.$ENV_TYPE.$USER@`hostname -s`
. ./qto/setup.sh
. ./qto/1-setup.sh
# 2. Let QTO create a database and fill it with data
. ./qto/src/bash/qto/qto.sh -a check-perl-syntax -a scramble-confs -a provision-db-admin -a run-qto-db-ddl -a load-db-data-from-s3
# 2. Create a database and fill it with data
#
# Former command:
# . ./qto/src/bash/qto/qto.sh -a check-perl-syntax -a scramble-confs -a provision-db-admin -a run-qto-db-ddl -a load-db-data-from-s3
./2-create-db.sh
# 3. Start the web server
#
# Former command:
# ./src/bash/qto/qto.sh -a mojo-hypnotoad-start
./3-start-server.sh
# 3. Create test and production environments
# 4. Create test and production environments
. ./src/bash/qto/qto.sh -a to-env=tst
. ./src/bash/qto/qto.sh -a to-env=prd
Expand Down Expand Up @@ -188,6 +200,8 @@ do_load_functions(){
printf "\nLoading scripts to install Postgres, Perl, Python, Redis, nginx, etc.\n\n"
set -x
source $product_dir/lib/bash/funcs/export-json-section-vars.sh
source $product_dir/lib/bash/funcs/flush-screen.sh
export -f do_flush_screen
source $product_dir/src/bash/deployer/check-setup-bash.func.sh
source $product_dir/src/bash/deployer/check-install-ubuntu-packages.func.sh
source $product_dir/src/bash/deployer/check-install-postgres.func.sh
Expand All @@ -204,7 +218,7 @@ do_load_functions(){


do_copy_git_hooks(){
cp -v $unit_run_dir/../../../cnf/git/hooks/* $unit_run_dir/../../../.git/hooks/
cp -v ./cnf/git/hooks/* ./.git/hooks/
}


Expand Down Expand Up @@ -236,8 +250,8 @@ do_finalize(){
do_flush_screen

printf "\n\n:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::\n\n"
printf "$app_to_deploy deployment completed successfully.\n\nPlease continue database creation by running these commands one by one: \n\n"
printf "bash ;\n./2-db-creation.sh"
printf "$app_to_deploy deployment completed successfully.\n\nPlease run this command to create the database: \n\n"
printf "./2-create-db.sh"
printf "\n:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::\n"
}

Expand Down
8 changes: 4 additions & 4 deletions src/bash/deployer/test-deployer-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ main(){

do_set_vars(){
set -eu -o pipefail
unit_run_dir=$(perl -e 'use File::Basename; use Cwd "abs_path"; print dirname(abs_path(@ARGV[0]));' -- "$0")
product_base_dir=$(cd $unit_run_dir/../../../..; echo `pwd`) # opt/qto/
product_dir=$(cd $unit_run_dir/../../..; echo `pwd`) # opt/qto/qto.dev/
original_dir=$(perl -e 'use File::Basename; use Cwd "abs_path"; print dirname(abs_path(@ARGV[0]));' -- "$0")
product_base_dir=$(cd $original_dir/../../../..; echo `pwd`) # opt/qto/
product_dir=$(cd $original_dir/../../..; echo `pwd`) # opt/qto/qto.dev/
cd $product_dir
source "$unit_run_dir/../../../.env"
source "$original_dir/../../../.env"
source $product_dir/lib/bash/funcs/export-json-section-vars.sh
}

Expand Down
4 changes: 2 additions & 2 deletions src/bash/load-qto-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ usage(){
do_set_vars(){
set -eu -o pipefail
shopt -s expand_aliases # src: http://chiefsandendians.blogspot.com/2010/07/linux-scripts-and-alias.html
unit_run_dir=$(perl -e 'use File::Basename; use Cwd "abs_path"; print dirname(abs_path(@ARGV[0]));' -- "$0")
export product_dir=$(cd $unit_run_dir; echo `pwd`)
original_dir=$(perl -e 'use File::Basename; use Cwd "abs_path"; print dirname(abs_path(@ARGV[0]));' -- "$0")
export product_dir=$(cd $original_dir; echo `pwd`)
cd $product_dir
}

Expand Down
2 changes: 1 addition & 1 deletion src/bash/qto/install/docker/install-postgres.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

unit_run_dir=$(perl -e 'use File::Basename; use Cwd "abs_path"; print dirname(abs_path(@ARGV[0]));' -- "$0")
original_dir=$(perl -e 'use File::Basename; use Cwd "abs_path"; print dirname(abs_path(@ARGV[0]));' -- "$0")

# Add the PostgreSQL PGP key to verify their Debian packages.
# It should be the same key as https://www.postgresql.org/media/keys/ACCC4CF8.asc
Expand Down

0 comments on commit 2c3f606

Please sign in to comment.