-
Notifications
You must be signed in to change notification settings - Fork 0
/
dev_deploy.sh
73 lines (63 loc) · 2.88 KB
/
dev_deploy.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
65
66
67
68
69
70
71
72
73
# Dev Deployment Script
echo "Preventing calamity. Please wait while environment variables are verified..."
# ENSURE ENVIRONMENT VARIABLES EXIST, OTHERWISE CRASH # IT'S CRITICAL THIS EXISTS OTHERWISE THE DEPLOYING SERVER WILL GET NUKED!!
if [ -z "${CKAN_LOG_PATH}" ] ||\
[ -z "${CKAN_PORT}" ] ||\
[ -z "${CKAN_SITE_URL}" ] ||\
[ -z "${CKAN_TAG}" ] ||\
[ -z "${CKANEXTS_PATH}" ] ||\
[ -z "${DOCKER_EXTS_PATH}" ] ||\
[ -z "${DOCKER_VENV_PATH}" ] ||\
[ -z "${DOCKER_PATH}" ] ||\
[ -z "${EXT_NAME}" ]
then
echo "Required environment variables not set! Exiting to prevent catastrophic behavior!"
exit 1
fi
echo "CKAN_LOG_PATH: ${CKAN_LOG_PATH}"
echo "CKAN_PORT: ${CKAN_PORT}"
echo "CKAN_TAG: ${CKAN_TAG}"
echo "CKAN_SITE_URL: ${CKAN_SITE_URL}"
echo "CKANEXTS_PATH: ${CKANEXTS_PATH}"
echo "EXT_NAME: ${EXT_NAME}"
echo "DOCKER_PATH: ${DOCKER_PATH}"
echo "DOCKER_VENV_PATH: ${DOCKER_VENV_PATH}"
echo "DOCKER_EXTS_PATH: ${DOCKER_EXTS_PATH}"
# COPY PLUGIN FILES
echo "Cloned repo into ${AGENT_RELEASEDIRECTORY}/${RELEASE_PRIMARYARTIFACTSOURCEALIAS}/drop/"
echo "Repo contents:"
ls "${AGENT_RELEASEDIRECTORY}/${RELEASE_PRIMARYARTIFACTSOURCEALIAS}/drop/"
# If the extension folder does not exist create it.
if [ ! -d ${CKANEXTS_PATH}${EXT_NAME} ]
then
echo "Extension folder does not exist, creating it now."
sudo mkdir ${CKANEXTS_PATH}${EXT_NAME}
else
echo "Extension folder exists, clearing old contents in ${CKANEXTS_PATH}${EXT_NAME}"
sudo rm -r ${CKANEXTS_PATH}${EXT_NAME}
sudo mkdir ${CKANEXTS_PATH}${EXT_NAME}
fi
echo "Copying new files"
sudo cp -r "${AGENT_RELEASEDIRECTORY}/${RELEASE_PRIMARYARTIFACTSOURCEALIAS}/drop/"* ${CKANEXTS_PATH}${EXT_NAME}
sudo chmod 777 -R ${CKANEXTS_PATH}${EXT_NAME}
echo "Installing plugin into CKAN venv"
sudo docker exec ckan /bin/bash -c "source ${DOCKER_VENV_PATH} && \
cd ${DOCKER_EXTS_PATH}${EXT_NAME}/ && pip install -r requirements.txt"
sudo docker exec ckan /bin/bash -c "source ${DOCKER_VENV_PATH} && \
cd ${DOCKER_EXTS_PATH}${EXT_NAME}/ && python setup.py develop"
# SHUTDOWN CKAN
cd ${DOCKER_PATH}
sudo docker-compose down
# RESTART CKAN
cd ${DOCKER_PATH}
sudo docker-compose up -d
# SEED VITALITY AUTHORIZATION MODEL
echo "Seeding users into metadata authorization model"
sudo docker exec ckan /usr/local/bin/ckan-paster --plugin=${EXT_NAME} \
vitality seed --config=/etc/ckan/production.ini
# RE-INDEX DATASETS
echo "Re-indexing datasets..."
sudo docker exec ckan /usr/local/bin/ckan-paster --plugin=ckan search-index \
rebuild --config=/etc/ckan/production.ini
sudo docker exec ckan /usr/local/bin/ckan-paster --plugin=ckanext-harvest harvester \
reindex --config=/etc/ckan/production.ini