pandora/vm/build.sh
2017-11-07 23:10:03 +01:00

32 lines
843 B
Bash
Executable file

#!/bin/bash
# apt-get install kvm cloud-utils qemu-utils curl
BASE=`pwd`
VERSION=`cd ..;git rev-list HEAD --count`
TARGET=${BASE}/pandora-r${VERSION}.vdi
img=xenial-server-cloudimg-amd64-disk1.img
if [ ! -e $img ]; then
echo downloading $img
curl -s -O https://cloud-images.ubuntu.com/xenial/current/$img
fi
echo preparing ${TARGET}.img
cp -a $img ${TARGET}.img
cloud-localds seed.img cloud-config
qemu-img resize ${TARGET}.img +998G
echo boot image and install pandora
kvm -m 1024 \
-smp 4 \
-cdrom seed.img \
-device e1000,netdev=user.0 \
-netdev user,id=user.0,hostfwd=tcp::5555-:22,hostfwd=tcp::2620-:80 \
-drive file=${TARGET}.img,if=virtio,cache=writeback,index=0 \
-vnc :2
echo convert qcow2 to vdi
rm -rf "${TARGET}"
qemu-img convert -f qcow2 -O vdi "${TARGET}.img" "${TARGET}"
rm "${TARGET}.img"