-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap.sh
executable file
·114 lines (93 loc) · 2.66 KB
/
bootstrap.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
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
109
110
111
112
113
114
#!/bin/bash
export DEBIAN_FRONTEND=noninteractive
apt-get update
# Don't apt-get upgrade http://stackoverflow.com/a/15093460/589391
apt-get install -y gunicorn nginx postgresql python-dateutil \
python-feedparser python-psycopg2
echo 'Installing Django...'
cd /tmp
wget -nv https://www.djangoproject.com/m/releases/1.4/Django-1.4.10.tar.gz
tar xzf Django-1.4.10.tar.gz
cd Django-1.4.10
python setup.py -q install
cd ..
rm -rf Django-1.4.10*
echo 'Configuring nginx...'
cat > /etc/nginx/sites-available/mess << 'EOF'
server {
listen 80;
client_max_body_size 10m;
client_body_buffer_size 128k;
keepalive_timeout 1000;
location /media {
alias /vagrant/mess/media;
}
location / {
# an HTTP header important enough to have its own Wikipedia entry:
# http://en.wikipedia.org/wiki/X-Forwarded-For
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# pass the Host: header from the client right along so redirects
# can be set properly within the Rack application
proxy_set_header Host $host;
# we don't want nginx trying to do something clever with
# redirects, we set the Host: header above already.
proxy_redirect off;
proxy_pass http://127.0.0.1:8000;
}
}
EOF
ln -s /etc/nginx/sites-available/mess /etc/nginx/sites-enabled/mess
/etc/init.d/nginx restart
echo 'Configuring gunicorn...'
cat > /etc/gunicorn.d/mess << 'EOF'
CONFIG = {
'mode': 'django',
'working_dir': '/vagrant/mess/',
'user': 'www-data',
'group': 'www-data',
'args': (
'--bind=127.0.0.1:8000',
'--worker-class=egg:gunicorn#sync',
'--timeout=1000',
# For dev. See http://stackoverflow.com/questions/12773763/gunicorn-autoreload-on-source-change
'--max-requests=1',
'--workers=1',
),
}
EOF
/etc/init.d/gunicorn restart
echo 'Creating MESS DB...'
sudo -u postgres psql <<EOF
CREATE USER mess with password 'mess';
EOF
sudo -u postgres createdb -O mess mess
echo 'Writing local settings for MESS...'
cat > /vagrant/mess/settings_local.py << 'EOF'
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (
('Dev', 'dev@localhost'),
)
MANAGERS = ADMINS
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'mess',
'USER': 'mess',
'PASSWORD': 'mess',
'HOST': 'localhost',
'PORT': '',
}
}
SECRET_KEY = 'secret'
DEFAULT_FROM_EMAIL = 'do-not-reply@localhost'
SERVER_EMAIL = 'hq@localhost'
MARIPOSA_IPS = ('192.168.48.24')
GOTOPHPBB_SECRET='phpbbsecret'
GOTOIS4C_SECRET='is4secret'
IS4C_SECRET='is4secret'
EOF
cd /vagrant/mess
python manage.py syncdb --noinput
echo 'MESS box provisioned!'
echo 'Visit The MESS at http://127.0.0.1:8080'