* Make non-public services only listen on localhost
* /opt/teamplayer/* is owned by root and thus not writeable * Put config files in /etc/teamplayer * Switch DBMS from Sqlite to PostgreSQL
This commit is contained in:
parent
eaf9c7cf82
commit
71c7629cb3
|
@ -5,7 +5,7 @@ ProxyPass /repo/ http://localhost:8000/repo/
|
||||||
<VirtualHost *>
|
<VirtualHost *>
|
||||||
DocumentRoot TP_HOME/web/
|
DocumentRoot TP_HOME/web/
|
||||||
WSGIDaemonProcess TP_USER user=TP_USER group=TP_USER processes=1 threads=5
|
WSGIDaemonProcess TP_USER user=TP_USER group=TP_USER processes=1 threads=5
|
||||||
WSGIScriptAlias / TP_HOME/teamplayer.wsgi
|
WSGIScriptAlias / /etc/teamplayer/teamplayer.wsgi
|
||||||
|
|
||||||
<Location "/">
|
<Location "/">
|
||||||
WSGIProcessGroup TP_USER
|
WSGIProcessGroup TP_USER
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
[H[2J
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
TEAMPLAYER CONSOLE
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,18 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
|
if [ ! -f /etc/firstboot ] ; then
|
||||||
|
echo "Creating TeamPlayer database ..."
|
||||||
|
createuser -U postgres -D -S -R teamplayer
|
||||||
|
createdb -U postgres teamplayer
|
||||||
|
touch /var/log/teamplayer/teamplayer.log
|
||||||
|
chown TP_USER:TP_USER /var/log/teamplayer/teamplayer.log
|
||||||
|
fi
|
||||||
|
|
||||||
su -c "TP_HOME/bin/start-teamplayer" TP_USER
|
su -c "TP_HOME/bin/start-teamplayer" TP_USER
|
||||||
tailf TP_HOME/teamplayer.log > /dev/tty7 &
|
tailf /var/log/teamplayer/teamplayer.log > /dev/tty7 &
|
||||||
|
|
||||||
# put some ionice on mpd
|
# put some ionice on mpd
|
||||||
sleep 3
|
sleep 3
|
||||||
ionice -c2 -n0 -p$(cat TP_DB/mpd/mpd.pid)
|
ionice -c2 -n0 -p$(cat TP_DB/mpd/mpd.pid)
|
||||||
|
|
||||||
|
touch /etc/firstboot
|
||||||
|
|
|
@ -4,6 +4,6 @@ sys-kernel/gentoo-sources symlink
|
||||||
media-sound/mpd audiofile ffmpeg flac id3 lame network ogg vorbis mad sqlite
|
media-sound/mpd audiofile ffmpeg flac id3 lame network ogg vorbis mad sqlite
|
||||||
media-video/ffmpeg mmx mxext mp3 network x264
|
media-video/ffmpeg mmx mxext mp3 network x264
|
||||||
media-libs/flac ogg
|
media-libs/flac ogg
|
||||||
dev-python/django sqlite
|
dev-python/django postgres
|
||||||
dev-db/sqlite threadsafe
|
dev-db/sqlite threadsafe
|
||||||
www-servers/apache threads
|
www-servers/apache threads
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/sh -e
|
#!/bin/sh -ve
|
||||||
|
|
||||||
CHROOT="$1"
|
CHROOT="$1"
|
||||||
HOSTNAME="$2"
|
HOSTNAME="$2"
|
||||||
|
@ -7,7 +7,8 @@ APPLIANCE="`dirname $0`"
|
||||||
HG_REPO="../teamplayer"
|
HG_REPO="../teamplayer"
|
||||||
TP_USER="teamplayer"
|
TP_USER="teamplayer"
|
||||||
TP_HOME="/opt/teamplayer"
|
TP_HOME="/opt/teamplayer"
|
||||||
TP_DB="/var/db/teamplayer"
|
TP_DB="/var/run/teamplayer"
|
||||||
|
PGVER="8.4"
|
||||||
|
|
||||||
INSTALL="/usr/bin/install"
|
INSTALL="/usr/bin/install"
|
||||||
M4="/usr/bin/m4"
|
M4="/usr/bin/m4"
|
||||||
|
@ -15,14 +16,23 @@ M4_DEFS="-D HOSTNAME=${HOSTNAME} -D TP_USER=${TP_USER} -D TP_HOME=${TP_HOME}"
|
||||||
M4_DEFS="${M4_DEFS} -D TP_DB=${TP_DB}"
|
M4_DEFS="${M4_DEFS} -D TP_DB=${TP_DB}"
|
||||||
M4C="${M4} ${M4_DEFS}"
|
M4C="${M4} ${M4_DEFS}"
|
||||||
|
|
||||||
|
# Postgres config
|
||||||
|
chroot ${CHROOT} passwd -d postgres
|
||||||
|
yes | chroot ${CHROOT} emerge --config =postgresql-server-${PGVER}*
|
||||||
|
chroot ${CHROOT} rc-update add postgresql-${PGVER} default
|
||||||
|
|
||||||
chroot ${CHROOT} getent passwd ${TP_USER} || \
|
chroot ${CHROOT} getent passwd ${TP_USER} || \
|
||||||
chroot ${CHROOT} useradd -c "Teamplayer Server" -U -d ${TP_HOME} \
|
chroot ${CHROOT} useradd -c "Teamplayer Server" -G postgres -U \
|
||||||
${TP_USER}
|
-d ${TP_HOME} ${TP_USER}
|
||||||
rm -rf ${TP_HOME}
|
rm -rf ${TP_HOME}
|
||||||
hg clone --pull ${HG_REPO} ${CHROOT}/${TP_HOME}
|
hg clone --pull ${HG_REPO} ${CHROOT}/${TP_HOME}
|
||||||
cp ${APPLIANCE}/teamplayer.wsgi ${CHROOT}${TP_HOME}/teamplayer.wsgi
|
|
||||||
cp ${APPLIANCE}/bash_profile ${CHROOT}${TP_HOME}/.bash_profile
|
cp ${APPLIANCE}/bash_profile ${CHROOT}${TP_HOME}/.bash_profile
|
||||||
${M4C} ${APPLIANCE}/settings_local.py > ${CHROOT}${TP_HOME}/web/settings_local.py
|
|
||||||
|
chroot ${CHROOT} mkdir -p /etc/teamplayer
|
||||||
|
${M4C} ${APPLIANCE}/teamplayer.wsgi > ${CHROOT}/etc/teamplayer/teamplayer.wsgi
|
||||||
|
${M4C} ${APPLIANCE}/settings_local.py > ${CHROOT}/etc/teamplayer/settings_local.py
|
||||||
|
|
||||||
mkdir -p ${CHROOT}${TP_HOME}/bin
|
mkdir -p ${CHROOT}${TP_HOME}/bin
|
||||||
${M4C} ${APPLIANCE}/start-teamplayer > ${CHROOT}${TP_HOME}/bin/start-teamplayer
|
${M4C} ${APPLIANCE}/start-teamplayer > ${CHROOT}${TP_HOME}/bin/start-teamplayer
|
||||||
chmod +x ${CHROOT}${TP_HOME}/bin/start-teamplayer
|
chmod +x ${CHROOT}${TP_HOME}/bin/start-teamplayer
|
||||||
|
@ -33,10 +43,12 @@ chroot ${CHROOT} ${INSTALL} -d -o ${TP_USER} -g ${TP_USER} ${TP_DB}/songs
|
||||||
chroot ${CHROOT} rm -rf ${TP_HOME}/web/media/songs
|
chroot ${CHROOT} rm -rf ${TP_HOME}/web/media/songs
|
||||||
chroot ${CHROOT} ln -s ${TP_DB}/songs ${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} ${INSTALL} -d -o ${TP_USER} -g ${TP_USER} ${TP_DB}/mpd
|
||||||
chroot ${CHROOT} chown -R ${TP_USER}:${TP_USER} ${TP_HOME}
|
chroot ${CHROOT} ${INSTALL} -d -o ${TP_USER} -g ${TP_USER} /var/log/teamplayer
|
||||||
${M4C} ${APPLIANCE}/10_teamplayer.conf > ${CHROOT}/etc/apache2/vhosts.d/10_teamplayer.conf
|
${M4C} ${APPLIANCE}/10_teamplayer.conf > ${CHROOT}/etc/apache2/vhosts.d/10_teamplayer.conf
|
||||||
cp ${APPLIANCE}/apache2.conf ${CHROOT}/etc/conf.d/apache2
|
cp ${APPLIANCE}/apache2.conf ${CHROOT}/etc/conf.d/apache2
|
||||||
${M4C} ${APPLIANCE}/local.start > ${CHROOT}/etc/conf.d/local.start
|
${M4C} ${APPLIANCE}/local.start > ${CHROOT}/etc/conf.d/local.start
|
||||||
${M4C} ${APPLIANCE}/local.stop > ${CHROOT}/etc/conf.d/local.stop
|
${M4C} ${APPLIANCE}/local.stop > ${CHROOT}/etc/conf.d/local.stop
|
||||||
sed -i 's/Gentoo Virtual Machine/TEAMPLAYER CONSOLE/' ${CHROOT}/etc/issue
|
cp ${APPLIANCE}/issue ${CHROOT}/etc/issue
|
||||||
|
|
||||||
chroot ${CHROOT} rc-update add apache2 default
|
chroot ${CHROOT} rc-update add apache2 default
|
||||||
|
chroot ${CHROOT} rc-update add ntpd default
|
||||||
|
|
|
@ -6,8 +6,10 @@ TP_STREAM_URL = '/stream.mp3'
|
||||||
`TP_HOME' = 'TP_HOME'
|
`TP_HOME' = 'TP_HOME'
|
||||||
DEBUG = False
|
DEBUG = False
|
||||||
TEMPLATE_DEBUG = DEBUG
|
TEMPLATE_DEBUG = DEBUG
|
||||||
DATABASE_ENGINE = 'sqlite3'
|
DATABASE_ENGINE = 'postgresql_psycopg2'
|
||||||
DATABASE_NAME = 'TP_DB/teamplayer.db'
|
DATABASE_NAME = 'teamplayer'
|
||||||
#SONG_STORAGE = 'TP_DB/songs'
|
DATABASE_HOST = ''
|
||||||
|
DATABASE_PASSWORD = ''
|
||||||
|
DATABASE_PORT = ''
|
||||||
TP_MPD_HOME = 'TP_DB/mpd'
|
TP_MPD_HOME = 'TP_DB/mpd'
|
||||||
TP_REPO_URL = '/repo/'
|
TP_REPO_URL = '/repo/'
|
||||||
|
|
|
@ -1,15 +1,18 @@
|
||||||
#!/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"
|
||||||
|
export PYTHONPATH
|
||||||
|
|
||||||
cd ~
|
cd ~
|
||||||
hg serve -p 8000 --prefix /repo/ > $HOME/hgserve.log 2>&1 &
|
hg serve -p 8000 --prefix /repo/ > /var/log/teamplayer/hgserve.log 2>&1 &
|
||||||
|
|
||||||
cd ~/web
|
cd ~/web
|
||||||
|
|
||||||
if [ ! -f "TP_DB/teamplayer.db" ] ; then
|
if [ ! -f "/etc/firstboot" ] ; then
|
||||||
python manage.py syncdb
|
python manage.py syncdb
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# spin!
|
# spin!
|
||||||
python manage.py spin --verbosity=2 $@ > "$HOME/teamplayer.log" 2>&1 &
|
python manage.py spin --verbosity=2 $@ > "/var/log/teamplayer/teamplayer.log" 2>&1 &
|
||||||
echo $! > "$HOME/tps.pid"
|
echo $! > "TP_DB/tps.pid"
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
# this should be run as the TP_USER user
|
# this should be run as the TP_USER user
|
||||||
|
|
||||||
cd ~/web
|
cd ~/web
|
||||||
|
PYTHONPATH="/etc/teamplayer:$PYTHONPATH"
|
||||||
|
|
||||||
[ -f "$HOME/tps.pid" ] && kill $(cat "$HOME/tps.pid")
|
export PYTHONPATH
|
||||||
python manage.py stop_stream > "$HOME/teamplayer.log"
|
|
||||||
|
[ -f "$HOME/tps.pid" ] && kill $(cat "TP_DB/tps.pid")
|
||||||
|
python manage.py stop_stream >> "/var/log/teamplayer/teamplayer.log"
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
path = os.path.dirname(__file__)
|
path = os.path.dirname(`__file__')
|
||||||
sys.path.append(path)
|
sys.path.append(path)
|
||||||
os.environ['DJANGO_SETTINGS_MODULE'] = 'web.settings'
|
sys.path.append('TP_HOME/web')
|
||||||
|
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
|
||||||
|
|
||||||
import django.core.handlers.wsgi
|
import django.core.handlers.wsgi
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
=dev-db/postgresql-server-8.4*
|
||||||
dev-python/django
|
dev-python/django
|
||||||
dev-python/python-mpd
|
dev-python/python-mpd
|
||||||
dev-vcs/mercurial
|
dev-vcs/mercurial
|
||||||
|
@ -5,5 +6,6 @@ media-libs/mutagen
|
||||||
media-sound/mpc
|
media-sound/mpc
|
||||||
media-sound/mpd
|
media-sound/mpd
|
||||||
net-misc/dhcpcd
|
net-misc/dhcpcd
|
||||||
|
net-misc/ntp
|
||||||
www-apache/mod_wsgi
|
www-apache/mod_wsgi
|
||||||
www-servers/apache
|
www-servers/apache
|
||||||
|
|
Loading…
Reference in New Issue