diff --git a/README b/README index 2cbeafde7..8ab9846b4 100644 --- a/README +++ b/README @@ -15,7 +15,8 @@ To run pan.do/ra you need to install and setup: additinal video packages -* Installing required packages +=== Installing required packages === + 1) add pandora ppa to get all packages in the required version apt-get install software-properties-common @@ -31,7 +32,8 @@ To run pan.do/ra you need to install and setup: poppler-utils mkvtoolnix gpac imagemagick \ python-ox oxframe ffmpeg -* Prepare Environment +=== Prepare Environment === + 1) add pandora user and set permissions adduser pandora --disabled-login --disabled-password @@ -50,7 +52,8 @@ Important: "use_your_own" is a password and you have to use the same value here rabbitmqctl set_permissions -p /pandora pandora ".*" ".*" ".*" -* Install Pan.do/ra +=== Install Pan.do/ra === + 1) Get code from bazzar cd /srv/ bzr branch http://code.0x2620.org/pandora pandora @@ -66,7 +69,7 @@ Important: "use_your_own" is a password and you have to use the same value here 2) create local_settings.py and config.jsonc -1) create file /srv/pandora/pandora/local_settings.py with the following content: +2.1) create file /srv/pandora/pandora/local_settings.py with the following content: DATABASES = { 'default': { 'NAME': 'pandora', @@ -84,7 +87,7 @@ Important: "use_your_own" is a password and you have to use the same value here #with nginx X-Accel-Redirect set this to True XACCELREDIRECT = True -2) create config.jsonc +2.2) create config.jsonc config.jsonc holds the configuration for your site. To start you can copy /srv/pandora/pandora/config.pandora.jsonc to /srv/pandora/pandora/config.jsonc but have a look at @@ -94,15 +97,7 @@ Important: "use_your_own" is a password and you have to use the same value here 3) initialize database su pandora cd /srv/pandora/pandora - ./manage.py syncdb --noinput - ./manage.py migrate item - ./manage.py migrate annotation - ./manage.py migrate - ./manage.py sqlfindindex - ./manage.py sync_itemsort - ./manage.py collectstatic -l --noinput - ./manage.py update_static - ./manage.py compile_pyc + ./manage.py init_db 4) install init scripts and start daemons cp /srv/pandora/etc/init/*.conf /etc/init/ @@ -136,7 +131,7 @@ b) apache2 (if you need it for other sites on the same server) Now you can open pandora in your browser, the first user to sign up will become admin. -=== Updating === +== Updating == To update a pandora installation get the latest version from bzr by running su pandora cd /srv/pandora @@ -149,7 +144,7 @@ to update your database run: cd /srv/pandora ./update.py db -=== Development === +== Development == in one terminal: ./manage.py runserver 2620 @@ -158,5 +153,5 @@ to update your database run: now you can access your local pandora instace at http://127.0.0.1:8000/ - we use virtual machines for development, you can get a vm from our site + we use virtual machines/lxc for development, you can get a vm from our site or use the script in vm/build.sh to create one. diff --git a/pandora/app/management/commands/init_db.py b/pandora/app/management/commands/init_db.py new file mode 100644 index 000000000..63be34edf --- /dev/null +++ b/pandora/app/management/commands/init_db.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- +# vi:si:et:sw=4:sts=4:ts=4 +from django.core.management.base import BaseCommand +from django.conf import settings +import os +import subprocess +import sys + +def run(cmd): + r = subprocess.call(cmd) + if r != 0: + sys.exit(r) + +class Command(BaseCommand): + """ + """ + help = 'initialize pan.do/ra db' + args = '' + + def handle(self, **options): + manage_py = sys.argv[0] + for cmd in [ + [manage_py, 'syncdb', '--noinput'], + [manage_py, 'migrate', 'item'], + [manage_py, 'migrate', 'annotation'], + [manage_py, 'migrate'], + [manage_py, 'sqlfindindex'], + [manage_py, 'sync_itemsort'], + [manage_py, 'update_static'], + [manage_py, 'compile_pyc'], + ]: + run(cmd) + if not os.path.exists(os.path.join(settings.STATIC_ROOT, 'admin')): + run([manage_py, 'collectstatic', '-l', '--noinput']) diff --git a/vm/firstboot.sh b/vm/firstboot.sh index 03676f622..94f0aa101 100755 --- a/vm/firstboot.sh +++ b/vm/firstboot.sh @@ -110,24 +110,17 @@ XACCELREDIRECT = True DEBUG = False TEMPLATE_DEBUG = DEBUG JSON_DEBUG = False +DB_GIN_TRGM = True EOF MANAGE="sudo -H -u pandora python manage.py" cd /srv/pandora/pandora -$MANAGE syncdb --noinput -$MANAGE migrate item -$MANAGE migrate annotation -$MANAGE migrate -echo "DB_GIN_TRGM = True" >> /srv/pandora/pandora/local_settings.py -$MANAGE sqlfindindex -$MANAGE sync_itemsort +$MANAGE init_db echo "UPDATE django_site SET domain = '$HOST.local', name = '$HOST.local' WHERE 1=1;" | $MANAGE dbshell mkdir /srv/pandora/data chown -R pandora:pandora /srv/pandora -$MANAGE update_static -$MANAGE collectstatic -l --noinput if [ "$SYSTEMD" == "yes" ]; then cp /srv/pandora/etc/systemd/*.service /lib/systemd/system/