#!/bin/bash -

# Create kickstart
cat << EOF > fedora.ks
install
text
reboot
lang en_US.UTF-8
keyboard us
network --bootproto dhcp
rootpw testpwd
firewall --enabled --ssh
selinux --enforcing
timezone --utc America/New_York
bootloader --location=mbr --append="console=tty0 console=ttyS0,115200 rd_NO_PLYMOUTH"
zerombr
clearpart --all --initlabel
autopart --type=plain

%packages
@core
%end
EOF

# Create disk image
DIMG=/var/lib/libvirt/images/F22VM-TEST.qcow2
qemu-img create -f qcow2 -o preallocation=metadata $DIMG 9G

# Create the guest
virt-install --connect=qemu:///system \
    --name=rawhide-vm \
    --ram=2048 \
    --cpu=host --vcpus=2 \
    --os-type=linux --os-variant=fedora21 \
    --initrd-inject=./fedora.ks \
    --extra-args="ks=file:/fedora.ks console=tty0 console=ttyS0,115200" \
    --disk path=$DIMG,format=qcow2,cache=writeback \
    --serial pty \
    --location http://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/x86_64/os/ \
    --nographics \
    --noreboot
