-
Notifications
You must be signed in to change notification settings - Fork 149
/
postinstall
executable file
·65 lines (47 loc) · 2.2 KB
/
postinstall
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
#!/bin/sh
# =============================================================================
# Post-install hook file for configuring dotcloud server
echo "Writing the local settings file..."
echo " - Setting the path to the Shareabouts config"
echo " - Adding the flavor to the installed applications"
cat >> src/project/local_settings.py <<EOF
import json
import os.path
with open('/home/dotcloud/environment.json') as f:
env = json.load(f)
# The SHAREABOUTS_FLAVOR environment variable is used as a prefix for the
# Shareabouts configuration. configuration is expected to live in a package
# named 'flavors.<SHAREABOUTS_FLAVOR>'. This package will correspond to a
# folder in the root of the src tree that contains all the configuration
# information for the flavor.
SHAREABOUTS_FLAVOR = env.get('SHAREABOUTS_FLAVOR')
INSTALLED_APPS = ('flavors.' + SHAREABOUTS_FLAVOR,) + INSTALLED_APPS
SHAREABOUTS_CONFIG = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'flavors', SHAREABOUTS_FLAVOR))
STATIC_ROOT = '/home/dotcloud/current/static/'
# Debug is False by default, true if set in the environment.
DEBUG = (env.get('DEBUG', 'False') in ['true', 'True'])
TEMPLATE_DEBUG = DEBUG
EOF
echo "Injecting the Shareabouts API access info into the config file at $SHAREABOUTS_FLAVOR"
python -c "
import json
with open('/home/dotcloud/environment.json') as f:
env = json.load(f)
print
print 'dataset_api_key: ' + env.get('SHAREABOUTS_API_KEY')
print 'api_root: ' + env.get('SHAREABOUTS_API_ROOT', 'SHAREABOUTS_API_ROOT-not-set-in-dotcloud-environment!!!')
print 'analytics_key: ' + env.get('SHAREABOUTS_ANALYTICS_KEY', 'SHAREABOUTS_ANALYTICS_KEY-not-set-in-dotcloud-environment!!!')
print 'feedback_key: ' + env.get('SHAREABOUTS_FEEDBACK_KEY', 'SHAREABOUTS_FEEDBACK_KEY-not-set-in-dotcloud-environment!!!')
" | cat >> src/flavors/$SHAREABOUTS_FLAVOR/config.yml
echo "Syncing the database..."
src/manage.py syncdb --migrate --noinput
echo "Setting up static file service..."
src/manage.py collectstatic --noinput
echo "Configuring nginx to serve static files..."
cat >> nginx.conf <<EOF
location /static/ { root /home/dotcloud/current ; }
EOF
echo "Compiling translations..."
cd src/sa_web
../manage.py compilemessages
cd ../..