This script will automate the extraction of multiple FreeBSD ISO images and extract them for using as PXE boot install images.
#!/usr/local/bin/bash #Copyright (C) 2009, Tom Judge # ---------------------------------------------------------------------------- # "THE BEER-WARE LICENSE" (Revision 42): # <tom@tomjudge.com> wrote this file. As long as you retain this notice you # can do whatever you want with this stuff. If we meet some day, and you think # this stuff is worth it, you can buy me a beer in return Tom Judge. # ---------------------------------------------------------------------------- ## Base of where the images are to be extracted to DATADIR=$1 ## Directory containing ISO's to be extracted ISODIR=$2 ## Mountpoint to use during extraction MOUNTPOINT=$3 echo "Source ISO's DIR: ${ISODIR}" echo "Destination DIR: ${DATADIR}" echo "ISO Mount Point: ${MOUNTPOINT}" echo for ISO in `ls -1 ${ISODIR}/*.iso`; do echo echo "Starting Processing of: ${ISO}" echo ## Setup Vars used for processing BASENAME=`basename -s .iso ${ISO}` RELEASE=`echo ${BASENAME} | cut -d - -f1` ARCH=`echo ${BASENAME} | cut -d - -f3` RELEASEBASE=${DATADIR}/${RELEASE}/${ARCH} echo "FreeBSD Release: ${RELEASE} - Architechture: ${ARCH}" echo "Creating install base dir: ${RELEASEBASE} and directory structure." mkdir -p ${RELEASEBASE} mkdir ${RELEASEBASE}/install mkdir ${RELEASEBASE}/pxe echo -n "Creating ISO MD Interface: " MDDEV=`mdconfig -a -t vnode -f ${ISO}` echo "Mounting ${MDDEV} on ${MOUNTPOINT}" mount -t cd9660 /dev/${MDDEV} ${MOUNTPOINT} echo "Rsyncing iso into: ${RELEASEBASE}/install" cd ${MOUNTPOINT} rsync -a . ${RELEASEBASE}/install/ cd - echo "Unmounting ${MOUNTPOINT}" umount ${MOUNTPOINT} echo "Destroying ISO MD Interface: ${MDDEV}" mdconfig -d -u ${MDDEV} ## Uncompress the MFS root image so that loader does not choke echo "Uncompressing mfsroot" cd ${RELEASEBASE}/install/boot gunzip -f mfsroot.gz echo "Copying boot into PXE Root" cd ${RELEASEBASE}/install/boot cp boot boot0 boot1 boot2 cdboot device.hints gptboot loader pmbr pxeboot mfsroot ${RELEASEBASE}/pxe/boot cp -r kernel ${RELEASEBASE}/pxe/boot cp -r firmware ${RELEASEBASE}/pxe/boot cp -r modules ${RELEASEBASE}/pxe/boot cp -r zfs ${RELEASEBASE}/pxe/boot cd - echo echo "Finished Processing of: ${ISO}" echo done