cleanup vm build script, fixes #1591

This commit is contained in:
j 2013-07-03 16:25:57 +02:00
parent 59f2e8da01
commit 3d7ad8b70a
5 changed files with 78 additions and 103 deletions

View file

@ -1,31 +1,33 @@
Create virtual disk of pan.do/ra Create virtual disk of pan.do/ra
== ubuntu-vm-builder setup == == Preparations ==
on ubuntu 11.10 you need to install python-vm-builder Pan.do/ra VM scripts use python-vm-builder,
its available in ubuntu 12.04 and later
apt-get install python-vm-builder apt-get install python-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) == Building ==
with that installed build image: You can configure some of the arguments in build.sh once done run:
./build.sh ./build.sh
this will create a vdi image in pandora/ this will create a vdi image in pandora/
== VirtualBox Usage == == VirtualBox Usage ==
Now you can create a new VirtualBox machine, Now you can create a new VirtualBox machine,
select Linux/Ubuntu and use vdi image as existing hard disk. select Linux/Ubuntu and use vdi image as existing hard disk.
Before starting up: Before starting up:
In Network -> Adpater 1 set to Bridged Adapter with your connected controller In Network -> Adpater 1 set to Bridged Adapter with your connected controller
== Use for development == == Use for development ==
Login via ssh or in terminal as pandora with password pandora Login via ssh or in terminal as pandora with password pandora
ssh pandora@pandora.local ssh pandora@pandora.local
@ -37,13 +39,8 @@ Pan.do/ra is installed in /srv/pandora and is served with nginx on http://pandor
== Update == == Update ==
to get the latest version of pan.do/ra to get the latest version of pan.do/ra
cd /srv/pandora cd /srv/pandora
./update.sh ./update.py
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

View file

@ -1,15 +1,30 @@
#!/bin/sh #!/bin/sh
size=1048576 #in MB
arch=amd64 #i368 or amd64
password=pandora
hypervisor=vbox #vbox or kvm
extra=""
#make available as pandora.local
extra="--addpkg avahi-daemon"
#to create and include in libvirt:
#hypervisor=kvm
#extra="--libvirt qemu:///system"
base=$(pwd) base=$(pwd)
sudo vmbuilder vbox ubuntu --suite=precise \ sudo vmbuilder vbox ubuntu --suite=precise \
--verbose --debug \ --verbose --debug \
--arch i386 \ --arch $arch \
--flavour generic \ --flavour generic \
--dest $base/pandora \ --dest $base/pandora \
--hostname pandora \ --hostname pandora \
--swapsize 512 \ --swapsize 512 \
--rootsize 1048576 \ --rootsize $size \
--user pandora \ --user pandora \
--pass pandora \ --pass $password \
--components main,universe,multiverse \ --components main,universe,multiverse \
--ppa j/pandora \ --ppa j/pandora \
--addpkg openssh-server \ --addpkg openssh-server \
@ -23,7 +38,6 @@ sudo vmbuilder vbox ubuntu --suite=precise \
--addpkg git \ --addpkg git \
--addpkg subversion \ --addpkg subversion \
--addpkg mercurial \ --addpkg mercurial \
--addpkg avahi-daemon \
--addpkg update-manager-core \ --addpkg update-manager-core \
--addpkg python-software-properties \ --addpkg python-software-properties \
--addpkg python-setuptools \ --addpkg python-setuptools \
@ -47,6 +61,5 @@ sudo vmbuilder vbox ubuntu --suite=precise \
--addpkg libav-tools \ --addpkg libav-tools \
--addpkg ffmpeg2theora \ --addpkg ffmpeg2theora \
--addpkg imagemagick \ --addpkg imagemagick \
--execscript=$base/install.sh \ --firstboot=$base/firstboot.sh \
--firstboot=$base/firstboot.sh $extra

View file

@ -2,7 +2,7 @@
#fails in bootstrap #fails in bootstrap
apt-get -y install ipython ntp apt-get -y install ipython ntp
add-apt-repository ppa:j/pandora add-apt-repository -y ppa:j/pandora
#postgresql #postgresql
apt-get -y install postgresql postgresql-contrib apt-get -y install postgresql postgresql-contrib
@ -17,6 +17,11 @@ rabbitmqctl add_vhost /pandora
rabbitmqctl set_permissions -p /pandora pandora ".*" ".*" ".*" rabbitmqctl set_permissions -p /pandora pandora ".*" ".*" ".*"
#pandora #pandora
bzr branch http://code.0x2620.org/pandora /srv/pandora
bzr branch http://code.0x2620.org/oxjs /srv/pandora/static/oxjs
virtualenv --system-site-packages /srv/pandora
/srv/pandora/bin/pip install -r /srv/pandora/requirements.txt
HOST=$(hostname -s) HOST=$(hostname -s)
HOST_CONFIG="/srv/pandora/pandora/config.$HOST.jsonc" HOST_CONFIG="/srv/pandora/pandora/config.$HOST.jsonc"
SITE_CONFIG="/srv/pandora/pandora/config.jsonc" SITE_CONFIG="/srv/pandora/pandora/config.jsonc"
@ -56,13 +61,10 @@ $MANAGE collectstatic -l --noinput
cp /srv/pandora/etc/init/* /etc/init/ cp /srv/pandora/etc/init/* /etc/init/
service pandora-cron start /srv/pandora/ctl start
service pandora-encoding start
service pandora-tasks start
service pandora start
#logrotate #logrotate
cp "/srv/pandora/etc/logrotate.d/pandora" "/etc/logroated.d/pandora" cp "/srv/pandora/etc/logrotate.d/pandora" "/etc/logrotate.d/pandora"
#nginx #nginx
cp "/srv/pandora/etc/nginx/pandora" "/etc/nginx/sites-available/default" cp "/srv/pandora/etc/nginx/pandora" "/etc/nginx/sites-available/default"
@ -88,6 +90,7 @@ done
echo echo
EOF EOF
chmod +x /usr/local/bin/genissue chmod +x /usr/local/bin/genissue
/usr/local/bin/genissue > /etc/issue
cat > /etc/rc.local << EOF cat > /etc/rc.local << EOF
#!/bin/sh -e #!/bin/sh -e
@ -101,3 +104,41 @@ rm -f /etc/udev/rules.d/70-persistent-net.rules
/usr/local/bin/genissue > /etc/issue /usr/local/bin/genissue > /etc/issue
EOF EOF
chmod +x /etc/rc.local chmod +x /etc/rc.local
cat > /home/pandora/.vimrc <<EOF
set nocompatible
set encoding=utf-8
set showcmd
set autochdir
set tabstop=4 shiftwidth=4
set expandtab
set si
set sw=4
set sts=4
set backspace=indent,eol,start
set hlsearch
set incsearch
set ignorecase
set smartcase
set modeline
nmap <C-V> "+gP
imap <C-V> <ESC><C-V>i
vmap <C-C> "+y
filetype plugin indent on
syntax on
nmap <C-H> :tabprev<CR>
nmap <C-L> :tabnext<CR>
hi SpellBad ctermbg=0
nnoremap <F2> :set invpaste paste?<CR>
set pastetoggle=<F2>
set showmode
EOF

View file

@ -1,7 +0,0 @@
#!/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 --system-site-packages /srv/pandora
$CH /srv/pandora/bin/pip install -r /srv/pandora/requirements.txt

View file

@ -1,69 +0,0 @@
#
# 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)