#!/bin/sh -e
#
# make a virtual floppy disk with sysprep.inf at its root.
#
# Copyright 2011 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
#
# Refer to the README and COPYING files for full details of the license
#

if [ $# -ne 1 ]; then
   echo usage: $0 /path/to.vfd
   echo
   echo create a floppy image and copy stdin into sysprep.inf.
   exit 1
fi

FLOPPY_NAME="$1"
/sbin/mkfs.msdos -C "$FLOPPY_NAME" 1440
/bin/chown vdsm:qemu "$FLOPPY_NAME"
/bin/chmod 0440 "$FLOPPY_NAME"
mntpoint=`mktemp -d`
mount -o loop,uid=`id -u`,gid=`id -g` "$FLOPPY_DIR/$FLOPPY_NAME" $mntpoint

/bin/cat > $mntpoint/sysprep.inf

umount $mntpoint
rmdir $mntpoint

