Merge pull request #30 from rackerlabs/jay/FixMakefsScript

Fixes and logging for makefs script
This commit is contained in:
Jason Faulkner 2014-01-22 15:26:45 -08:00
commit e25f5dd4ce

View File

@ -5,6 +5,10 @@
set -e set -e
log() {
echo "`basename $0`: $@"
}
usage() { usage() {
[[ -z "$1" ]] || echo -e "USAGE ERROR: $@\n" [[ -z "$1" ]] || echo -e "USAGE ERROR: $@\n"
echo "`basename $0`: CONFIGDRIVE_DIR IMAGEFILE DEVICE" echo "`basename $0`: CONFIGDRIVE_DIR IMAGEFILE DEVICE"
@ -24,11 +28,15 @@ DEVICE="$3"
# In production this will be replaced with secure erasing the drives # In production this will be replaced with secure erasing the drives
# For now we need to ensure there aren't any old (GPT) partitions on the drive # For now we need to ensure there aren't any old (GPT) partitions on the drive
log "Erasing existing mbr from ${DEVICE}"
dd if=/dev/zero of=$DEVICE bs=512 count=10 dd if=/dev/zero of=$DEVICE bs=512 count=10
# Converts image to raw and writes to device
log "Imaging $IMAGEFILE onto $DEVICE"
qemu-img convert -O raw $IMAGEFILE $DEVICE qemu-img convert -O raw $IMAGEFILE $DEVICE
# Create small partition at the end of the device # Create small partition at the end of the device
log "Adding configdrive partition to $DEVICE"
parted -a optimal -s -- $DEVICE mkpart primary ext2 -16MiB -0 parted -a optimal -s -- $DEVICE mkpart primary ext2 -16MiB -0
# Find partition we just created # Find partition we just created
@ -36,6 +44,7 @@ parted -a optimal -s -- $DEVICE mkpart primary ext2 -16MiB -0
ISO_PARTITION=`sfdisk --dump $DEVICE | grep -v ' 0,' | tail -n1 | awk '{print $1}'` ISO_PARTITION=`sfdisk --dump $DEVICE | grep -v ' 0,' | tail -n1 | awk '{print $1}'`
# This generates the ISO image of the config drive. # This generates the ISO image of the config drive.
log "Writing Configdrive contents in $CONFIGDRIVE_DIR to $ISO_PARTITION"
genisoimage \ genisoimage \
-o ${ISO_PARTITION} \ -o ${ISO_PARTITION} \
-ldots \ -ldots \
@ -48,3 +57,5 @@ genisoimage \
-r \ -r \
-V 'config-2' \ -V 'config-2' \
${CONFIGDRIVE_DIR} ${CONFIGDRIVE_DIR}
log "${DEVICE} imaged successfully!"