add build script to build virtual machine image for pan.do/ra
This commit is contained in:
parent
99528a73d4
commit
0350c0b122
5 changed files with 230 additions and 0 deletions
55
vm/README.txt
Normal file
55
vm/README.txt
Normal file
|
@ -0,0 +1,55 @@
|
|||
Create virtual disk of pan.do/ra
|
||||
|
||||
== ubuntu-vm-builder setup ==
|
||||
|
||||
due to https://bugs.launchpad.net/ubuntu/+source/vm-builder/+bug/676132
|
||||
we need to use maverick-proposed repository:
|
||||
|
||||
echo "deb http://archive.ubuntu.com/ubuntu/ maverick-proposed restricted main multiverse universe" > /etc/apt/sources.list.d/ubunt-proposed.list
|
||||
apt-get update
|
||||
apt-get -t maverick-proposed install ubuntu-vm-builder
|
||||
|
||||
|
||||
due to https://bugs.launchpad.net/vmbuilder/+bug/683614
|
||||
building vbox images does not work. install virtualbox_vm.py:
|
||||
sudo cp virtualbox_vm.py /usr/lib/python2.6/dist-packages/VMBuilder/plugins/virtualbox/vm.py
|
||||
|
||||
(or change vbox to kvm to build kvm image)
|
||||
|
||||
with that installed build image:
|
||||
|
||||
./build.sh
|
||||
|
||||
this will create a vdi image in pandora/
|
||||
|
||||
== VirtualBox Usage ==
|
||||
Now you can create a new VirtualBox machine, use vdi image as existing hard disk.
|
||||
Before starting up you have to adjust some settings:
|
||||
In System -> Processor enable PAE/NX
|
||||
In Storage remove disk from SATA Controller
|
||||
add disk to IDE Controler and enable "Use host I/O cache"
|
||||
|
||||
In Network -> Adpater 1 set to Bridged Adapter with your connected controller
|
||||
|
||||
== Use for development ==
|
||||
Login via ssh or in terminal as pandora with password pandora
|
||||
|
||||
Adjust your bzr configuration with bzr whoami:
|
||||
bzr whoami "Pando the Panda <pan.do@pan.do>"
|
||||
|
||||
Pan.do/ra is installed in /srv/pandora and is served with nginx on http://pandora.local
|
||||
|
||||
|
||||
== Update ==
|
||||
to get the latest version of pan.do/ra
|
||||
cd /srv/pandora
|
||||
bzr pull
|
||||
cd static/oxjs
|
||||
bzr pull
|
||||
|
||||
you might have to adjust the database at this point. now restart pandora daemons
|
||||
|
||||
service pandora restart
|
||||
service pandora-tasks restart
|
||||
service pandora-encoding restart
|
||||
|
45
vm/build.sh
Executable file
45
vm/build.sh
Executable file
|
@ -0,0 +1,45 @@
|
|||
#!/bin/sh
|
||||
base=$(pwd)
|
||||
sudo vmbuilder vbox ubuntu --suite=maverick \
|
||||
--verbose --debug \
|
||||
--arch i386 \
|
||||
--dest $base/pandora \
|
||||
--hostname pandora \
|
||||
--swapsize 512 \
|
||||
--rootsize 8192 \
|
||||
--user pandora \
|
||||
--pass pandora \
|
||||
--components main,universe,multiverse \
|
||||
--ppa j/pandora \
|
||||
--ppa gstreamer-developers/ppa \
|
||||
--addpkg openssh-server \
|
||||
--addpkg acpid \
|
||||
--addpkg vim \
|
||||
--addpkg wget \
|
||||
--addpkg pwgen \
|
||||
--addpkg nginx \
|
||||
--addpkg rabbitmq-server \
|
||||
--addpkg bzr \
|
||||
--addpkg git \
|
||||
--addpkg subversion \
|
||||
--addpkg mercurial \
|
||||
--addpkg avahi-daemon \
|
||||
--addpkg python-setuptools \
|
||||
--addpkg python-pip \
|
||||
--addpkg python-virtualenv \
|
||||
--addpkg ipython \
|
||||
--addpkg python-imaging \
|
||||
--addpkg python-dev \
|
||||
--addpkg python-imaging \
|
||||
--addpkg python-numpy \
|
||||
--addpkg python-psycopg2 \
|
||||
--addpkg python-simplejson \
|
||||
--addpkg python-transmissionrpc \
|
||||
--addpkg transmission-daemon \
|
||||
--addpkg oxtimeline \
|
||||
--addpkg oxframe \
|
||||
--addpkg mkvtoolnix \
|
||||
--execscript=$base/install.sh \
|
||||
--firstboot=$base/firstboot.sh
|
||||
|
||||
#kvm-img convert -O vdi pandora/*.qcow2 pandora.vdi
|
54
vm/firstboot.sh
Executable file
54
vm/firstboot.sh
Executable file
|
@ -0,0 +1,54 @@
|
|||
#!/bin/sh
|
||||
#ffmpeg
|
||||
wget http://firefogg.org/nightly/ffmpeg.linux -O /usr/local/bin/ffmpeg
|
||||
chmod 755 /usr/local/bin/ffmpeg
|
||||
|
||||
wget http://firefogg.org/nightly/ffmpeg2theora.linux -O /usr/local/bin/ffmpeg2theora
|
||||
chmod 755 /usr/local/bin/ffmpeg2theora
|
||||
|
||||
#postgresql
|
||||
apt-get -y install postgresql
|
||||
sudo -u postgres createuser -S -D -R pandora
|
||||
sudo -u postgres createdb -O pandora pandora
|
||||
|
||||
#do not start systemwide transmission-daemon
|
||||
/etc/init.d/transmission-daemon stop
|
||||
sed -i "s/ENABLE_DAEMON=1/ENABLE_DAEMON=0/g" /etc/default/transmission-daemon
|
||||
|
||||
#rabbitmq
|
||||
RABBITPWD=$(pwgen -n 16 -1)
|
||||
rabbitmqctl add_user pandora $RABBITPWD
|
||||
rabbitmqctl add_vhost /pandora
|
||||
rabbitmqctl set_permissions -p /pandora pandora ".*" ".*" ".*"
|
||||
|
||||
#pandora
|
||||
cat > /srv/pandora/pandora/local_settings.py << EOF
|
||||
DATABASE_ENGINE = 'postgresql_psycopg2'
|
||||
DATABASE_NAME = 'pandora'
|
||||
DATABASE_USER = 'pandora'
|
||||
|
||||
POSTER_SERVICES=['http://data.0xdb.org/poster/']
|
||||
|
||||
BROKER_PASSWORD = "$RABBITPWD"
|
||||
|
||||
XACCELREDIRECT = True
|
||||
EOF
|
||||
|
||||
cd /srv/pandora/pandora
|
||||
sudo -u pandora python manage.py syncdb --noinput
|
||||
sudo -u pandora python manage.py loaddata fixtures/0xdb_properties.json
|
||||
echo "UPDATE django_site SET domain = 'pandora.local', name = 'pandora.local' WHERE 1=1;" | sudo -u pandora python manage.py dbshell
|
||||
|
||||
mkdir /srv/pandora/data
|
||||
chown -R pandora:pandora /srv/pandora
|
||||
|
||||
cp /srv/pandora/etc/init/* /etc/init/
|
||||
|
||||
service pandora-encoding start
|
||||
service pandora-tasks start
|
||||
service pandora start
|
||||
|
||||
#nginx
|
||||
sed "s/__PREFIX__/\/srv\/pandora/g" "/srv/pandora/nginx/vhost.in" > "/etc/nginx/sites-available/default"
|
||||
service nginx restart
|
||||
|
7
vm/install.sh
Executable file
7
vm/install.sh
Executable file
|
@ -0,0 +1,7 @@
|
|||
#!/bin/sh
|
||||
CH="chroot $1"
|
||||
$CH bzr branch http://code.0x2620.org/pandora /srv/pandora
|
||||
$CH bzr branch http://code.0x2620.org/oxjs /srv/pandora/static/oxjs
|
||||
$CH virtualenv /srv/pandora
|
||||
$CH pip -E /srv/pandora install -r /srv/pandora/requirements.txt
|
||||
|
69
vm/virtualbox_vm.py
Normal file
69
vm/virtualbox_vm.py
Normal file
|
@ -0,0 +1,69 @@
|
|||
#
|
||||
# Uncomplicated VM Builder
|
||||
# Copyright (C) 2007-2009 Canonical Ltd.
|
||||
#
|
||||
# See AUTHORS for list of contributors
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License version 3, as
|
||||
# published by the Free Software Foundation.
|
||||
#
|
||||
# This program 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.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
import os
|
||||
import os.path
|
||||
import stat
|
||||
import VMBuilder
|
||||
from VMBuilder import register_hypervisor, Hypervisor
|
||||
from VMBuilder.disk import vbox_manager_path
|
||||
import VMBuilder.hypervisor
|
||||
|
||||
class VirtualBox(Hypervisor):
|
||||
preferred_storage = VMBuilder.hypervisor.STORAGE_DISK_IMAGE
|
||||
needs_bootloader = True
|
||||
name = 'VirtualBox'
|
||||
arg = 'vbox'
|
||||
|
||||
def register_options(self):
|
||||
group = self.setting_group('VM settings')
|
||||
group.add_setting('mem', extra_args=['-m'], type='int', default=128, help='Assign MEM megabytes of memory to the guest vm. [default: %default]')
|
||||
group.add_setting('cpus', type='int', default=1, help='Assign NUM cpus to the guest vm. [default: %default]')
|
||||
group.add_setting('vbox-disk-format', metavar='FORMAT', default='vdi', help='Desired disk format. Valid options are: vdi vmdk. [default: %default]')
|
||||
|
||||
def convert(self, disks, destdir):
|
||||
self.imgs = []
|
||||
for disk in disks:
|
||||
img_path = disk.convert(destdir, self.context.get_setting('vbox-disk-format'))
|
||||
self.imgs.append(img_path)
|
||||
self.call_hooks('fix_ownership', img_path)
|
||||
|
||||
def deploy(self, destdir):
|
||||
hostname = self.context.distro.get_setting('hostname')
|
||||
mac = self.context.get_setting('mac')
|
||||
ip = self.context.get_setting('ip')
|
||||
vm_deploy = VMBuilder.util.render_template('virtualbox',
|
||||
self.context,
|
||||
'vm_deploy_script',
|
||||
{ 'os_type' : self.context.distro.__class__.__name__,
|
||||
'vm_name' : hostname,
|
||||
'vm_disks' : self.imgs,
|
||||
'mac' : mac,
|
||||
'ip' : ip,
|
||||
'memory' : self.context.get_setting('mem'),
|
||||
'cpus' : self.context.get_setting('cpus') })
|
||||
|
||||
script_file = '%s/deploy_%s.sh' % (destdir, hostname)
|
||||
fp = open(script_file, 'w')
|
||||
fp.write(vm_deploy)
|
||||
fp.close()
|
||||
os.chmod(script_file, stat.S_IRWXU | stat.S_IRGRP | stat.S_IROTH)
|
||||
self.call_hooks('fix_ownership', script_file)
|
||||
|
||||
register_hypervisor(VirtualBox)
|
Loading…
Reference in a new issue