This repository was archived by the owner on May 28, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy path_init.sh
More file actions
executable file
·110 lines (90 loc) · 2.95 KB
/
_init.sh
File metadata and controls
executable file
·110 lines (90 loc) · 2.95 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
110
#!/usr/bin/env bash
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.
# cd, install from source, and setup postgres
# Make sure all environment variables created below are exported
# even if they are not explicitly exported (just in case)
. /usr/share/virtualenvwrapper/virtualenvwrapper.sh
MY_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
set -euo pipefail
# Automatically export all variables
set -a
# Airflow requires this variable be set during installation to avoid a GPL
# dependency.
export SLUGIFY_USES_TEXT_UNIDECODE=yes
GCP_CONFIG_DIR="${HOME}/config"
if [[ -f ${GCP_CONFIG_DIR}/variables.env ]]; then
echo "Sourcing variables from ${GCP_CONFIG_DIR}/variables.env"
set -x
source ${GCP_CONFIG_DIR}/variables.env
set +x
fi
PYTHON_VERSION=${PYTHON_VERSION:=2.7}
if [[ "${PYTHON_VERSION}" = "2.7" ]]; then
echo "Python 2.7 used"
echo
set +ue
workon airflow27
set -ue
elif [[ "${PYTHON_VERSION}" = "3.5" ]]; then
echo
echo "Python 3.5 used"
echo
set +ue
workon airflow35
set -ue
else
echo
echo "Python 3.6 used"
echo
set +ue
workon airflow36
set -ue
fi
cd /workspace
pip install -e .[devel_ci] \
&& sudo service postgresql start \
&& sudo -u postgres createuser root \
&& sudo -u postgres psql --command "ALTER USER root WITH PASSWORD 'airflow';" \
&& sudo -u postgres createdb airflow/airflow.db
export GCP_SERVICE_ACCOUNT_KEY_NAME=${GCP_SERVICE_ACCOUNT_KEY_NAME:=""}
alias set_gcp_key=". /airflow/_setup_gcp_key.sh"
. ${MY_DIR}/_setup_gcp_key.sh "${GCP_SERVICE_ACCOUNT_KEY_NAME}"
export AIRFLOW_HOME=${AIRFLOW_HOME:=/airflow}
export GCP_CONFIG_DIR=${GCP_CONFIG_DIR:=${HOME}/onfig}
export GCP_SERVICE_ACCOUNT_KEY_DIR=${GCP_CONFIG_DIR}/keys
export AIRFLOW_SOURCES="${AIRFLOW_SOURCES:=/workspace}"
# Enable local executor
export AIRFLOW_CONFIG=${AIRFLOW_SOURCES}/tests/contrib/operators/postgres_local_executor.cfg
# Source all environment variables from key dir
for ENV_FILE in ${GCP_SERVICE_ACCOUNT_KEY_DIR}/*.env
do
if [[ -f ${ENV_FILE} ]]; then
source ${ENV_FILE}
echo
cat ${ENV_FILE}
echo
fi
done
if [[ -f ${AIRFLOW_SOURCES}/decrypted_variables.env ]]; then
set -x
source ${AIRFLOW_SOURCES}/decrypted_variables.env
set +x
fi
set +a
eval "${@}"