From 145dc43c3ddc82b2237d73f9f0bce2b957faac78 Mon Sep 17 00:00:00 2001 From: Albert Hopkins Date: Wed, 21 Jul 2010 23:09:09 -0400 Subject: [PATCH] Oops, actually forgot to add the teamplayer directory --- teamplayer/10_teamplayer.conf | 17 ++++++++ teamplayer/apache2.conf | 73 +++++++++++++++++++++++++++++++++++ teamplayer/critical | 36 +++++++++++++++++ teamplayer/local.start | 8 ++++ teamplayer/local.stop | 3 ++ teamplayer/package.keywords | 1 + teamplayer/package.use | 8 ++++ teamplayer/postinstall | 41 ++++++++++++++++++++ teamplayer/preinstall | 13 +++++++ teamplayer/settings_local.py | 13 +++++++ teamplayer/start-teamplayer | 15 +++++++ teamplayer/stop-teamplayer | 7 ++++ teamplayer/teamplayer.wsgi | 10 +++++ teamplayer/world | 9 +++++ 14 files changed, 254 insertions(+) create mode 100644 teamplayer/10_teamplayer.conf create mode 100644 teamplayer/apache2.conf create mode 100644 teamplayer/critical create mode 100755 teamplayer/local.start create mode 100644 teamplayer/local.stop create mode 100644 teamplayer/package.keywords create mode 100644 teamplayer/package.use create mode 100755 teamplayer/postinstall create mode 100755 teamplayer/preinstall create mode 100644 teamplayer/settings_local.py create mode 100755 teamplayer/start-teamplayer create mode 100755 teamplayer/stop-teamplayer create mode 100644 teamplayer/teamplayer.wsgi create mode 100644 teamplayer/world diff --git a/teamplayer/10_teamplayer.conf b/teamplayer/10_teamplayer.conf new file mode 100644 index 0000000..9458234 --- /dev/null +++ b/teamplayer/10_teamplayer.conf @@ -0,0 +1,17 @@ +Servername HOSTNAME +Listen 80 +ProxyPass /repo/ http://localhost:8000/repo/ + + + DocumentRoot TP_HOME/web/ + WSGIDaemonProcess TP_USER user=TP_USER group=TP_USER processes=1 threads=5 + WSGIScriptAlias / TP_HOME/teamplayer.wsgi + + + WSGIProcessGroup TP_USER + WSGIApplicationGroup %{GLOBAL} + Order deny,allow + Allow from all + + + diff --git a/teamplayer/apache2.conf b/teamplayer/apache2.conf new file mode 100644 index 0000000..acc0e98 --- /dev/null +++ b/teamplayer/apache2.conf @@ -0,0 +1,73 @@ +# /etc/conf.d/apache2: config file for /etc/init.d/apache2 + +# When you install a module it is easy to activate or deactivate the modules +# and other features of apache using the APACHE2_OPTS line. Every module should +# install a configuration in /etc/apache2/modules.d. In that file will have an +# directive where NNN is the option to enable that module. +# +# Here are the options available in the default configuration: +# +# AUTH_DIGEST Enables mod_auth_digest +# AUTHNZ_LDAP Enables authentication through mod_ldap (available if USE=ldap) +# CACHE Enables mod_cache +# DAV Enables mod_dav +# ERRORDOCS Enables default error documents for many languages. +# INFO Enables mod_info, a useful module for debugging +# LANGUAGE Enables content-negotiation based on language and charset. +# LDAP Enables mod_ldap (available if USE=ldap) +# MANUAL Enables /manual/ to be the apache manual (available if USE=docs) +# MEM_CACHE Enables default configuration mod_mem_cache +# PROXY Enables mod_proxy +# SSL Enables SSL (available if USE=ssl) +# SUEXEC Enables running CGI scripts (in USERDIR) through suexec. +# USERDIR Enables /~username mapping to /home/username/public_html +# +# +# The following two options provide the default virtual host for the HTTP and +# HTTPS protocol. YOU NEED TO ENABLE AT LEAST ONE OF THEM, otherwise apache +# will not listen for incomming connections on the approriate port. +# +# DEFAULT_VHOST Enables name-based virtual hosts, with the default +# virtual host being in /var/www/localhost/htdocs +# SSL_DEFAULT_VHOST Enables default vhost for SSL (you should enable this +# when you enable SSL) +# +APACHE2_OPTS="-D INFO -D WSGI -D PROXY" + +# Extended options for advanced uses of Apache ONLY +# You don't need to edit these unless you are doing crazy Apache stuff +# As not having them set correctly, or feeding in an incorrect configuration +# via them will result in Apache failing to start +# YOU HAVE BEEN WARNED. + +# PID file +#PIDFILE=/var/run/apache2.pid + +# timeout for startup/shutdown checks +#TIMEOUT=10 + +# ServerRoot setting +#SERVERROOT=/usr/lib64/apache2 + +# Configuration file location +# - If this does NOT start with a '/', then it is treated relative to +# $SERVERROOT by Apache +#CONFIGFILE=/etc/apache2/httpd.conf + +# Location to log startup errors to +# They are normally dumped to your terminal. +#STARTUPERRORLOG="/var/log/apache2/startuperror.log" + +# A command that outputs a formatted text version of the HTML at the URL +# of the command line. Designed for lynx, however other programs may work. +#LYNX="lynx -dump" + +# The URL to your server's mod_status status page. +# Required for status and fullstatus +#STATUSURL="http://localhost/server-status" + +# Method to use when reloading the server +# Valid options are 'restart' and 'graceful' +# See http://httpd.apache.org/docs/2.2/stopping.html for information on +# what they do and how they differ. +#RELOAD_TYPE="graceful" diff --git a/teamplayer/critical b/teamplayer/critical new file mode 100644 index 0000000..07ffddb --- /dev/null +++ b/teamplayer/critical @@ -0,0 +1,36 @@ +app-editors/nano +net-misc/openssh +net-misc/rsync +net-misc/wget +sys-kernel/gentoo-sources +sys-kernel/linux-headers +sys-devel/gcc +sys-devel/automake +sys-devel/bison +sys-devel/make +sys-devel/flex +sys-devel/automake-wrapper +sys-devel/autoconf-wrapper +sys-devel/autoconf +sys-devel/m4 +sys-devel/gcc-config +sys-devel/libtool +sys-devel/binutils +sys-devel/binutils-config +sys-devel/patch +sys-devel/gnuconfig +app-admin/python-updater +app-admin/perl-cleaner +sys-apps/man-pages +sys-apps/man +sys-apps/file +sys-apps/less +sys-apps/texinfo +sys-apps/busybox +sys-apps/debianutils +sys-apps/man-pages-posix +sys-apps/sandbox +sys-apps/which +dev-lang/perl +sys-devel/libperl +sys-apps/portage diff --git a/teamplayer/local.start b/teamplayer/local.start new file mode 100755 index 0000000..11f1c1b --- /dev/null +++ b/teamplayer/local.start @@ -0,0 +1,8 @@ +#!/bin/sh + +su -c "TP_HOME/bin/start-teamplayer" TP_USER +tailf TP_HOME/teamplayer.log > /dev/tty7 & + +# put some ionice on mpd +sleep 3 +ionice -c2 -n0 -p$(cat TP_DB/mpd/mpd.pid) diff --git a/teamplayer/local.stop b/teamplayer/local.stop new file mode 100644 index 0000000..86077ac --- /dev/null +++ b/teamplayer/local.stop @@ -0,0 +1,3 @@ +#!/bin/sh + +su -c "TP_HOME/bin/stop-teamplayer" TP_USER diff --git a/teamplayer/package.keywords b/teamplayer/package.keywords new file mode 100644 index 0000000..2da3877 --- /dev/null +++ b/teamplayer/package.keywords @@ -0,0 +1 @@ +dev-python/django ~amd64 diff --git a/teamplayer/package.use b/teamplayer/package.use new file mode 100644 index 0000000..8f9eedb --- /dev/null +++ b/teamplayer/package.use @@ -0,0 +1,8 @@ +app-editors/nano ncurses +dev-lang/python sqlite ssl threads xml +sys-kernel/gentoo-sources symlink +media-sound/mpd audiofile ffmpeg flac id3 lame network ogg vorbis mad sqlite +media-video/ffmpeg mmx mxext mp3 network x264 +media-libs/flac ogg +dev-python/django sqlite +dev-db/sqlite threadsafe diff --git a/teamplayer/postinstall b/teamplayer/postinstall new file mode 100755 index 0000000..8a460f4 --- /dev/null +++ b/teamplayer/postinstall @@ -0,0 +1,41 @@ +#!/bin/sh -e + +CHROOT="$1" +HOSTNAME="$2" +APPLIANCE="`dirname $0`" + +HG_REPO="/home/percy/Hg/teamplayer" +TP_USER="teamplayer" +TP_HOME="/opt/teamplayer" +TP_DB="/var/db/teamplayer" + +INSTALL="/usr/bin/install" +M4="/usr/bin/m4" +M4_DEFS="-D HOSTNAME=${HOSTNAME} -D TP_USER=${TP_USER} -D TP_HOME=${TP_HOME}" +M4_DEFS="${M4_DEFS} -D TP_DB=${TP_DB}" +M4C="${M4} ${M4_DEFS}" + +chroot ${CHROOT} getent passwd ${TP_USER} || \ + chroot ${CHROOT} useradd -c "Teamplayer Server" -U -d ${TP_HOME} \ + ${TP_USER} +rm -rf ${TP_HOME} +hg clone --pull ${HG_REPO} ${CHROOT}/${TP_HOME} +cp ${APPLIANCE}/teamplayer.wsgi ${CHROOT}${TP_HOME}/teamplayer.wsgi +${M4C} ${APPLIANCE}/settings_local.py > ${CHROOT}${TP_HOME}/web/settings_local.py +mkdir -p ${CHROOT}${TP_HOME}/bin +${M4C} ${APPLIANCE}/start-teamplayer > ${CHROOT}${TP_HOME}/bin/start-teamplayer +chmod +x ${CHROOT}${TP_HOME}/bin/start-teamplayer +${M4C} ${APPLIANCE}/stop-teamplayer > ${CHROOT}${TP_HOME}/bin/stop-teamplayer +chmod +x ${CHROOT}${TP_HOME}/bin/stop-teamplayer +chroot ${CHROOT} ${INSTALL} -d -o ${TP_USER} -g ${TP_USER} ${TP_DB} +chroot ${CHROOT} ${INSTALL} -d -o ${TP_USER} -g ${TP_USER} ${TP_DB}/songs +chroot ${CHROOT} rm -rf ${TP_HOME}/web/media/songs +chroot ${CHROOT} ln -s ${TP_DB}/songs ${TP_HOME}/web/media/songs +chroot ${CHROOT} ${INSTALL} -d -o ${TP_USER} -g ${TP_USER} ${TP_DB}/mpd +chroot ${CHROOT} chown -R ${TP_USER}:${TP_USER} ${TP_HOME} +${M4C} ${APPLIANCE}/10_teamplayer.conf > ${CHROOT}/etc/apache2/vhosts.d/10_teamplayer.conf +cp ${APPLIANCE}/apache2.conf ${CHROOT}/etc/conf.d/apache2 +${M4C} ${APPLIANCE}/local.start > ${CHROOT}/etc/conf.d/local.start +${M4C} ${APPLIANCE}/local.stop > ${CHROOT}/etc/conf.d/local.stop +sed -i 's/Gentoo Virtual Machine/TEAMPLAYER CONSOLE/' ${CHROOT}/etc/issue +chroot ${CHROOT} rc-update add apache2 default diff --git a/teamplayer/preinstall b/teamplayer/preinstall new file mode 100755 index 0000000..7e3f6c5 --- /dev/null +++ b/teamplayer/preinstall @@ -0,0 +1,13 @@ +#!/bin/sh -ev + +CHROOT="$1" +APPLIANCE="`dirname $0`" + +# set up apache modules in make.conf +cat >> ${CHROOT}/etc/make.conf << EOF + +# Apache config for TeamPlayer +APACHE2_MPMS="prefork" +APACHE2_MODULES="authz_host dir mime proxy proxy_http" +EOF + diff --git a/teamplayer/settings_local.py b/teamplayer/settings_local.py new file mode 100644 index 0000000..6d1faaf --- /dev/null +++ b/teamplayer/settings_local.py @@ -0,0 +1,13 @@ +TEMPLATE_DIRS = ( + 'TP_HOME/web/templates', +) + +TP_STREAM_URL = '/stream.mp3' +`TP_HOME' = 'TP_HOME' +DEBUG = False +TEMPLATE_DEBUG = DEBUG +DATABASE_ENGINE = 'sqlite3' +DATABASE_NAME = 'TP_DB/teamplayer.db' +#SONG_STORAGE = 'TP_DB/songs' +TP_MPD_HOME = 'TP_DB/mpd' +TP_REPO_URL = '/repo/' diff --git a/teamplayer/start-teamplayer b/teamplayer/start-teamplayer new file mode 100755 index 0000000..3d059ca --- /dev/null +++ b/teamplayer/start-teamplayer @@ -0,0 +1,15 @@ +#!/bin/sh +# this should be run as the TP_USER user + +cd ~ +hg serve -p 8000 --prefix /repo/ > $HOME/hgserve.log 2>&1 & + +cd ~/web + +if [ ! -f "TP_DB/teamplayer.db" ] ; then + python manage.py syncdb +fi + +# spin! +python manage.py spin --verbosity=2 > "$HOME/teamplayer.log" 2>&1 & +echo $! > "$HOME/tps.pid" diff --git a/teamplayer/stop-teamplayer b/teamplayer/stop-teamplayer new file mode 100755 index 0000000..44ca610 --- /dev/null +++ b/teamplayer/stop-teamplayer @@ -0,0 +1,7 @@ +#!/bin/sh +# this should be run as the TP_USER user + +cd ~/web + +[ -f "$HOME/tps.pid" ] && kill $(cat "$HOME/tps.pid") +python manage.py stop_stream > "$HOME/teamplayer.log" diff --git a/teamplayer/teamplayer.wsgi b/teamplayer/teamplayer.wsgi new file mode 100644 index 0000000..f89ac81 --- /dev/null +++ b/teamplayer/teamplayer.wsgi @@ -0,0 +1,10 @@ +import os +import sys +path = os.path.dirname(__file__) +sys.path.append(path) +os.environ['DJANGO_SETTINGS_MODULE'] = 'web.settings' + +import django.core.handlers.wsgi + +application = django.core.handlers.wsgi.WSGIHandler() + diff --git a/teamplayer/world b/teamplayer/world new file mode 100644 index 0000000..e8bda09 --- /dev/null +++ b/teamplayer/world @@ -0,0 +1,9 @@ +media-sound/mpd +media-sound/mpc +dev-python/python-mpd +dev-python/django +www-servers/apache +www-apache/mod_wsgi +net-misc/dhcpcd +media-libs/mutagen +dev-vcs/mercurial