diff options
-rwxr-xr-x | buildtools/subst-vars.py | 28 | ||||
-rw-r--r-- | rpkid/Makefile.in | 10 | ||||
-rw-r--r-- | rpkid/portal-gui/Makefile.in | 6 | ||||
-rw-r--r-- | rpkid/portal-gui/settings.py.in (renamed from rpkid/portal-gui/settings.py) | 24 |
4 files changed, 54 insertions, 14 deletions
diff --git a/buildtools/subst-vars.py b/buildtools/subst-vars.py new file mode 100755 index 00000000..5083c2dd --- /dev/null +++ b/buildtools/subst-vars.py @@ -0,0 +1,28 @@ +# $Id$ + +""" +Copyright (C) 2011 SPARTA, Inc., dba Cobham Analytic Solutions + +Permission to use, copy, modify, and distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE +OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +""" + + +import os, sys + +# pull out all AC_* environment variables into a dict to substitute in the input file +d = {} +for v in os.environ: + if v.startswith('AC_'): + d[v] = os.environ[v] + +sys.stdout.write(sys.stdin.read() % d) diff --git a/rpkid/Makefile.in b/rpkid/Makefile.in index 9ad7b4e8..5980d6bd 100644 --- a/rpkid/Makefile.in +++ b/rpkid/Makefile.in @@ -69,7 +69,7 @@ BUILD_SCRIPTS = portal-gui/scripts/rpkigui-reset-demo \ AUX_SCRIPTS = -SETTINGS = portal-gui/local_settings.py portal-gui/rpki.wsgi +SETTINGS = portal-gui/settings.py portal-gui/rpki.wsgi all:: ${POW_SO} rpki/relaxng.py myrpki.rng rpki/sql_schemas.py ${SCRIPTS} ${AUX_SCRIPTS} ${SETTINGS} ${BUILD_SCRIPTS} @@ -287,12 +287,8 @@ portal-gui/rpki.wsgi: ${srcdir}/portal-gui/rpki.wsgi.in -e "s|@PYTHON""PATH@|${sysconfdir}/rpki|" \ ${srcdir}/portal-gui/rpki.wsgi.in > portal-gui/rpki.wsgi -portal-gui/local_settings.py: Makefile - ( echo 'import rpki.config'; \ - echo 'SECRET_KEY="${SECRET_KEY}"'; \ - echo 'STATIC_ROOT="${datarootdir}/rpki/media"'; \ - echo 'rpki.config.default_dirname="${sysconfdir}"'; \ - ) > portal-gui/local_settings.py +portal-gui/settings.py: ${srcdir}/portal-gui/settings.py.in + ${COMPILE_SETTINGS} portal-gui/scripts/rpki-manage: ${srcdir}/portal-gui/scripts/rpki-manage.in sed -e "s|@DJANGO""_ADMIN@|${DJANGO_ADMIN}|" \ diff --git a/rpkid/portal-gui/Makefile.in b/rpkid/portal-gui/Makefile.in index 9e7fc85f..7eb2e572 100644 --- a/rpkid/portal-gui/Makefile.in +++ b/rpkid/portal-gui/Makefile.in @@ -24,7 +24,7 @@ INSTDIR=${DESTDIR}$(datarootdir)/rpki SYSCONFDIR=${DESTDIR}${sysconfdir}/rpki # automatically built sources -BUILD=apache.conf local_settings.py +BUILD=apache.conf all: $(BUILD) @@ -53,7 +53,6 @@ install: $(BUILD) ${INSTALL} -m 644 apache.conf $(SYSCONFDIR)/apache.conf ${INSTALL} -m 644 rpki.wsgi $(INSTDIR)/wsgi/rpki.wsgi ${INSTALL} -m 644 settings.py ${SYSCONFDIR} - ${INSTALL} -m 644 local_settings.py ${SYSCONFDIR} # this would be better handled with "django-admin collectstatic" but makes the install # process harder for the end user. ${INSTALL} -m 644 $(srcdir)/../rpki/gui/app/static/css/* $(INSTDIR)/media/css @@ -62,8 +61,7 @@ install: $(BUILD) deinstall uninstall: rm -rf $(INSTDIR)/media $(INSTDIR)/wsgi - rm -rf $(SYSCONFDIR)/apache.conf $(SYSCONFDIR)/settings.py $(SYSCONFDIR)/settings.pyc \ - $(SYSCONFDIR)/local_settings.py $(SYSCONFDIR)/settings.pyc + rm -rf $(SYSCONFDIR)/apache.conf $(SYSCONFDIR)/settings.py $(SYSCONFDIR)/settings.pyc test: @true diff --git a/rpkid/portal-gui/settings.py b/rpkid/portal-gui/settings.py.in index ee4b5cee..8246304c 100644 --- a/rpkid/portal-gui/settings.py +++ b/rpkid/portal-gui/settings.py.in @@ -1,14 +1,23 @@ -# DO NOT EDIT! Modifications should be placed in local_settings.py +# +# Sample Django settings.py for running the RPKI portal gui. This +# template was written for Django 1.3. +# +# DO NOT EDIT! This file is automatically generated from +# settings.py.in + __version__ = '$Id$' import rpki.config import os.path -from local_settings import * DEBUG = True TEMPLATE_DEBUG = DEBUG +# needs to be set prior to the call to rpki.config.parser so it knows +# where to find the system rpki.conf +rpki.config.default_dirname = '%(AC_SYSCONFDIR)s' + # load the sql authentication bits from the system rpki.conf rpki_config = rpki.config.parser(section='web_portal') @@ -27,7 +36,10 @@ def get_conv(): from MySQLdb.converters import conversions import types conv = conversions.copy() - conv[types.LongType] = lambda x, conv: "0x%x" % x + # WARNING: the extra percents in the following line are due to the fact + # that this entire script is used as a format string to generate + # settings.py + conv[types.LongType] = lambda x, conv: "0x%%x" %% x return conv DATABASES = { @@ -66,6 +78,9 @@ def select_tz(): # system time zone. TIME_ZONE = select_tz() +# Make this unique, and don't share it with anybody. +SECRET_KEY = '%(AC_SECRET_KEY)s' + # List of callables that know how to import templates from various sources. TEMPLATE_LOADERS = ( 'django.template.loaders.filesystem.Loader', @@ -112,5 +127,8 @@ TEMPLATE_CONTEXT_PROCESSORS = ( "django.core.context_processors.static" ) +# where to put static files +STATIC_ROOT = '%(AC_DATAROOTDIR)s/rpki/media' + # must end with a slash! STATIC_URL = '/media/' |