pandora/vm/build.sh

33 lines
837 B
Bash
Raw Permalink Normal View History

2016-03-05 13:06:39 +00:00
#!/bin/bash
2017-03-17 00:21:24 +00:00
# apt-get install kvm cloud-utils qemu-utils curl
2016-03-05 13:06:39 +00:00
BASE=`pwd`
VERSION=`cd ..;git rev-list HEAD --count`
TARGET=${BASE}/pandora-r${VERSION}.vdi
2016-03-15 22:04:53 +00:00
2019-07-19 10:21:45 +00:00
img=bionic-server-cloudimg-amd64.img
2013-07-03 14:25:57 +00:00
2017-11-07 22:10:03 +00:00
if [ ! -e $img ]; then
echo downloading $img
2019-07-19 10:21:45 +00:00
curl -s -O https://cloud-images.ubuntu.com/bionic/current/$img
2017-11-07 22:10:03 +00:00
fi
echo preparing ${TARGET}.img
cp -a $img ${TARGET}.img
2013-07-03 14:25:57 +00:00
2017-03-17 00:21:24 +00:00
cloud-localds seed.img cloud-config
qemu-img resize ${TARGET}.img +998G
2016-03-15 22:04:53 +00:00
2017-03-17 00:21:24 +00:00
echo boot image and install pandora
kvm -m 1024 \
2019-07-19 10:55:05 +00:00
-smp 2 \
2017-03-17 00:21:24 +00:00
-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
2016-03-05 13:06:39 +00:00
2017-03-17 00:21:24 +00:00
echo convert qcow2 to vdi
2016-03-05 13:06:39 +00:00
rm -rf "${TARGET}"
2017-03-17 00:21:24 +00:00
qemu-img convert -f qcow2 -O vdi "${TARGET}.img" "${TARGET}"
2016-03-05 13:06:39 +00:00
rm "${TARGET}.img"