-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild.sh
More file actions
109 lines (92 loc) · 2.54 KB
/
build.sh
File metadata and controls
109 lines (92 loc) · 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/bin/bash
# Copyright 2020 ASL19 Organization
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Project config
PROJECT_ROOT=`pwd`
DIST_DIR_NAME="dist"
DEPLOY_DIR_NAME="deploy"
LAMBDA_CODE_FILE=lambda.zip
build() {
echo "---------------------------"
echo "Building deployment package"
echo "---------------------------"
echo ""
if [ ! -d deploy ]; then
mkdir deploy
fi
if [ ! -d ${DIST_DIR_NAME} ]; then
mkdir ${DIST_DIR_NAME}
fi
dist_path=${PROJECT_ROOT}/${DIST_DIR_NAME}
echo "Cleaning up dist and deploy directory ..."
rm -rf ${dist_path}/*
rm -rf ${PROJECT_ROOT}/${DEPLOY_DIR_NAME}/*
echo "Copying project files ..."
cp -rf ${PROJECT_ROOT}/src/${SCRIPT_DIR_NAME}/* ${dist_path}
echo "Copying common files ..."
cp -rf ${PROJECT_ROOT}/src/common/* ${dist_path}
echo "Creating settings.py file"
envsubst "$(env | cut -d= -f1 | sed -e 's/^/$/')" < ${dist_path}/settings-sample.py > "${dist_path}/settings.py"
echo "Adding pip libs ..."
pip install -r requirements.txt -t ${dist_path}/
echo "Adding google directory ..."
mkdir ${dist_path}/google
touch ${dist_path}/google/__init__.py
cd ${dist_path}
zip -r ${PROJECT_ROOT}/${DEPLOY_DIR_NAME}/${LAMBDA_CODE_FILE} *
ls -la ${PROJECT_ROOT}/${DEPLOY_DIR_NAME}/
echo ${PROJECT_ROOT}/${DEPLOY_DIR_NAME}/${LAMBDA_CODE_FILE}
cd ${PROJECT_ROOT}
}
options() {
echo "------------"
echo "Script Usage"
echo "------------"
echo ""
echo "Options:"
echo ""
echo "-e | --email : Build email responder code"
echo "-t | --telegram : Build telegram bot code"
echo ""
}
echo "---------------------------------------"
echo "Build Script"
echo "---------------------------------------"
echo ""
if [ $# -eq 0 ]
then
options
exit 1
else
key="$1"
case $key in
-t|--telegram)
source ./env_telegram.sh
SCRIPT_DIR_NAME="telegram"
build
exit 0
;;
-e|--email)
source ./env_email.sh
SCRIPT_DIR_NAME="email"
build
exit 0
;;
*)
# unknown option
options
exit 1
;;
esac
fi