-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathinstall-web2py.sh
executable file
·51 lines (40 loc) · 1.78 KB
/
install-web2py.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
#!/bin/bash
# ---------- WEB2PY ----------
# Install or upgrade web2py, based on a pinned release. (See
# https://github.com/web2py/web2py/releases for all available releases.)
WEB2PY_RELEASE='2.8.2'
# N.B. We should only change WEB2PY_RELEASE after updating the modified web2py files
# listed in the section 'ROUTES AND WEB2PY PATCHES' below, and thorough testing!
mkdir -p downloads
if [ ! -d web2py -o ! -r downloads/web2py_${WEB2PY_RELEASE}_src.zip ]; then
wget --no-verbose -O downloads/web2py_${WEB2PY_RELEASE}_src.zip \
https://github.com/web2py/web2py/archive/R-${WEB2PY_RELEASE}.zip
# clobber any existing web2py installation
rm -rf ./web2py
unzip -q downloads/web2py_${WEB2PY_RELEASE}_src.zip
# rename to expected 'web2py'
mv web2py-R-${WEB2PY_RELEASE}/ web2py
log "Installed web2py R-${WEB2PY_RELEASE}"
# clear old sessions in all web2py applications (these can cause heisenbugs in web2py upgrades)
rm -rf repo/opentree/*/sessions/*
rm -rf repo/phylesystem-api/sessions/*
log "Cleared old sessions in all web2py apps"
fi
# ---------- VIRTUALENV + WEB2PY + WSGI ----------
# Patch web2py's wsgihandler so that it does the equivalent of 'venv/activate'
# when started by Apache.
# See http://stackoverflow.com/questions/11758147/web2py-in-apache-mod-wsgi-with-virtualenv
# Indentation (or lack thereof) is critical
cat <<EOF >fragment.tmp
activate_this = '$PWD/venv/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))
import sys
sys.path.insert(0, '$PWD/web2py')
EOF
# This is pretty darn fragile! But if it fails, it will fail big -
# the web apps won't work at all.
(head -2 web2py/handlers/wsgihandler.py && \
cat fragment.tmp && \
tail -n +3 web2py/handlers/wsgihandler.py) \
> web2py/wsgihandler.py
rm fragment.tmp