1 | #!/usr/bin/python |
---|
2 | |
---|
3 | #----------------------------------------------------------------------------- |
---|
4 | # create local settings file |
---|
5 | |
---|
6 | import os |
---|
7 | |
---|
8 | if not os.path.exists('settings_local.py'): |
---|
9 | from random import choice |
---|
10 | secret = ''.join([ |
---|
11 | choice('abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)') |
---|
12 | for i in range(50) |
---|
13 | ]) |
---|
14 | print "Creating local settings file (settings_local.py)" |
---|
15 | old_umask = os.umask(0077) |
---|
16 | local_settings = open('settings_local.py', 'w') |
---|
17 | local_settings.write("\n".join([ |
---|
18 | "#!/usr/bin/python", |
---|
19 | "#", |
---|
20 | "# DashWiki local configuration", |
---|
21 | "#", |
---|
22 | "", |
---|
23 | "from dashwiki.settings import DASHWIKI_ROOT_DIR", |
---|
24 | "", |
---|
25 | "SECRET_KEY = '%s'" % secret, |
---|
26 | "#DASHWIKI_LOGGING_CONFIG = '%s/logging.yaml' % (DASHWIKI_ROOT_DIR)", |
---|
27 | "#DASHWIKI_CACHE_ROOT = '%s/cache' % (DASHWIKI_ROOT_DIR)", |
---|
28 | "#DATABASES = {", |
---|
29 | "# 'default': {", |
---|
30 | "# 'ENGINE': 'django.db.backends.sqlite3',", |
---|
31 | "# 'NAME': '%s/db/dashwiki.db' % (DASHWIKI_ROOT_DIR),", |
---|
32 | "# }", |
---|
33 | "#}", |
---|
34 | "", |
---|
35 | "# if you have DEBUG = False (the default), you need to set valid hostnames", |
---|
36 | "# for HTTP server running DashWiki (they say you don't want to set it to '*')", |
---|
37 | "#DEBUG = False", |
---|
38 | "#ALLOWED_HOSTS = ['localhost']", |
---|
39 | "", |
---|
40 | "# example of how to add path to one of the lists:", |
---|
41 | "#from dashwiki.settings import DASHWIKI_PLUGINS_DIR", |
---|
42 | "#DASHWIKI_PLUGINS_DIR += (", |
---|
43 | "# '%s/local/plugins' % DASHWIKI_ROOT_DIR,", |
---|
44 | "#)", |
---|
45 | "", |
---|
46 | "# vim:ft=python", |
---|
47 | "" |
---|
48 | ])) |
---|
49 | local_settings.close() |
---|
50 | os.umask(old_umask) |
---|
51 | |
---|
52 | #----------------------------------------------------------------------------- |
---|
53 | # deploy database |
---|
54 | |
---|
55 | import dashwiki.settings |
---|
56 | import django.core.management as mgmt |
---|
57 | |
---|
58 | mgmt.setup_environ(dashwiki.settings) |
---|
59 | mgmt.call_command('syncdb', interactive = False) |
---|
60 | |
---|
61 | #----------------------------------------------------------------------------- |
---|
62 | # fill the database with initial content |
---|
63 | |
---|
64 | from dashwiki.wiki.models import WikiPage |
---|
65 | WikiPage( |
---|
66 | 'WikiStart', |
---|
67 | '\n'.join([ |
---|
68 | '= DashWiki welcome page =', |
---|
69 | '', |
---|
70 | 'Edit this page.', |
---|
71 | '', |
---|
72 | 'Initial message will not show up in edit history.', |
---|
73 | '', |
---|
74 | ]) |
---|
75 | ).save() |
---|
76 | |
---|
77 | #----------------------------------------------------------------------------- |
---|
78 | # vim:ft=python:nowrap |
---|