forked from ModioAB/caramel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
post-deploy.sh
executable file
·43 lines (36 loc) · 1.24 KB
/
post-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
#! /bin/bash
## This script are tasks to be done on the server after initial deployment.
## This includes setting up local environments and virtualenvs
## This should only be called from "deploy-caramel.sh"
set -e
## get the paths
: ${PIP_DOWNLOAD_CACHE:=$HOME/pip-downloads}
export PIP_DOWNLOAD_CACHE
HERE="$(dirname "$(readlink -f "$0")")"
PROJECT="$1"
REV="$2"
venv=/opt/venv/"$PROJECT-$REV"
# Create new VirtualEnv
scl enable python33 "virtualenv-3.3 $venv"
/sbin/restorecon -vR "$venv"
# Virtual env population & install
scl enable python33 "bash -c \
'source \"${venv}/bin/activate\";\
'pip install -U pip';
'pip install -U setuptools';
cd \"${HERE}\"; python setup.py install;'"
/sbin/restorecon -vR "$venv"
echo "Setting permissions"
chmod -R go+rX "$HERE"
chmod -R go+rX "$venv"
# Permissions inside Virtual Env
chcon -t httpd_sys_content_t "${venv}/bin/activate"
## Set up venv inside web-root
cd "$HERE"/..
rm -f "$PROJECT".ini "$PROJECT"-venv
ln -s "$HERE"/production.ini "$PROJECT".ini
ln -s "$venv" "$PROJECT"-venv
chcon -t httpd_sys_content_t "$PROJECT".ini
# Below only works for root, do it manually.
echo "As root: chcon -t httpd_sys_content_rw_t caramel.sqlite"
# You probably want to do something to kill all old instances of caramel here below.