Skip to content
This repository was archived by the owner on May 23, 2023. It is now read-only.

Commit 8134da6

Browse files
Ajustes gerais de scripts da pasta root
1 parent 043f0c0 commit 8134da6

File tree

5 files changed

+162
-22
lines changed

5 files changed

+162
-22
lines changed

scripts/boot-lambdas.sh

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,51 @@
1-
# a api não precisa ser bootada
2-
#./examples/lambda_api/scripts/boot.sh
3-
./examples/lambda_sqs/scripts/boot.sh
1+
# -----------------------------------------------------------------------------
2+
# Current file variables
3+
# -----------------------------------------------------------------------------
4+
debug=false
5+
parent_folder="../"
6+
current_path=$(pwd)
7+
current_path_basename=$(basename $(pwd))
8+
current_file_full_path=$0
9+
# echo $current_filepath
10+
current_file_name=$(basename -- "$0")
11+
echo $current_file_full_path
12+
echo $current_file_name
13+
if [ $current_file_full_path = $current_file_name ] || [ $current_file_full_path = "./$current_file_name" ]; then
14+
current_file_full_path="./${current_file_full_path}"
15+
current_file_path="./"
16+
else
17+
current_file_path="${current_file_full_path/$current_file_name/''}"
18+
fi
19+
if [ debug ]; then
20+
echo '----------------------------------------'
21+
echo "$0 - Script variables"
22+
echo '----------------------------------------'
23+
echo "current_path: $current_path"
24+
echo "current_path_basename: $current_path_basename"
25+
echo "current_file_full_path: $current_file_full_path"
26+
echo "current_file_name: $current_file_name"
27+
echo "current_file_path: $current_file_path"
28+
echo '----------------------------------------'
29+
fi
30+
31+
32+
## variables
33+
echo '----------------------------------------'
34+
echo "$0 - Sourcing file: ${current_file_path}variables.sh"
35+
echo '----------------------------------------'
36+
source ${current_file_path}variables.sh
37+
38+
## now loop through the above array
39+
for example_path in "${arr[@]}"
40+
do
41+
echo "Booting ${example_path} ..."
42+
if test -f "${parent_folder}${example_path}scripts/boot.sh"; then
43+
${parent_folder}${example_path}scripts/boot.sh
44+
elif test -f "${example_path}scripts/boot.sh"; then
45+
${example_path}scripts/boot.sh
46+
else
47+
echo 'There is no boot file'
48+
fi
49+
done
50+
51+
# You can access them using echo "${arr[0]}", "${arr[1]}" also

scripts/boot.sh

Lines changed: 81 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,84 @@
11
#!/bin/bash
2-
echo 'Validating jd installation..'
3-
/usr/bin/jq --help > /dev/null 2>&1
4-
if [ $? -ne 0 ]; then
5-
echo 'Installing'
6-
# download directly into ~/bin_compciv
7-
sudo curl http://stedolan.github.io/jq/download/linux64/jq -o /usr/bin/jq
8-
# give it executable permissions
9-
sudo chmod a+x /usr/bin/jq
10-
fi
2+
# -----------------------------------------------------------------------------
3+
# Current file variables
4+
# -----------------------------------------------------------------------------
5+
debug=false
6+
parent_folder="../"
7+
current_path=$(pwd)
8+
current_path_basename=$(basename $(pwd))
9+
current_file_full_path=$0
10+
# echo $current_filepath
11+
current_file_name=$(basename -- "$0")
12+
# echo $current_filename
13+
if [ $current_file_full_path = $current_file_name ] || [ $current_file_full_path = "./$current_file_name" ]; then
14+
current_file_full_path="./${current_file_full_path}"
15+
current_file_path="./"
16+
else
17+
current_file_path="${current_file_full_path/$current_file_name/''}"
18+
fi
19+
if [ debug ]; then
20+
echo '----------------------------------------'
21+
echo "$0 - Script variables"
22+
echo '----------------------------------------'
23+
echo "current_path: $current_path"
24+
echo "current_path_basename: $current_path_basename"
25+
echo "current_file_full_path: $current_file_full_path"
26+
echo "current_file_name: $current_file_name"
27+
echo "current_file_path: $current_file_path"
28+
echo '----------------------------------------'
29+
fi
1130

12-
echo 'Validate connection'
13-
./scripts/boot-validate-connection.sh
31+
echo '----------------------------------------'
32+
echo "$0 - jq check"
33+
echo '----------------------------------------'
34+
echo 'Validating jq installation...'
35+
/usr/bin/jq --version > /dev/null 2>&1
36+
if [ $? -ne 0 ]; then
37+
echo 'Installing jq...'
38+
# download directly into ~/bin_compciv
39+
sudo curl http://stedolan.github.io/jq/download/linux64/jq -o /usr/bin/jq
40+
# give it executable permissions
41+
sudo chmod a+x /usr/bin/jq
42+
else
43+
echo 'jq installed...'
44+
fi
1445

15-
echo 'Create the lambdas...'
16-
./scripts/boot-lambdas.sh
46+
47+
echo '----------------------------------------'
48+
echo "$0 - Localstack connection check"
49+
echo '----------------------------------------'
50+
# valida se o Localstack está rodando
51+
if test -f ${current_file_path}boot-validate-connection.sh; then
52+
echo 'Validate connection...'
53+
${current_file_path}boot-validate-connection.sh
54+
else
55+
echo 'There is no connection check'
56+
fi
57+
58+
59+
echo '----------------------------------------'
60+
echo "$0 - Database boot"
61+
echo '----------------------------------------'
62+
if test -f ${current_file_path}boot-db.sh; then
63+
${current_file_path}boot-db.sh
64+
else
65+
echo 'There is no database to be booted'
66+
fi
67+
68+
echo '----------------------------------------'
69+
echo "$0 - Queues boot"
70+
echo '----------------------------------------'
71+
if test -f ${current_file_path}boot-queues.sh; then
72+
${current_file_path}boot-queues.sh
73+
else
74+
echo 'There is no queues to be booted'
75+
fi
76+
77+
echo '----------------------------------------'
78+
echo "$0 - Lambdas boot"
79+
echo '----------------------------------------'
80+
if test -f ${current_file_path}boot-lambdas.sh; then
81+
${current_file_path}boot-lambdas.sh
82+
else
83+
echo 'There is no lambdas to be booted'
84+
fi

scripts/install.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22

3-
# declare an array variable
4-
declare -a arr=("./examples/lambda_api/" "./examples/lambda_cron/" "./examples/lambda_s3/" "./examples/lambda_sns/" "./examples/lambda_sqs/")
3+
## variables
4+
source ${current_filename_path}scripts/variables.sh
55

66
## now loop through the above array
77
for example_path in "${arr[@]}"

scripts/variables.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
# declare an array variable
3+
declare -a arr=("./examples/lambda_api/" "./examples/lambda_cron/" "./examples/lambda_s3/" "./examples/lambda_sns/" "./examples/lambda_sqs/")

scripts/venv.sh

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,28 @@
11
#!/bin/bash
2-
python3 -m venv venv
3-
source ./venv/bin/activate
2+
current_path=$(basename $(pwd))
3+
current_filename=$(basename -- "$0")
4+
current_filename_path=$0
5+
# echo $current_filename_path
6+
current_filename_path="${current_filename_path/$current_filename/''}"
7+
# echo $current_filename_path
8+
current_filename_path="${current_filename_path/scripts\//''}"
9+
# echo $current_filename_path
10+
current_filename_path_basename=$(basename -- "$current_filename_path")
411

5-
if test -f "./scripts/install.sh"; then
6-
bash ./scripts/install.sh
12+
echo "current_path: $current_path"
13+
echo "current_filename: $current_filename"
14+
echo "current_filename_path: $current_filename_path"
15+
echo "current_filename_path_basename: $current_filename_path_basename"
16+
17+
18+
if test -f "${current_filename_path}venv/bin/activate"; then
19+
python3 -m venv venv
20+
source ${current_filename_path}venv/bin/activate
21+
else
22+
echo "Unable to find ${current_filename_path}venv/bin/activate"
23+
exit 1
24+
fi
25+
26+
if test -f "${current_filename_path}scripts/install.sh"; then
27+
bash ${current_filename_path}scripts/install.sh
728
fi

0 commit comments

Comments
 (0)