teamplayer: fixes to work with TeamPlayer 2.0

This commit is contained in:
Albert Hopkins 2013-07-22 13:33:36 +00:00
parent 344f1bb1eb
commit 2ee9462c97
14 changed files with 187 additions and 47 deletions

View File

@ -6,7 +6,7 @@ PGVER = 9.2
INSTALL = install INSTALL = install
AVAHI := NO AVAHI := NO
M4_DEFS += -D TP_USER=$(TP_USER) -D TP_HOME=$(TP_HOME) -D TP_DB=$(TP_DB) M4_DEFS += -D TP_USER=$(TP_USER) -D TP_HOME=$(TP_HOME) -D TP_DB=$(TP_DB) -D TP_HOSTNAME=$(HOSTNAME)
M4C = $(M4) $(M4_DEFS) M4C = $(M4) $(M4_DEFS)
inroot := chroot $(CHROOT) inroot := chroot $(CHROOT)
@ -20,7 +20,7 @@ preinstall:
$(inroot) eselect python set python2.7 $(inroot) eselect python set python2.7
$(inroot) python-updater $(inroot) python-updater
postinstall: $(post_files) $(SCROBBLER_AUTH) postinstall: $(post_files) $(SCROBBLER_AUTH) urls.py
$(inroot) $(EMERGE) -n $(USEPKG) dev-db/postgresql-server:$(PGVER) $(inroot) $(EMERGE) -n $(USEPKG) dev-db/postgresql-server:$(PGVER)
$(inroot) passwd -d postgres $(inroot) passwd -d postgres
echo 'PG_INITDB_OPTS="--locale=en_US.UTF-8"' >> $(CHROOT)/etc/conf.d/postgresql-$(PGVER) echo 'PG_INITDB_OPTS="--locale=en_US.UTF-8"' >> $(CHROOT)/etc/conf.d/postgresql-$(PGVER)
@ -34,15 +34,23 @@ ifeq ($(AVAHI),YES)
cp teamplayer.service $(CHROOT)/etc/avahi/services cp teamplayer.service $(CHROOT)/etc/avahi/services
$(inroot) ln -sf /etc/init.d/avahi-daemon $(rcdefault)/avahi-daemon $(inroot) ln -sf /etc/init.d/avahi-daemon $(rcdefault)/avahi-daemon
endif endif
$(inroot) $(EMERGE) -1n $(USEPKG) dev-python/virtualenv
$(inroot) getent passwd $(TP_USER) || \ $(inroot) getent passwd $(TP_USER) || \
$(inroot) useradd -c "Teamplayer Server" -G postgres -U -d $(TP_HOME) $(TP_USER) $(inroot) useradd -c "Teamplayer Server" -G postgres -U -d $(TP_HOME) $(TP_USER)
rm -rf $(CHROOT)/$(TP_HOME) rm -rf $(CHROOT)/$(TP_HOME)
hg clone --pull $(TP_REPO) $(CHROOT)/$(TP_HOME) mkdir -p $(CHROOT)/$(TP_HOME)
hg clone --pull $(TP_REPO) $(CHROOT)/$(TP_HOME)/teamplayer
cp bash_profile $(CHROOT)$(TP_HOME)/.bash_profile cp bash_profile $(CHROOT)$(TP_HOME)/.bash_profile
$(inroot) mkdir -p /etc/teamplayer $(inroot) virtualenv-2.7 $(TP_HOME)
$(M4C) settings_local.py > $(CHROOT)/etc/teamplayer/settings_local.py $(inroot) bash -c ". $(TP_HOME)/bin/activate ; pip install -e $(TP_HOME)/teamplayer"
$(inroot) bash -c ". $(TP_HOME)/bin/activate ; pip install psycopg2 flup 'Whoosh<2.5.0'"
$(inroot) bash -c ". $(TP_HOME)/bin/activate ; django-admin.py startproject project $(TP_HOME)"
chmod +x $(CHROOT)/$(TP_HOME)/manage.py
$(inroot) ln -sf ../manage.py $(TP_HOME)/bin/manage
cp urls.py $(CHROOT)/$(TP_HOME)/project/urls.py
$(M4C) settings_local.py >> $(CHROOT)/$(TP_HOME)/project/settings_local.py
ifdef SCROBBLER_AUTH ifdef SCROBBLER_AUTH
cat $(SCROBBLER_AUTH) >> $(CHROOT)/etc/teamplayer/settings_local.py cat $(SCROBBLER_AUTH) >> $(CHROOT)/$(TP_HOME)/project/settings_local.py
endif endif
mkdir -p $(CHROOT)$(TP_HOME)/bin mkdir -p $(CHROOT)$(TP_HOME)/bin
$(M4C) start-teamplayer > $(CHROOT)$(TP_HOME)/bin/start-teamplayer $(M4C) start-teamplayer > $(CHROOT)$(TP_HOME)/bin/start-teamplayer
@ -51,9 +59,8 @@ endif
chmod +x $(CHROOT)$(TP_HOME)/bin/stop-teamplayer chmod +x $(CHROOT)$(TP_HOME)/bin/stop-teamplayer
$(inroot) $(INSTALL) -d -o $(TP_USER) -g $(TP_USER) $(TP_DB) $(inroot) $(INSTALL) -d -o $(TP_USER) -g $(TP_USER) $(TP_DB)
$(inroot) $(INSTALL) -d -o $(TP_USER) -g $(TP_USER) $(TP_DB)/songs $(inroot) $(INSTALL) -d -o $(TP_USER) -g $(TP_USER) $(TP_DB)/songs
$(inroot) rm -rf $(TP_HOME)/web/media/songs $(inroot) mkdir -p $(TP_HOME)/library
$(inroot) ln -s $(TP_DB)/songs $(TP_HOME)/web/media/songs $(inroot) chown -R $(TP_USER):$(TP_USER) $(TP_HOME)
$(inroot) chown -R $(TP_USER) $(TP_HOME)
$(inroot) $(INSTALL) -d -o $(TP_USER) -g $(TP_USER) $(TP_DB)/mpd $(inroot) $(INSTALL) -d -o $(TP_USER) -g $(TP_USER) $(TP_DB)/mpd
$(inroot) $(INSTALL) -d -o $(TP_USER) -g $(TP_USER) /var/log/teamplayer $(inroot) $(INSTALL) -d -o $(TP_USER) -g $(TP_USER) /var/log/teamplayer
$(M4C) local.start > $(CHROOT)/etc/local.d/teamplayer.start $(M4C) local.start > $(CHROOT)/etc/local.d/teamplayer.start
@ -64,10 +71,9 @@ endif
$(M4C) lighttpd.conf > $(CHROOT)/etc/lighttpd/lighttpd.conf $(M4C) lighttpd.conf > $(CHROOT)/etc/lighttpd/lighttpd.conf
$(inroot) gpasswd -a lighttpd teamplayer $(inroot) gpasswd -a lighttpd teamplayer
# Fix for Gentoo bug #359361. Remove when fixed
$(inroot) ln -sf /usr/lib/postgresql-$(PGVER)/lib64/libpq.so.5 /usr/lib/libpq.so.5
$(inroot) ln -sf /etc/init.d/lighttpd $(rcdefault)/lighttpd $(inroot) ln -sf /etc/init.d/lighttpd $(rcdefault)/lighttpd
$(inroot) ln -sf /etc/init.d/ntpd $(rcdefault)/ntpd $(inroot) ln -sf /etc/init.d/ntpd $(rcdefault)/ntpd
$(inroot) $(EMERGE) --depclean --with-bdeps=n
clean: clean:

View File

@ -1 +1,3 @@
export DJANGO_SETTINGS_MODULE='project.settings_local'
PATH="$HOME/bin:$PATH" PATH="$HOME/bin:$PATH"
. activate

View File

@ -1,4 +1,4 @@
------------------------------------------------------------------------------  ------------------------------------------------------------------------------
TEAMPLAYER CONSOLE TEAMPLAYER CONSOLE
------------------------------------------------------------------------------ ------------------------------------------------------------------------------

View File

@ -71,10 +71,10 @@ fastcgi.server = (
), ),
) )
alias.url = ( alias.url = (
"/m" => "TP_HOME/web/media/", "/static" => "TP_HOME/static/",
) )
url.rewrite-once = ( url.rewrite-once = (
"^(/m.*)$" => "$1", "^(/static.*)$" => "$1",
"^(/.*)$" => "/teamplayer.fcgi$1", "^(/.*)$" => "/teamplayer.fcgi$1",
) )

View File

@ -1,14 +1,16 @@
#!/bin/sh #!/bin/sh
LOGFILE="/var/log/teamplayer/teamplayer.log"
if [ ! -f /etc/firstboot ] ; then if [ ! -f /etc/firstboot ] ; then
echo "Creating TeamPlayer database ..." echo "Creating TeamPlayer database ..."
createuser -U postgres -D -S -R teamplayer createuser -U postgres -D -S -R teamplayer
createdb -U postgres teamplayer createdb -U postgres teamplayer
touch /var/log/teamplayer/teamplayer.log touch "$LOGFILE"
chown TP_USER:TP_USER /var/log/teamplayer/teamplayer.log chown TP_USER:TP_USER "$LOGFILE"
fi fi
su -c "TP_HOME/bin/start-teamplayer" TP_USER su -c "TP_HOME/bin/start-teamplayer" TP_USER
tailf /var/log/teamplayer/teamplayer.log > /dev/tty7 & #tailf "$LOGFILE" > /dev/console &
touch /etc/firstboot touch /etc/firstboot

0
teamplayer/local.stop Normal file → Executable file
View File

View File

@ -1,3 +1,5 @@
# Settings for TeamPlayer # Settings for TeamPlayer
PYTHON_TARGETS="python2_7" PYTHON_TARGETS="python2_7"
PYTHON_SINGLE_TARGET="python2_7"
USE_PYTHON="2.7"

View File

@ -1,4 +1,4 @@
dev-db/postgresql-base ~amd64 dev-db/postgresql-base ~amd64 ~x86
dev-db/postgresql-server ~amd64 dev-db/postgresql-server ~amd64 ~x86
dev-python/django ~amd64 virtual/python-imaging ~amd64 ~x86
dev-python/python-mpd ~amd64 dev-lang/python:2.7 ~amd64 ~x86

View File

@ -1,12 +1,13 @@
app-editors/nano ncurses app-editors/nano ncurses
dev-db/sqlite extensions dev-db/sqlite extensions
dev-lang/python sqlite ssl threads xml dev-lang/python sqlite ssl threads xml
dev-python/django postgres
media-libs/flac ogg media-libs/flac ogg
media-sound/mpd audiofile ffmpeg flac id3tag lame network ogg vorbis mad sqlite media-sound/mpd aac audiofile ffmpeg flac inotify id3tag lame network ogg vorbis mad sqlite
media-video/ffmpeg mmx mxext mp3 network x264 media-video/ffmpeg mmx mxext mp3 network x264
sys-apps/kmod tools
sys-devel/gcc cxx sys-devel/gcc cxx
sys-kernel/gentoo-sources symlink sys-kernel/gentoo-sources symlink
sys-libs/ncurses minimal sys-libs/ncurses minimal
virtual/python-imaging python_targets_python2_7
virtual/ffmpeg x264 mp3 virtual/ffmpeg x264 mp3
www-servers/lighttpd fastcgi pcre www-servers/lighttpd fastcgi pcre

View File

@ -1,15 +1,131 @@
from settings import *
#############################################################################
# Local Settings
#
# New/Overriden settings from settings_local.py
#############################################################################
import os
DEBUG = False
TEMPLATE_DEBUG = DEBUG
TIME_ZONE = 'America/New_York'
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'
# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = False
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash if there is a path component (optional in other cases).
# Examples: "http://media.lawrence.com", "http://example.com/media/"
MEDIA_URL = ''
STATIC_ROOT = 'static'
STATIC_URL = '/static/'
STATICFILE_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
)
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
)
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'haystack',
'rest_framework',
'teamplayer',
'tp_library',
)
AUTH_PROFILE_MODULE = 'teamplayer.UserProfile'
LOGIN_REDIRECT_URL = '/'
REST_FRAMEWORK = {
'DEFAULT_PERMISSION_CLASSES': [
'rest_framework.permissions.IsAuthenticated',
],
}
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
'formatters': {
'verbose': {
'format': '%(levelname)s %(asctime)s %(message)s'
}
},
'handlers': {
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler'
},
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'verbose'
}
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
'teamplayer': {
'handlers': ['console'],
'level': 'DEBUG',
'propagate': False,
}
}
}
ALLOWED_HOSTS = ['*']
TIME_ZONE = 'UTC' TIME_ZONE = 'UTC'
DJANGO_STATIC_MEDIA = False
FORCE_SCRIPT_NAME = '' FORCE_SCRIPT_NAME = ''
MEDIA_ROOT = 'TP_DB'
TEMPLATE_DIRS = ( TEMPLATE_DIRS = (
'TP_HOME/web/teamplayer/templates', 'TP_HOME/web/teamplayer/templates',
) )
TP_STREAM_URL = '/stream.mp3'
`TP_HOME' = 'TP_HOME' `TP_HOME' = 'TP_HOME'
DEBUG = False
TEMPLATE_DEBUG = DEBUG TEAMPLAYER = {
'STREAM_URL': '/stream.mp3',
'MPD_HOME': 'TP_DB/mpd',
'MPD_LOG': '/dev/null',
'UPLOADED_LIBRARY_DIR': 'TP_HOME/library',
'CROSSFADE': 2,
}
DATABASES = { DATABASES = {
'default': { 'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2', 'ENGINE': 'django.db.backends.postgresql_psycopg2',
@ -20,6 +136,13 @@ DATABASES = {
} }
} }
TP_MPD_HOME = 'TP_DB/mpd'
TP_REPO_URL = '/repo/' # haystack
TP_MPD_LOG = '/dev/null' HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine',
'PATH': os.path.join(`TP_HOME', 'library_index'),
},
}
HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.RealtimeSignalProcessor'

View File

@ -1,17 +1,15 @@
#!/bin/sh #!/bin/sh
# this should be run as the TP_USER user # this should be run as the TP_USER user
PYTHONPATH="/etc/teamplayer:$PYTHONPATH" PYTHON=python
PYTHON=python2.7 DJANGO_SETTINGS_MODULE="project.settings_local" ; export DJANGO_SETTINGS_MODULE
export PYTHONPATH
cd ~ cd ~
hg serve -p 8000 --prefix /repo/ > /var/log/teamplayer/hgserve.log 2>&1 & . bin/activate
cd ~/web
if [ ! -f "/etc/firstboot" ] ; then if [ ! -f "/etc/firstboot" ] ; then
$PYTHON manage.py syncdb --noinput --verbosity=0 $PYTHON manage.py syncdb --noinput --verbosity=0
$PYTHON manage.py collectstatic --noinput --verbosity=0
fi fi
# start the fastcgi daemon # start the fastcgi daemon
@ -19,6 +17,6 @@ $PYTHON manage.py runfcgi daemonize=true protocol=fcgi maxrequest=20 \
pidfile="TP_DB/fcgi.pid" socket=TP_DB/teamplayer.sock umask=002 \ pidfile="TP_DB/fcgi.pid" socket=TP_DB/teamplayer.sock umask=002 \
> "/var/log/teamplayer/teamplayer.log" 2>&1 > "/var/log/teamplayer/teamplayer.log" 2>&1
# spin! # Start the Spin Doctor
$PYTHON manage.py spin --verbosity=2 $@ > "/var/log/teamplayer/teamplayer.log" 2>&1 & $PYTHON manage.py spindoctor --verbosity=2 $@ > "/var/log/teamplayer/teamplayer.log" 2>&1 &
echo $! > "TP_DB/tps.pid" echo $! > "TP_DB/tps.pid"

View File

@ -1,12 +1,14 @@
#!/bin/sh #!/bin/sh
# this should be run as the TP_USER user # this should be run as the TP_USER user
cd ~/web PYTHON=python
PYTHONPATH="/etc/teamplayer:$PYTHONPATH" DJANGO_SETTINGS_MODULE="project.settings_local" ; export DJANGO_SETTINGS_MODULE
PYTHON=python2.7
export PYTHONPATH . ~/bin/activate
[ -f "TP_DB/tps.pid" ] && kill $(cat "TP_DB/tps.pid") cd ~
#[ -f "TP_DB/tps.pid" ] && kill $(cat "TP_DB/tps.pid")
[ -f "TP_DB/fcgi.pid" ] && kill $(cat "TP_DB/fcgi.pid") [ -f "TP_DB/fcgi.pid" ] && kill $(cat "TP_DB/fcgi.pid")
$PYTHON manage.py stop_stream >> "/var/log/teamplayer/teamplayer.log" $PYTHON manage.py stop_stream >> "/var/log/teamplayer/teamplayer.log"

8
teamplayer/urls.py Normal file
View File

@ -0,0 +1,8 @@
from django.conf.urls import patterns, include, url
urlpatterns = patterns(
'',
(r'^accounts/login/$', 'django.contrib.auth.views.login'),
url('^library/', include('tp_library.urls')),
url('', include('teamplayer.urls')),
)

View File

@ -1,7 +1,3 @@
=dev-python/django-1.3*
dev-python/flup
dev-python/python-mpd
media-libs/mutagen
media-sound/mpd media-sound/mpd
net-misc/ntp net-misc/ntp
www-servers/lighttpd www-servers/lighttpd