Skip to content

Commit

Permalink
qto-220717175515 change from product version dir to product dir - che…
Browse files Browse the repository at this point in the history
…ck-perl-syntax ok
  • Loading branch information
YordanGeorgiev authored and ci-cd-usr-2202241735 committed Jul 17, 2022
1 parent c903154 commit 803d347
Show file tree
Hide file tree
Showing 265 changed files with 1,495 additions and 2,307 deletions.
2 changes: 0 additions & 2 deletions .env

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
JSON
ExtUtils::MakeMaker
Spiffy
Carp::Always
JSON
JSON::Parse
Data::Printer
Carp::Always
IO::CaptureOutput
Net::DNS
Net::Domain::TLD
Email::Valid
IPC::System::Simple
Mojolicious
IPC::System::Simple
Mojolicious
Mojolicious::Plugin::BasicAuthPlus
Mojolicious::Plugin::StaticCache
Mojolicious::Plugin::RenderFile
Mojolicious::Plugin::Authentication
IO::Socket::SSL
IO::Socket::SSL
URL::Encode
ExtUtils::Installed
File::Copy
Expand All @@ -26,15 +28,15 @@
File::Copy::Recursive
Test::Trap
Test::More
Test::Most
Test::Most
Test::Mojo
DBD::Pg
Tie::Hash::DBD
Scalar::Util::Numeric
Time::HiRes
Mojo::JWT
Mojo::Pg
Mojo::Phantom
DBD::Pg
Mojo::Phantom
Authen::Passphrase::BlowfishCrypt
Term::ReadKey
Term::Prompt
Expand All @@ -45,3 +47,5 @@
Gravatar::URL
Mojolicious::Plugin::Gzip
Excel::Writer::XLSX
Test::Mojo::WithRoles
Text::Iconv
71 changes: 71 additions & 0 deletions cnf/env/lde.env.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"env" : {
"db" : {
"root_pwd" : "c7RN8xzWpW9h",
"postgres_db_useradmin" : "usrldeqtoadmin",
"postgres_db_port" : "15432",
"postgres_db_useradmin_pw" : "bs0HvcKhTBUO",
"postgres_db_user" : "usrldeqtoapp",
"app_user_pwd" : "yE96SvxujCer",
"project_databases" : "lde_qto, lde_ldeel_pro",
"postgres_db_name" : "lde_qto",
"postgres_usr_pw" : "UdDIXogL2yvA",
"postgres_db_host" : "127.0.0.1",
"postgres_os_usr_pw" : "id7V2RKblIwo",
"postgres_db_user_pw" : "u46SLhBNzxys",
"postgres_sys_usr_admin_pw" : "oS6eRolHb9qH",
"AdminEmail" : "dcW6rFF9jwLI"
},
"app" : {
"web_host" : "host-name",
"mojo_morbo_port" : "3001",
"mojo_hypnotoad_port" : "8078",
"postgres_db_name" : "lde_qto",
"num_of_workers" : "2",
"inactivity_timeout" : "60",
"https_port" : "441",
"port" : "8078",
"ht_protocol" : "http",
"nginx_port" : "78",
"ws_protocol" : "ws"
},
"log" : {
"LogDir" : "$ProductDir/dat/log",
"LogToFile" : 1,
"PrintDebugMsgs" : 1,
"LogFile" : "$LogDir/$ProductName.%YYYY%.%MM%.%DD%.log",
"TimeFormat" : "YYYY-MM-DD hh:mm:ss",
"LogTimeToTextSeparator" : ":::",
"PrintWarningMsgs" : 1,
"PrintConsoleMsgs" : 1,
"PrintInfoMsgs" : 1,
"PrintErrorMsgs" : 1,
"PrintTraceMsgs" : 1
},
"ssh" : {
"ssh_key_pair_file" : "~/.ssh/key-pair-qto-amzn.pem",
"launch_dir" : "/home/ubuntu/dat/tmp",
"ssh_server" : "lde.qto.fi",
"ssh_user" : "ubuntu"
},
"redis" : {
"server" : "127.0.0.1",
"port" : "16379"
},
"aws" : {
"AdminEmail" : "yordan.georgiev@gmail.com",
"bucket" : "qto.fi",
"AWS_DEFAULT_REGION" : "eu-west-1",
"AWS_SECRET_ACCESS_KEY" : "WFwdysUn6mJx",
"pem_key_fpath" : "~/.ssh/id_rsa.aws-ec2.qto.lde",
"ssh_key_pair_file" : "~/.ssh/key-pair-qto-amzn.pem",
"availability_zone" : "eu-west-1c",
"AWS_ACCESS_KEY_ID" : "LAvD3tWm1V6M"
},
"git" : {
"git_clone_url" : "git@github.com:YordanGeorgiev/qto.git",
"private_key_file" : "~/.ssh/id_rsa.ysg"
},
"ENV_TYPE" : "lde"
}
}
6 changes: 3 additions & 3 deletions cnf/tpl/vagrant/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ ENV['VAGRANT_DEFAULT_PROVIDER'] = 'virtualbox'
Vagrant.configure("2") do |config|

# dev, tst and prd are separate vagrants
config.vm.define "%ENV_TYPE%-qto-vagrant" do |config|
config.vm.hostname = "%ENV_TYPE%-qto-vagrant"
config.vm.define "%ENV%-qto-vagrant" do |config|
config.vm.hostname = "%ENV%-qto-vagrant"

# use the latest ubuntu as a base
config.vm.box = "generic/ubuntu1804"
Expand Down Expand Up @@ -41,7 +41,7 @@ Vagrant.configure("2") do |config|
# go to the product instance dir
cd /home/vagrant/opt
source $(find . -name '.env') && cd qto/qto.$VERSION.$ENV_TYPE.$USER
source $(find . -name '.env') && cd qto/qto.$VERSION.$ENV.$USER
# ensure application layer consistency, run db ddl's and load data from s3
bash ./src/bash/qto/qto.sh -a check-perl-syntax -a scramble-confs
Expand Down
2 changes: 1 addition & 1 deletion dat/src/perl/qto/lib/Qto/Controller/Home.pm
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ sub doRenderPageTemplate {
, 'msg' => $msg
, 'db' => $db
, 'WsProtocol' => $config->{'env'}->{'app'}->{'ws_protocol'}
, 'EnvType' => $config->{'env'}->{'run'}->{'ENV_TYPE'}
, 'EnvType' => $config->{'env'}->{'run'}->{'ENV'}
, 'ProductVersion' => $config->{'env'}->{'run'}->{'VERSION'}
, 'GitShortHash' => $config->{'env'}->{'run'}->{'GitShortHash'}
, 'page_load_time' => $page_load_time
Expand Down
6 changes: 3 additions & 3 deletions doc/md/installations_doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ Check the main method in the run.sh and uncomment entities you do not want to in
The run of the following "shell actions" will create the QTO database and load it with a snapshot of it's data from an SQL dump stored in s3. If you start getting a lot of Perl "cannot not find module" syntax check error, you probably did not reload the bash shell, by typing "bash" and hitting Enter in the previous step.

# go to the product instance dir
source $(find . -name '.env') && cd qto/qto.$VERSION.$ENV_TYPE.$USER
source $(find . -name '.env') && cd qto/qto.$VERSION.$ENV.$USER

# ensure application layer consistency, run db ddl's and load data from s3
./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
Expand All @@ -218,7 +218,7 @@ The run of the following "shell actions" will create the QTO database and load i
Start the application layer by issuing the following command. The hypnotoad starting script ALWAYS checks whether or not you have public and private files for the JWT auth and if you do not have them if will create them basically only once. So hit Enter or type a password, when executing the action for the first time.

# ALWAYS run any shell-action from the product instance dir
cd ~/opt/qto/qto.$VERSION.$ENV_TYPE.$USER
cd ~/opt/qto/qto.$VERSION.$ENV.$USER

# start the web server
bash src/bash/qto/qto.sh -a mojo-hypnotoad-start
Expand Down Expand Up @@ -393,7 +393,7 @@ Copy paste the full command below - this is IMPORTANT !!!
The run of the following "shell actions" will create the QTO database and load it with a snapshot of its data from a SQL dump stored in s3.

# go to the product instance dir
source $(find . -name '.env') && cd qto/qto.$VERSION.$ENV_TYPE.$USER
source $(find . -name '.env') && cd qto/qto.$VERSION.$ENV.$USER

# ensure application layer consistency, run db ddl's and load data from s3
bash ./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
Expand Down
22 changes: 11 additions & 11 deletions doc/txt/qto/helps/dev/clone-to-app.help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,40 +11,40 @@ doCloneToApp(){
tgt_app=${tgt_app#$prefix}
tgt_environment_name=$(echo $environment_name | perl -ne "s/$run_unit/$tgt_app/g;print")
tgt_environment_name=$(echo $tgt_environment_name | perl -ne "s/$product_version/0.0.0/g;print")
tgt_environment_name=$(echo $tgt_environment_name | perl -ne "s/$env_type/dev/g;print")
tgt_environment_name=$(echo $tgt_environment_name | perl -ne "s/$ENV/dev/g;print")
tgt_product_dir=$product_base_dir/$tgt_app
tgt_PRODUCT_INSTANCE_DIR=$tgt_product_dir/$tgt_environment_name
mkdir -p $tgt_PRODUCT_INSTANCE_DIR
tgt_PRODUCT_DIR=$tgt_product_dir/$tgt_environment_name
mkdir -p $tgt_PRODUCT_DIR

# remove everything from the tgt product version dir - no extra files allowed !!!
rm -fvr $tgt_PRODUCT_INSTANCE_DIR
rm -fvr $tgt_PRODUCT_DIR
# if the removal failed exit with error msg
[[ $? -eq 0 ]] || doExit 2 "ERROR --- cannot write to $tgt_PRODUCT_INSTANCE_DIR !"
[[ $? -eq 0 ]] || doExit 2 "ERROR --- cannot write to $tgt_PRODUCT_DIR !"

doCreateRelativePackage
unzip -o $zip_file -d $tgt_PRODUCT_INSTANCE_DIR
unzip -o $zip_file -d $tgt_PRODUCT_DIR

to_srch=$run_unit
to_repl=$tgt_app

#-- search and replace in file names
find "$tgt_PRODUCT_INSTANCE_DIR/" -type d |\
find "$tgt_PRODUCT_DIR/" -type d |\
perl -nle '$o=$_;s#'"$to_srch"'#'"$to_repl"'#g;$n=$_;`mkdir -p $n` ;'
find "$tgt_PRODUCT_INSTANCE_DIR/" -type f |\
find "$tgt_PRODUCT_DIR/" -type f |\
perl -nle '$o=$_;s#'"$to_srch"'#'"$to_repl"'#g;$n=$_;rename($o,$n) unless -e $n ;'


find $tgt_PRODUCT_INSTANCE_DIR -exec file {} \; | grep text | cut -d: -f1| { while read -r file_to_edit ;
find $tgt_PRODUCT_DIR -exec file {} \; | grep text | cut -d: -f1| { while read -r file_to_edit ;
do (
perl -pi -e "s#$to_srch#$to_repl#g" "$file_to_edit"
);
done ;
}

# on cygwin the perl -pi leaves backup files => remove them
find $tgt_PRODUCT_INSTANCE_DIR -type f -name '*.bak' | xargs rm -fv
find $tgt_PRODUCT_DIR -type f -name '*.bak' | xargs rm -fv

cp -v $zip_file $tgt_PRODUCT_INSTANCE_DIR
cp -v $zip_file $tgt_PRODUCT_DIR

}
#eof func doCloneToApp
4 changes: 2 additions & 2 deletions doc/txt/qto/helps/dev/create-ctags.help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ doCreateCtags(){
ctags --help >/dev/null 2>&1 ||
{ doLog "ERROR. ctags is not installed or not in PATH. Aborting." >&2; exit 1; }
pushd .
cd $PRODUCT_INSTANCE_DIR
cd $PRODUCT_DIR

cmd="rm -fv ./tags" && doRunCmdAndLog "$cmd"
cmd="ctags -R -n --fields=+i+K+S+l+m+a ." && doRunCmdAndLog "$cmd"
cmd="ls -la $PRODUCT_INSTANCE_DIR/tags" && doRunCmdAndLog "$cmd"
cmd="ls -la $PRODUCT_DIR/tags" && doRunCmdAndLog "$cmd"

popd
}
Expand Down
6 changes: 3 additions & 3 deletions doc/txt/qto/helps/pckg/create-relative-package.help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
# Purpose:
# ------------------------------------------------------
creates a zip file with all the files specified in the
met/.<<env_type>>.qto with their relative file paths so that
met/.<<ENV>>.qto with their relative file paths so that
the user could deploy the product by :
mkdir -p <<target_PRODUCT_INSTANCE_DIR>>
unzip -o <<zip_file>> -d <<target_PRODUCT_INSTANCE_DIR>>
mkdir -p <<target_PRODUCT_DIR>>
unzip -o <<zip_file>> -d <<target_PRODUCT_DIR>>

# Prerequisites
# ------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions doc/txt/qto/helps/pckg/remove-package.help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ doRemovePackage(){

#remove the dirs as well
for dir in `cat "$include_file"`; do (
dir="$PRODUCT_INSTANCE_DIR/$dir"
dir="$PRODUCT_DIR/$dir"
test -d "$dir" && cmd="rm -fRv $dir" && doRunCmdAndLog "$cmd"
);
done

cmd="rm -fv $include_file" && \
doRunCmdAndLog "$cmd"
echo "rm -fvr $PRODUCT_INSTANCE_DIR">>"$product_dir/remove-""$environment_name".sh
echo "rm -fvr $PRODUCT_DIR">>"$product_dir/remove-""$environment_name".sh
echo "rm -fv $product_dir/remove-""$environment_name".sh>>"$product_dir/remove-""$environment_name".sh
nohup bash "$product_dir/remove-""$environment_name".sh &
}
Expand Down
30 changes: 0 additions & 30 deletions lib/bash/funcs/export-json-section-vars.sh

This file was deleted.

4 changes: 2 additions & 2 deletions lib/bash/funcs/flush-screen.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#------------------------------------------------------------------------------
# usage example:
# source $PRODUCT_INSTANCE_DIR/lib/bash/funcs/flush-screen.sh
# source $PRODUCT_DIR/lib/bash/funcs/flush-screen.sh
# do_flush_screen
#
# if you have sourced $PRODUCT_INSTANCE_DIR/lib/bash/funcs/export-json-section-vars.sh before,
# if you have sourced $PRODUCT_DIR/lib/bash/funcs/export-json-section-vars.sh before,
# then this function is also imported, so sourcing again is not necessary
#------------------------------------------------------------------------------
do_flush_screen(){
Expand Down
4 changes: 2 additions & 2 deletions lib/bash/funcs/parse-cnf-env-vars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ doParseCnfEnvVars(){
test -z "$cnf_file" && echo " you should set the cnf_file !!!"

cnf_dir=$(perl -e 'use File::Basename; use Cwd "abs_path"; print dirname(abs_path(@ARGV[0]));' -- "$cnf_file")
PRODUCT_INSTANCE_DIR=${cnf_dir%/*}
PRODUCT_DIR=${cnf_dir%/*}

INI_SECTION=MainSection

Expand All @@ -24,7 +24,7 @@ doParseCnfEnvVars(){
-e 's/#.*$//' \
-e 's/[[:space:]]*$//' \
-e 's/^[[:space:]]*//' \
-e "s|%ProductInstanceDir%|${PRODUCT_INSTANCE_DIR}|" \
-e "s|%ProductInstanceDir%|${PRODUCT_DIR}|" \
-e "s/^\(.*\)=\([^\"']*\)$/export \1=\"\2\"/" \
< $cnf_file \
| sed -n -e "/^\[$INI_SECTION\]/,/^\s*\[/{/^[^#].*\=.*/p;}"`
Expand Down
11 changes: 0 additions & 11 deletions lib/make/start-container.func.mk

This file was deleted.

5 changes: 0 additions & 5 deletions lib/make/stop-container.func.mk

This file was deleted.

15 changes: 15 additions & 0 deletions lib/make/uninstall-img.func.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# # usage: include it in your Makefile
# include <<file-path>>
#
# # function usage example:
#
# uninstall-csitea-web:
# $(call uninstall-img,csitea-web,80)


define uninstall-img
@clear
-@docker container stop $$(docker ps -aqf "name=${product}-${1}-con") 2> /dev/null
-@docker container rm $$(docker ps -aqf "name=${product}-${1}-con") 2> /dev/null
endef

Loading

0 comments on commit 803d347

Please sign in to comment.