mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-23 22:59:30 +00:00
Imported a cut down mumble app
This commit is contained in:
22
mumble/management/__init__.py
Normal file
22
mumble/management/__init__.py
Normal file
@@ -0,0 +1,22 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
* Copyright © 2009-2010, Michael "Svedrin" Ziegler <diese-addy@funzt-halt.net>
|
||||
*
|
||||
* Mumble-Django is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This package is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
"""
|
||||
|
||||
from server_detect import find_existing_instances
|
||||
from django.db.models import signals
|
||||
from mumble import models
|
||||
|
||||
signals.post_syncdb.connect( find_existing_instances, sender=models );
|
||||
|
||||
15
mumble/management/commands/__init__.py
Normal file
15
mumble/management/commands/__init__.py
Normal file
@@ -0,0 +1,15 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
* Copyright © 2009-2010, Michael "Svedrin" Ziegler <diese-addy@funzt-halt.net>
|
||||
*
|
||||
* Mumble-Django is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This package is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
"""
|
||||
194
mumble/management/commands/checkenv.py
Normal file
194
mumble/management/commands/checkenv.py
Normal file
@@ -0,0 +1,194 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
* Copyright © 2009-2010, Michael "Svedrin" Ziegler <diese-addy@funzt-halt.net>
|
||||
*
|
||||
* Mumble-Django is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This package is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
"""
|
||||
|
||||
import os, Ice
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.sites.models import Site
|
||||
from django.conf import settings
|
||||
|
||||
from mumble.models import Mumble
|
||||
|
||||
|
||||
class TestFailed( Exception ):
|
||||
pass;
|
||||
|
||||
class Command( BaseCommand ):
|
||||
def handle(self, **options):
|
||||
self.check_slice();
|
||||
self.check_rootdir();
|
||||
self.check_dbase();
|
||||
self.check_sites();
|
||||
self.check_mumbles();
|
||||
self.check_admins();
|
||||
self.check_secret_key();
|
||||
|
||||
def check_slice( self ):
|
||||
print "Checking slice file...",
|
||||
if settings.SLICE is None:
|
||||
raise TestFailed( "You don't have set the SLICE variable in settings.py." )
|
||||
|
||||
if " " in settings.SLICE:
|
||||
raise TestFailed( "You have a space char in your Slice path. This will confuse Ice, please check." )
|
||||
|
||||
if not settings.SLICE.endswith( ".ice" ):
|
||||
raise TestFailed( "The slice file name MUST end with '.ice'." )
|
||||
|
||||
try:
|
||||
fd = open( settings.SLICE, "rb" )
|
||||
slice = fd.read()
|
||||
fd.close()
|
||||
except IOError, err:
|
||||
raise TestFailed( "Failed opening the slice file: %s" % err )
|
||||
|
||||
import Ice
|
||||
Ice.loadSlice( settings.SLICE )
|
||||
|
||||
print "[ OK ]"
|
||||
|
||||
def check_rootdir( self ):
|
||||
print "Checking root directory access...",
|
||||
if not os.path.exists( settings.MUMBLE_DJANGO_ROOT ):
|
||||
raise TestFailed( "The mumble-django root directory does not exist." );
|
||||
|
||||
elif settings.DATABASE_ENGINE != "sqlite3":
|
||||
print "not using sqlite [ OK ]"
|
||||
|
||||
else:
|
||||
statinfo = os.stat( settings.MUMBLE_DJANGO_ROOT );
|
||||
|
||||
if statinfo.st_uid == 0:
|
||||
raise TestFailed(
|
||||
"The mumble-django root directory belongs to user root. This is "
|
||||
"most certainly not what you want because it will prevent your "
|
||||
"web server from being able to write to the database. Please check." );
|
||||
|
||||
elif not os.access( settings.MUMBLE_DJANGO_ROOT, os.W_OK ):
|
||||
raise TestFailed( "The mumble-django root directory is not writable." );
|
||||
|
||||
else:
|
||||
print "[ OK ]";
|
||||
|
||||
def check_dbase( self ):
|
||||
print "Checking database access...",
|
||||
if settings.DATABASE_ENGINE == "sqlite3":
|
||||
if not os.path.exists( settings.DATABASE_NAME ):
|
||||
raise TestFailed( "database does not exist. Have you run syncdb yet?" );
|
||||
|
||||
else:
|
||||
statinfo = os.stat( settings.DATABASE_NAME );
|
||||
|
||||
if statinfo.st_uid == 0:
|
||||
raise TestFailed(
|
||||
"the database file belongs to root. This is most certainly not what "
|
||||
"you want because it will prevent your web server from being able "
|
||||
"to write to it. Please check." );
|
||||
|
||||
elif not os.access( settings.DATABASE_NAME, os.W_OK ):
|
||||
raise TestFailed( "database file is not writable." );
|
||||
|
||||
else:
|
||||
print "[ OK ]";
|
||||
|
||||
else:
|
||||
print "not using sqlite, so I can't check.";
|
||||
|
||||
|
||||
def check_sites( self ):
|
||||
print "Checking URL configuration...",
|
||||
|
||||
try:
|
||||
site = Site.objects.get_current();
|
||||
|
||||
except Site.DoesNotExist:
|
||||
try:
|
||||
sid = settings.SITE_ID
|
||||
except AttributeError:
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
raise ImproperlyConfigured(
|
||||
"You're using the Django \"sites framework\" without having set the SITE_ID "
|
||||
"setting. Create a site in your database and rerun this command to fix this error.")
|
||||
else:
|
||||
print( "none set.\n"
|
||||
"Please enter the domain where Mumble-Django is reachable." );
|
||||
dom = raw_input( "> " ).strip();
|
||||
site = Site( id=sid, name=dom, domain=dom );
|
||||
site.save();
|
||||
|
||||
if site.domain == 'example.com':
|
||||
print( "still the default.\n"
|
||||
"The domain is configured as example.com, which is the default but does not make sense. "
|
||||
"Please enter the domain where Mumble-Django is reachable." );
|
||||
|
||||
site.domain = raw_input( "> " ).strip();
|
||||
site.save();
|
||||
|
||||
print site.domain, "[ OK ]";
|
||||
|
||||
|
||||
def check_admins( self ):
|
||||
print "Checking if an Admin user exists...",
|
||||
|
||||
for user in User.objects.all():
|
||||
if user.is_superuser:
|
||||
print "[ OK ]";
|
||||
return;
|
||||
|
||||
raise TestFailed( ""
|
||||
"No admin user exists, so you won't be able to log in to the admin system. You "
|
||||
"should run `./manage.py createsuperuser` to create one." );
|
||||
|
||||
|
||||
def check_mumbles( self ):
|
||||
print "Checking Murmur instances...",
|
||||
|
||||
mm = Mumble.objects.all();
|
||||
|
||||
if mm.count() == 0:
|
||||
raise TestFailed(
|
||||
"no Mumble servers are configured, you might want to run "
|
||||
"`./manage.py syncdb` to run an auto detection." );
|
||||
|
||||
else:
|
||||
for mumble in mm:
|
||||
try:
|
||||
mumble.getCtl();
|
||||
except Ice.Exception, err:
|
||||
raise TestFailed(
|
||||
"Connecting to Murmur `%s` (%s) failed: %s" % ( mumble.name, mumble.dbus, err )
|
||||
);
|
||||
print "[ OK ]";
|
||||
|
||||
def check_secret_key( self ):
|
||||
print "Checking SECRET_KEY...",
|
||||
|
||||
blacklist = ( 'u-mp185msk#z4%s(do2^5405)y5d!9adbn92)apu_p^qvqh10v', );
|
||||
|
||||
if settings.SECRET_KEY in blacklist:
|
||||
raise TestFailed(
|
||||
"Your SECRET_KEY setting matches one of the keys that were put in the settings.py "
|
||||
"file shipped with Mumble-Django, which means your SECRET_KEY is all but secret. "
|
||||
"You should change the setting, or run gen_secret_key.sh to do it for you."
|
||||
);
|
||||
else:
|
||||
print "[ OK ]";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
21
mumble/management/commands/mmrunserver.py
Normal file
21
mumble/management/commands/mmrunserver.py
Normal file
@@ -0,0 +1,21 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
* Copyright © 2009-2010, Michael "Svedrin" Ziegler <diese-addy@funzt-halt.net>
|
||||
*
|
||||
* Mumble-Django is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This package is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
"""
|
||||
|
||||
from django.core.management.commands.runserver import Command as OrigCommand
|
||||
from mumble.murmurenvutils import MumbleCommandWrapper
|
||||
|
||||
class Command( MumbleCommandWrapper, OrigCommand ):
|
||||
pass
|
||||
21
mumble/management/commands/mmshell.py
Normal file
21
mumble/management/commands/mmshell.py
Normal file
@@ -0,0 +1,21 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
* Copyright © 2009-2010, Michael "Svedrin" Ziegler <diese-addy@funzt-halt.net>
|
||||
*
|
||||
* Mumble-Django is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This package is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
"""
|
||||
|
||||
from django.core.management.commands.shell import Command as OrigCommand
|
||||
from mumble.murmurenvutils import MumbleCommandWrapper_noargs
|
||||
|
||||
class Command( MumbleCommandWrapper_noargs, OrigCommand ):
|
||||
pass
|
||||
21
mumble/management/commands/mmsyncdb.py
Normal file
21
mumble/management/commands/mmsyncdb.py
Normal file
@@ -0,0 +1,21 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
* Copyright © 2009-2010, Michael "Svedrin" Ziegler <diese-addy@funzt-halt.net>
|
||||
*
|
||||
* Mumble-Django is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This package is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
"""
|
||||
|
||||
from django.core.management.commands.syncdb import Command as OrigCommand
|
||||
from mumble.murmurenvutils import MumbleCommandWrapper_noargs
|
||||
|
||||
class Command( MumbleCommandWrapper_noargs, OrigCommand ):
|
||||
pass
|
||||
135
mumble/management/server_detect.py
Normal file
135
mumble/management/server_detect.py
Normal file
@@ -0,0 +1,135 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
* Copyright © 2009-2010, Michael "Svedrin" Ziegler <diese-addy@funzt-halt.net>
|
||||
*
|
||||
* Mumble-Django is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This package is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
from mumble import models
|
||||
from mumble.mctl import MumbleCtlBase
|
||||
|
||||
|
||||
def find_in_dicts( keys, conf, default, valueIfNotFound=None ):
|
||||
if not isinstance( keys, tuple ):
|
||||
keys = ( keys, );
|
||||
|
||||
for keyword in keys:
|
||||
if keyword in conf:
|
||||
return conf[keyword];
|
||||
|
||||
for keyword in keys:
|
||||
keyword = keyword.lower();
|
||||
if keyword in default:
|
||||
return default[keyword];
|
||||
|
||||
return valueIfNotFound;
|
||||
|
||||
|
||||
def find_existing_instances( **kwargs ):
|
||||
if "verbosity" in kwargs:
|
||||
v = kwargs['verbosity'];
|
||||
else:
|
||||
v = 1;
|
||||
|
||||
if v > 1:
|
||||
print "Starting Mumble servers and players detection now.";
|
||||
|
||||
triedEnviron = False;
|
||||
online = False;
|
||||
while not online:
|
||||
if not triedEnviron and 'MURMUR_CONNSTR' in os.environ:
|
||||
dbusName = os.environ['MURMUR_CONNSTR'];
|
||||
triedEnviron = True;
|
||||
if v > 1:
|
||||
print "Trying environment setting", dbusName;
|
||||
else:
|
||||
print "--- Murmur connection info ---"
|
||||
print " 1) DBus -- net.sourceforge.mumble.murmur"
|
||||
print " 2) ICE -- Meta:tcp -h 127.0.0.1 -p 6502"
|
||||
print "Enter 1 or 2 for the defaults above, nothing to skip Server detection,"
|
||||
print "and if the defaults do not fit your needs, enter the correct string."
|
||||
print "Whether to use DBus or ICE will be detected automatically from the"
|
||||
print "string's format."
|
||||
print
|
||||
|
||||
dbusName = raw_input( "Service string: " ).strip();
|
||||
|
||||
if not dbusName:
|
||||
if v:
|
||||
print 'Be sure to run "python manage.py syncdb" with Murmur running before'
|
||||
print "trying to use this app! Otherwise, existing Murmur servers won't be"
|
||||
print 'configurable!';
|
||||
return False;
|
||||
elif dbusName == "1":
|
||||
dbusName = "net.sourceforge.mumble.murmur";
|
||||
elif dbusName == "2":
|
||||
dbusName = "Meta:tcp -h 127.0.0.1 -p 6502";
|
||||
|
||||
try:
|
||||
ctl = MumbleCtlBase.newInstance( dbusName, settings.SLICE );
|
||||
except Exception, instance:
|
||||
if v:
|
||||
print "Unable to connect using name %s. The error was:" % dbusName;
|
||||
print instance;
|
||||
print
|
||||
else:
|
||||
online = True;
|
||||
if v > 1:
|
||||
print "Successfully connected to Murmur via connection string %s, using %s." % ( dbusName, ctl.method );
|
||||
|
||||
servIDs = ctl.getAllServers();
|
||||
|
||||
for id in servIDs:
|
||||
if v > 1:
|
||||
print "Checking Murmur instance with id %d." % id;
|
||||
# first check that the server has not yet been inserted into the DB
|
||||
try:
|
||||
instance = models.Mumble.objects.get( dbus=dbusName, srvid=id );
|
||||
except models.Mumble.DoesNotExist:
|
||||
values = {
|
||||
"srvid": id,
|
||||
"dbus": dbusName,
|
||||
}
|
||||
|
||||
if v > 1:
|
||||
print "Found new Murmur instance %d on bus '%s'... " % ( id, dbusName ),
|
||||
|
||||
# now create a model for the record set.
|
||||
instance = models.Mumble( **values );
|
||||
else:
|
||||
if v > 1:
|
||||
print "Syncing Murmur instance... ",
|
||||
|
||||
instance.configureFromMurmur();
|
||||
|
||||
if v > 1:
|
||||
print instance.name;
|
||||
|
||||
instance.save( dontConfigureMurmur=True );
|
||||
|
||||
# Now search for players on this server that have not yet been registered
|
||||
if instance.booted:
|
||||
if v > 1:
|
||||
print "Looking for registered Players on Server id %d." % id;
|
||||
instance.readUsersFromMurmur( verbose=v );
|
||||
elif v > 1:
|
||||
print "This server is not running, can't sync players.";
|
||||
|
||||
if v > 1:
|
||||
print "Successfully finished Servers and Players detection.";
|
||||
return True;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user