-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathentrypoint.sh
executable file
·55 lines (49 loc) · 1.78 KB
/
entrypoint.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
#!/bin/bash
# users can overwrite UWSGI_OPTIONS
if [ "$UWSGI_OPTIONS" == '' ]; then
UWSGI_OPTIONS='--master --thunder-lock --enable-threads'
fi
selectVersion() {
if [ "$WEB2PY_VERSION" != '' ]; then
git checkout $WEB2PY_VERSION
fi
}
# Run uWSGI using the uwsgi protocol
if [ "$1" = 'uwsgi' ]; then
# switch to a particular Web2py version if specificed
selectVersion
# add an admin password if specified
if [ "$WEB2PY_PASSWORD" != '' ]; then
python -c "from gluon.main import save_password; save_password('$WEB2PY_PASSWORD',443)"
fi
# run uwsgi
exec uwsgi --socket 0.0.0.0:9090 --protocol uwsgi --wsgi wsgihandler:application $UWSGI_OPTIONS
fi
# Run uWSGI using http
if [ "$1" = 'http' ]; then
# switch to a particular Web2py version if specificed
selectVersion
# disable administrator HTTP protection if requested
if [ "$WEB2PY_ADMIN_SECURITY_BYPASS" = 'true' ]; then
if [ "$WEB2PY_PASSWORD" == '' ]; then
echo "ERROR - WEB2PY_PASSWORD not specified"
exit 1
fi
echo "WARNING! - Admin Application Security over HTTP bypassed"
python -c "from gluon.main import save_password; save_password('$WEB2PY_PASSWORD',8080)"
sed -i "s/elif not request.is_local and not DEMO_MODE:/elif False:/" \
$WEB2PY_ROOT/applications/admin/models/access.py
sed -i "s/is_local=(env.remote_addr in local_hosts and client == env.remote_addr)/is_local=True/" \
$WEB2PY_ROOT/gluon/main.py
fi
# run uwsgi
exec uwsgi --http 0.0.0.0:8080 --wsgi wsgihandler:application $UWSGI_OPTIONS
fi
# Run using the builtin Rocket web server
if [ "$1" = 'rocket' ]; then
# switch to a particular Web2py version if specificed
selectVersion
# Use the -a switch to specify the password
exec python web2py.py -a '$WEB2PY_PASSWORD' -i 0.0.0.0 -p 8080
fi
exec "$@"