Browse Source

move the database file to a db subdirectory, to get the perms right when people run "chmod -R <md-dir>/*"

Natenom/support-murmur-13-1446181288462
Michael Ziegler 15 years ago
parent
commit
1b15a7a263
  1. 2
      .hgignore
  2. 8
      db/README.txt
  3. 15
      pyweb/mumble/management/__init__.py
  4. 2
      pyweb/settings.py

2
.hgignore

@ -2,6 +2,8 @@ syntax: glob
*.pyc
*.db3
*.db3.bak
*.db3-journal
*~
.directory
.secret.txt

8
db/README.txt

@ -0,0 +1,8 @@
This file basically only exists to have HG keep the "db" directory. I
moved the DB to this subdirectory, because people keep running into
a "Cannot open database file" error which results from permissions
being set incorrectly. People mostly run "chown -R <md-dir>/*" instead
of "chown -R <md-dir>" and therefore run into these problems.
When the db is in a subdir of <md-dir>, it matches the wildcard and
will then have correct permissions.

15
pyweb/mumble/management/__init__.py

@ -14,6 +14,10 @@
* GNU General Public License for more details.
"""
from shutil import copy, move
from os.path import exists, join
from django.conf import settings
from django.db import connection
from django.db.models import signals
@ -22,6 +26,14 @@ from mumble import models
from update_schema import update_schema
from server_detect import find_existing_instances
if settings.DATABASE_ENGINE == "sqlite3":
# Move the DB to the db subdirectory if necessary.
oldpath = join( settings.MUMBLE_DJANGO_ROOT, "mumble-django.db3" )
if not exists( settings.DATABASE_NAME ) and exists( oldpath ):
move( oldpath, settings.DATABASE_NAME )
cursor = connection.cursor()
tablename = models.Mumble._meta.db_table
@ -38,6 +50,9 @@ else:
uptodate = True
if not uptodate:
if settings.DATABASE_ENGINE == "sqlite3":
# backup the db before the conversion.
copy( settings.DATABASE_NAME, settings.DATABASE_NAME+".bak" )
signals.post_syncdb.connect( update_schema, sender=models );
else:
signals.post_syncdb.connect( find_existing_instances, sender=models );

2
pyweb/settings.py

@ -106,7 +106,7 @@ MUNIN_CATEGORY = 'network'
# Database settings for Mumble-Django's database. These do NOT need to point to Murmur's database,
# Mumble-Django should use its own!
DATABASE_ENGINE = 'sqlite3'
DATABASE_NAME = join( MUMBLE_DJANGO_ROOT, 'mumble-django.db3' )
DATABASE_NAME = join( MUMBLE_DJANGO_ROOT, 'db', 'mumble-django.db3' )
DATABASE_USER = ''
DATABASE_PASSWORD = ''
DATABASE_HOST = ''

Loading…
Cancel
Save