This repository has been archived by the owner on Jan 31, 2025. It is now read-only.
forked from ukwa/ukwa-services
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy-airflow.sh
executable file
·64 lines (54 loc) · 2 KB
/
deploy-airflow.sh
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
#!/usr/bin/env bash
set -euxo pipefail
# read script environ argument, check, and read envars
CONTEXT_ENV_FILE=$1
if ! [[ -f ${CONTEXT_ENV_FILE} ]]; then
echo "ERROR: Script $0 argument [${CONTEXT_ENV_FILE}] missing"
exit
fi
set -a # automatically export all variables
source ${CONTEXT_ENV_FILE}
set +a
if ! [[ ${DEPLOYMENT_CONTEXT} =~ DEV|BETA|PROD|INGEST ]]; then
echo "ERROR: Script $0 DEPLOYMENT_CONTEXT envar not (DEV|BETA|PROD|INGEST)"
exit
fi
#if [[ ${ENVIRON} == 'dev' ]]; then
# export CONTEXT_ENV_FILE=/mnt/nfs/config/gitlab/ukwa-services-env/dev.env
# # Additional config for this enviroment (purple like ACT but made paler so it's usable):
# export AIRFLOW__WEBSERVER__NAVBAR_COLOR="#ff80ff"
# # BETA
# #export AIRFLOW__WEBSERVER__NAVBAR_COLOR="darkred"
#elif [[ ${ENVIRON} == 'ingest' ]]; then
# export CONTEXT_ENV_FILE=/root/gitlab/ukwa-services-env/ingest.env
# export AIRFLOW__WEBSERVER__INSTANCE_NAME="Airflow (Production/Ingest)"
#else
# export PUSH_GATEWAY=monitor.wa.bl.uk:9091
# echo "ERROR - not yet configured!"
# exit
#fi
# Storage:
echo Setup ${STORAGE_PATH} ...
# Storage locations for Airflow itself:
mkdir -p ${STORAGE_PATH}/airflow/logs
mkdir -p ${STORAGE_PATH}/airflow/postgres
# Storage location for data exported from e.g. W3ACT, like access lists used for playback
mkdir -p ${STORAGE_PATH}/hadoop_lsr
mkdir -p ${STORAGE_PATH}/data_exports
echo "Directory ${STORAGE_PATH}/hadoop_lsr should be owned by user 1000"
echo "Directory ${STORAGE_PATH} (recursive) should be in group airflow"
# Clone the Git repo used to store access-control lists
GIT_URL=http://git.wa.bl.uk/bl-services/wayback_excludes_update.git
FOLDER=${STORAGE_PATH}/wayback_acls
if [ ! -d "$FOLDER" ] ; then
git clone $GIT_URL $FOLDER
else
cd "$FOLDER"
git pull $GIT_URL
cd -
fi
# And make sure the ownership is right:
echo "Please chown $FOLDER so it's owned by the access user, e.g."
echo "sudo chown -R access:access $FOLDER"
# deploy container
docker stack deploy -c docker-compose.yaml airflow