-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup
executable file
·101 lines (77 loc) · 3.2 KB
/
setup
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
#!/bin/bash
# Setup the environment for traxler development/deployment.
# $ . setup [--full]
# File/dir. --------------------------------------------------------------------
# The root of the entire traxler tree.
ROOT="$(while [ "$PWD" != '/' ]; do test -e .tx_root && pwd && break; cd ..; done)"
# Contains the static website files.
STATIC_DIR="$ROOT/source/static"
# Contains scripts for accessing/modifying/running the server and database.
TOOL_DIR="$ROOT/tool"
PRODUCTIVITY_DIR="$ROOT/tool/productivity"
# Path to python virtual environment.
VENV_DIR="$ROOT/.tx"
# Path to symlinks to put in path.
PATH_DIR="$ROOT/tool/path"
# File that stores the AWS profile to use for this project. Useful if you have
# more than one project on your computer you are developing under different
# profiles.
AWS_PROFILE_FILE="$ROOT/.AWS_PROFILE"
# AWS resources. ---------------------------------------------------------------
# Bucket used to store student images.
TX_S3_IMAGE_BUCKET="traxler-image-bucket"
# Bucket used to store the static web pages.
TX_S3_WEBSITE_BUCKET="traxler-website-bucket"
# Table used to store student data.
TX_DYNAMODB_STUDENT_TABLE="dynamo-traxler-student-table"
# Export. ----------------------------------------------------------------------
# Allow other scripts to access important project constants.
export ROOT STATIC_DIR TOOL_DIR PRODUCTIVITY_DIR RUNTIME_DIR
# Add some of our tools to PATH.
export PATH="$PATH_DIR:$PATH"
# Export the AWS resource names.
export TX_S3_IMAGE_BUCKET TX_S3_WEBSITE_BUCKET TX_DYNAMODB_STUDENT_TABLE
# Adding common python files to path.
export PYTHONPATH="$ROOT/source/common:$ROOT/source/dependency:$ROOT/source/function:${PYTHONPATH}"
# Setup. -----------------------------------------------------------------------
# Source all of the scripts in the include directory.
for script in $TOOL_DIR/include/*.sh; do
source $script;
done
# Welcome the new developer.
echo
echo_traxler
echo
# If no AWS_PROFILE_FILE exists, or if it's empty, ask the user and create one.
if [ ! -f "$AWS_PROFILE_FILE" -o ! -s "$AWS_PROFILE_FILE" ]; then
echo Which AWS profile would you like to use? Only necessary if you plan on
echo deploying.
echo If you are just developing, or wish to use the default profile, you can
echo just leave this blank.
read -p "[default]: " aws_profile
if [ -z "$aws_profile" ]; then
aws_profile="default"
fi
echo "$aws_profile" > $AWS_PROFILE_FILE
fi
# Set the default aws profile to use for all AWS services.
export AWS_PROFILE=`cat $AWS_PROFILE_FILE`
# If "--full" is supplied, create a new virtual environment and download listed
# packages. This is only necessary after pulling a new commit.
if [ "$1" = "--full" ]; then
# Leave the current virtual environment if we are in one.
if command -v deactivate > /dev/null; then
deactivate
fi
# Create and enter a new virtual environment.
echo Creating virtual environment...
python3 -m venv "$VENV_DIR"
source "$VENV_DIR/bin/activate"
# Install required python packages.
echo Installing packages...
pip install -qr "$ROOT/requirements.txt"
echo_green "All done!"
else
# Enter the virtual environment.
source "$VENV_DIR/bin/activate"
fi