aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rpkid/Makefile.in6
-rw-r--r--rpkid/examples/rpki.conf14
-rw-r--r--rpkid/portal-gui/Makefile.in14
-rw-r--r--rpkid/portal-gui/scripts/rpkigui-setup-sql.py29
-rw-r--r--rpkid/portal-gui/settings.py.in24
5 files changed, 64 insertions, 23 deletions
diff --git a/rpkid/Makefile.in b/rpkid/Makefile.in
index 1ce31177..33e0dde5 100644
--- a/rpkid/Makefile.in
+++ b/rpkid/Makefile.in
@@ -44,7 +44,7 @@ POW_SO = rpki/POW/_POW.so
SCRIPTS = rpki-sql-backup rpki-sql-setup rpki-start-servers irbe_cli irdbd myrpki \
pubd rootd rpkid portal-gui/scripts/rpkigui-load-csv \
portal-gui/scripts/rpkigui-add-user portal-gui/scripts/rpkigui-response \
- portal-gui/scripts/rpkigui-rcynic
+ portal-gui/scripts/rpkigui-rcynic portal-gui/scripts/rpkigui-setup-sql
AUX_SCRIPTS =
@@ -200,7 +200,6 @@ COMPILE_DJANGO = \
COMPILE_SETTINGS = \
rm -f $@; \
- AC_DATABASE_PATH='${DESTDIR}${localstatedir}/rpki/gui.db' \
AC_SECRET_KEY='${SECRET_KEY}' \
AC_LOCALSTATEDIR='${DESTDIR}${localstatedir}' \
AC_WEBUSER='${WEBUSER}' \
@@ -248,6 +247,9 @@ portal-gui/scripts/rpkigui-rcynic: portal-gui/scripts/rpkigui-rcynic.py
portal-gui/scripts/rpkigui-response: portal-gui/scripts/rpkigui-response.py
${COMPILE_DJANGO}
+portal-gui/scripts/rpkigui-setup-sql: portal-gui/scripts/rpkigui-setup-sql.py
+ ${COMPILE_DJANGO}
+
portal-gui/apache/rpki.wsgi: ${srcdir}/portal-gui/apache/rpki.wsgi.in
${COMPILE_DJANGO}
diff --git a/rpkid/examples/rpki.conf b/rpkid/examples/rpki.conf
index 06b853a9..3ffdaa9b 100644
--- a/rpkid/examples/rpki.conf
+++ b/rpkid/examples/rpki.conf
@@ -132,6 +132,10 @@ pubd_sql_database = pubd
pubd_sql_username = ${myrpki::shared_sql_username}
pubd_sql_password = ${myrpki::shared_sql_password}
+web_portal_sql_database = web_portal
+web_portal_sql_username = ${myrpki::shared_sql_username}
+web_portal_sql_password = ${myrpki::shared_sql_password}
+
# Name of OpenSSL binary. You might need to change this if you have
# no system copy installed, or if the system copy doesn't support CMS.
# The copy of openssl built by this package should suffice.
@@ -368,6 +372,16 @@ root_cert_manifest = rsync://${myrpki::publication_rsync_server}/${myrpki::publ
#################################################################
+# Glue to allow the django application to pull user configuration
+# from this file rather than directly editing settings.py
+
+[web_portal]
+sql-database = ${myrpki::web_portal_sql_database}
+sql-username = ${myrpki::web_portal_sql_username}
+sql-password = ${myrpki::web_portal_sql_password}
+
+#################################################################
+
# Constants for OpenSSL voodoo portion of this file, to make them
# easier to find.
diff --git a/rpkid/portal-gui/Makefile.in b/rpkid/portal-gui/Makefile.in
index fa4e1e46..4c3882eb 100644
--- a/rpkid/portal-gui/Makefile.in
+++ b/rpkid/portal-gui/Makefile.in
@@ -17,16 +17,11 @@ libexecdir=@libexecdir@
sysconfdir=@sysconfdir@
WEBUSER=@WEBUSER@
-DJANGO_ADMIN=@DJANGO_ADMIN@
-PYTHON=@PYTHON@
-DJANGO_DIR=@DJANGO_DIR@
INSTALL = @INSTALL@
CONFDIR=${DESTDIR}$(localstatedir)/rpki/conf
-DATABASE_PATH=${DESTDIR}$(localstatedir)/rpki/gui.db
INSTDIR=${DESTDIR}$(datarootdir)/rpki/gui
-STATIC_DIR=${INSTDIR}/static
PYTHONPATH=${DESTDIR}${sysconfdir}/rpki
# automatically built sources
@@ -42,9 +37,7 @@ distclean: clean
rm -f Makefile
edit = sed \
- -e 's|@DJANGO_DIR[@]|$(DJANGO_DIR)|g' \
- -e 's|@INSTDIR[@]|$(INSTDIR)|g' \
- -e 's|@STATIC_DIR[@]|$(STATIC_DIR)|g'
+ -e 's|@INSTDIR[@]|$(INSTDIR)|g'
apache/rpki.conf: $(srcdir)/apache/rpki.conf.in Makefile
$(edit) $@.in > $@
@@ -52,8 +45,6 @@ apache/rpki.conf: $(srcdir)/apache/rpki.conf.in Makefile
.PHONY: install-perms install-data install
install-perms:
- chown $(WEBUSER) `dirname $(DATABASE_PATH)`
- chown $(WEBUSER) $(DATABASE_PATH)
mkdir -p $(CONFDIR)
chown -R $(WEBUSER) $(CONFDIR)
@@ -63,7 +54,6 @@ install-apache:
${INSTALL} -m 644 apache/rpki.wsgi $(INSTDIR)/apache
install-data: $(BUILD) install-apache
- mkdir -p `dirname $(DATABASE_PATH)`
mkdir -p ${PYTHONPATH}
# FIXME should eventually try to merge new settings?
@if [ ! -f ${PYTHONPATH}/settings.py ]; then \
@@ -72,8 +62,6 @@ install-data: $(BUILD) install-apache
echo "${PYTHONPATH}/settings.py already exists, installing settings.py as ${PYTHONPATH}/settings.py.new"; \
${INSTALL} -m 644 settings.py ${PYTHONPATH}/settings.py.new; \
fi
- $(DJANGO_ADMIN) syncdb --pythonpath ${PYTHONPATH} --settings settings
- #$(DJANGO_ADMIN) collectstatic --noinput --pythonpath ${PYTHONPATH} --settings settings
if [ ! -f $(INSTDIR)/rpki.conf.template ]; then ${INSTALL} -m 644 ../examples/rpki.conf $(INSTDIR)/rpki.conf.template; fi
install: install-data install-perms
diff --git a/rpkid/portal-gui/scripts/rpkigui-setup-sql.py b/rpkid/portal-gui/scripts/rpkigui-setup-sql.py
new file mode 100644
index 00000000..2d3c1833
--- /dev/null
+++ b/rpkid/portal-gui/scripts/rpkigui-setup-sql.py
@@ -0,0 +1,29 @@
+# $Id$
+#
+# This script is responsible for creating the database used by the
+# portal gui. Look in the settings.py file for the user and password.
+# n.b. The configure script generates a random password.
+#
+
+import getpass, MySQLdb
+from django.conf import settings
+
+dbname = settings.DATABASES['default']['NAME']
+dbuser = settings.DATABASES['default']['USER']
+dbpass = settings.DATABASES['default']['PASSWORD']
+
+print """WARNING!!!
+WARNING!!!
+WARNING!!!
+
+About to destroy and recreate the database named "%s" and give access
+to the user named "%s".
+""" % (dbname, dbuser)
+
+passwd = getpass.getpass('Please enter your MySQL root password: ')
+
+db = MySQLdb.connect(user='root', passwd=passwd)
+c = db.cursor()
+c.execute('DROP DATABASE IF EXISTS %s' % dbname)
+c.execute('CREATE DATABASE %s CHARACTER SET utf8' % dbname)
+c.execute('GRANT ALL ON %s.* TO %s@localhost identified by %%s' % (dbname, dbuser), (dbpass,))
diff --git a/rpkid/portal-gui/settings.py.in b/rpkid/portal-gui/settings.py.in
index 2800bc24..8e04ef62 100644
--- a/rpkid/portal-gui/settings.py.in
+++ b/rpkid/portal-gui/settings.py.in
@@ -6,13 +6,27 @@
# DO NOT EDIT! This file is automatically generated from
# settings.py.in
+import rpki.config
+
DEBUG = True
TEMPLATE_DEBUG = DEBUG
+RPKI_CONFIG = '/usr/local/var/rpki/conf/SPARTA/rpki.conf'
+
+rpki_config = rpki.config.parser(filename=RPKI_CONFIG, section='web_portal')
+
DATABASES = {
'default' : {
- 'ENGINE': 'django.db.backends.sqlite3',
- 'NAME' : '%(AC_DATABASE_PATH)s'
+ 'ENGINE': 'django.db.backends.mysql',
+ 'NAME' : rpki_config.get('sql-database'),
+ 'USER' : rpki_config.get('sql-username'),
+ 'PASSWORD': rpki_config.get('sql-password'),
+ # ensure the default storage engine is InnoDB since we need foreign key support
+ # django documentation suggests removing this after the syncdb is performed
+ # as an optimization, but there isn't an easy way to do this automatically.
+ 'OPTIONS' : {
+ 'init_command': 'SET storage_engine=INNODB'
+ }
}
}
@@ -54,7 +68,6 @@ INSTALLED_APPS = (
'django.contrib.admindocs',
'django.contrib.contenttypes',
'django.contrib.sessions',
-# 'django.contrib.staticfiles',
'rpki.gui.app',
'rpki.gui.cacheview'
)
@@ -67,8 +80,3 @@ TEMPLATE_CONTEXT_PROCESSORS = (
"django.contrib.messages.context_processors.messages",
"django.core.context_processors.request"
)
-
-#STATIC_URL = '/static/'
-#STATIC_ROOT = '%(AC_DATAROOTDIR)s/rpki/gui/static'
-#STATICFILES_DIRS = (("admin", "%(AC_DJANGO_DIR)s/contrib/admin/media"),)
-#STATICFILES_FINDERS = ("django.contrib.staticfiles.finders.FileSystemFinder",)