pandora/vm/build.sh

57 lines
1.4 KiB
Bash
Raw Normal View History

2016-03-05 13:06:39 +00:00
#!/bin/bash
cd "`dirname "$0"`"
BASE=`pwd`
VERSION=`cd ..;git rev-list HEAD --count`
TARGET=${BASE}/pandora-r${VERSION}.vdi
SIZE=1T
RELEASE=trusty
2013-07-03 14:25:57 +00:00
2016-03-05 13:06:39 +00:00
if [ "$MIRROR" = "" ]; then
MIRROR="--mirror http://archive.ubuntu.com/ubuntu/"
fi
2013-07-03 14:25:57 +00:00
2016-03-15 22:04:53 +00:00
if [ -e "$BASE/settings.sh" ]; then
. "$BASE/settings.sh"
fi
2016-03-05 13:06:39 +00:00
if [ $(id -u) -ne 0 ]; then
echo "you need to run $0 as root"
exit 1
fi
2013-07-03 14:25:57 +00:00
2016-03-05 13:06:39 +00:00
# make sure ubuntu-archive-keyring is installed
test -e /usr/share/keyrings/ubuntu-archive-keyring.gpg || apt-get install ubuntu-archive-keyring
2013-07-03 14:25:57 +00:00
2016-03-15 22:04:53 +00:00
vmdebootstrap=`vmdebootstrap --version`
if [[ $vmdebootstrap == "1.4" ]]; then
EXTRA=--no-systemd-networkd
fi
2016-03-05 13:06:39 +00:00
vmdebootstrap \
--image ${TARGET}.img \
--size ${SIZE} \
--sparse \
--distribution=${RELEASE} \
$MIRROR \
2016-03-15 22:04:53 +00:00
$EXTRA \
2016-03-05 13:06:39 +00:00
--enable-dhcp \
--no-serial-console \
--no-kernel \
--package "linux-image-generic" \
--package "avahi-daemon" \
--package "ssh" \
--mbr \
--grub \
--sudo \
--lock-root-password \
--user pandora/pandora \
--hostname pandora \
2016-03-05 13:06:39 +00:00
--customize "${BASE}/prepare.sh" \
--log ${TARGET}.log --log-level debug --verbose
echo "Installing pan.do/ra in VM"
qemu-system-x86_64 -enable-kvm -name pandora -m 1024 -drive "format=raw,file=${TARGET}.img" -vnc :2
rm -rf "${TARGET}"
/usr/bin/VBoxManage convertfromraw -format VDI "${TARGET}.img" "${TARGET}"
rm "${TARGET}.img"