Skip to content
Switch branches/tags
Go to file
Cannot retrieve contributors at this time
executable file 58 lines (48 sloc) 1.82 KB
if ! [ $# -eq 1 ]; then
echo "Usage: $0 <fedora-cloud-image.qcow2>"
exit 1
# Resize the disk? By default it's a 2GB HDD
echo "$(date -R) Cleaniung up..."
rm -rf $IMAGE
cp $1 $IMAGE
echo "$(date -R) Modifying the image..."
guestfish -a $IMAGE -i --network --selinux > image.log <<_EOF_
# Load selinux policy
sh "/usr/sbin/load_policy -i"
# Remove cloud-init
sh "yum -y remove cloud-init"
# Update the system
sh "yum -y update"
# Install Docker and Open vSwitch and bridge-utils and DHCPd
sh "yum -y install docker-io openvswitch bridge-utils dhcp"
# Disable the docker0 bridge creation
sh "echo -e '.include /usr/lib/systemd/system/docker.service\n\n[Service]\nExecStart=\nExecStart=/usr/bin/docker -d -b=none' > /etc/systemd/system/docker.service"
# Run Docker on boot
ln-s /usr/lib/systemd/system/docker.service /etc/systemd/system/
# Run Open vSwitch on boot
ln-s /usr/lib/systemd/system/openvswitch.service /etc/systemd/system/
# Create fedora user
sh "useradd -m fedora"
# Reset the fedora user password
sh "echo 'fedora:fedora' | chpasswd"
# Give the fedora users administrative rights
sh "echo 'fedora ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/fedora"
# Add the fedora user to docker group
sh "usermod -a -G docker fedora"
# Upload the network configuration script
upload /home/fedora/
sh "chmod +x /home/fedora/"
if $RESIZE_DISK; then
echo "$(date -R) Resizing the disk..."
virt-filesystems --long -h --all -a $IMAGE >> image.log
qemu-img create -f qcow2 -o preallocation=metadata $ $DISK_SIZE >> image.log
virt-resize --quiet --expand /dev/sda1 $IMAGE $ >> image.log
mv $ $IMAGE
echo "$(date -R) Image '$IMAGE' created!"