forked from openplans/shareabouts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
postinstall
executable file
·108 lines (92 loc) · 3.26 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/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"
echo " - Setting the dataset access location and key"
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', 'SHAREABOUTS_FLAVOR-not-set-in-dotcloud-environment!!!'),
'DATASET_KEY': env.get('SHAREABOUTS_DATASET_KEY', 'SHAREABOUTS_DATASET_KEY-not-set-in-dotcloud-environment!!!'),
'DATASET_ROOT': env.get('SHAREABOUTS_DATASET_ROOT', 'SHAREABOUTS_DATASET_ROOT-not-set-in-dotcloud-environment!!!'),
'CONTEXT': {
'analytics_key': env.get('SHAREABOUTS_ANALYTICS_KEY', 'SHAREABOUTS_ANALYTICS_KEY-not-set-in-dotcloud-environment!!!'),
'feedback_key': env.get('SHAREABOUTS_FEEDBACK_KEY', 'SHAREABOUTS_FEEDBACK_KEY-not-set-in-dotcloud-environment!!!'),
}
}
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
ALLOWED_HOSTS = ['*']
admin_email = env.get('SHAREABOUTS_ADMIN_EMAIL')
if admin_email:
projname = env.get('DOTCLOUD_PROJECT')
username = env.get('DOTCLOUD_USERNAME')
ADMINS = (
('Shareabouts - %s:%s' % (projname, username), admin_email),
)
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
'formatters': {
'verbose': {
'format': '%(levelname)s %(asctime)s %(name)s: %(message)s %(process)d %(thread)d'
},
'moderate': {
'format': '%(levelname)s %(asctime)s %(name)s: %(message)s'
},
'simple': {
'format': '%(levelname)s %(message)s'
},
},
'handlers': {
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler'
},
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
}
}
EOF
echo "Setting up static file service..."
python src/manage.py collectstatic --noinput
echo "Configuring nginx to serve static files..."
cat >> nginx.conf <<EOF
location /static/ {
root /home/dotcloud/current ;
expires max;
}
gzip on;
gzip_types
text/plain text/html text/css text/csv
application/json application/javascript;
EOF
echo "Compiling translations..."
cd src/sa_web
python ../manage.py compilemessages
cd ../flavors/$SHAREABOUTS_FLAVOR
python ../../manage.py compilemessages
cd ../../..