mkisofw.sh

This script is based on the work of Brad Skiff and should provide everything you need to download, modify and build an iso image of the floppyfw. If you find any bugs and know how to fix them, please feel free to click 'edit' and fix the script. If you have any questions about how this works or you just want to chat, please feel free to email me, fmrose@ncsu.edu

To get started copy and paste this script into a file (called mkisofw.sh for example). Edit the configuration section to your liking, the defaults should mostly work except for the CDRECOPT setting, that will most likely need to be modified. Then as root

chmod u+x mkisofw.sh
./mkisofw.sh

Begin copying here

#! /bin/bash
 
######### Begin Configuration ##########
# Executables
WGET=/usr/bin/wget
MKISOFS=/usr/bin/mkisofs
CDRECORD=/usr/bin/cdrecord
 
# URL of the floppyfw iso image you wish to use/get.
ISO_URL=http://www.zelow.no/floppyfw/download/floppyfw-3.0/floppyfw-3.0.5/floppyfw-3.0.5.iso
 
# Volume label for the cd you will burn, just naming the disc
CDNAME=cdfw-3.0.5
 
# Directory name for temporary placement of files to be modified.
EDITDIR_NAME=isoloop
 
# The working directory for all actions
BASEDIR=/tmp
 
# The loopback mount point
MOUNTDIR=/mnt/loop
 
# Directory where a master copy of all config files are kept.
# This directory can contain a complete list, or any part thereof,
# of the iso image file hierarchy. 
MASTERDIR=/root/cdfw
 
# List of configuration files that should be maintained by you.
CONFFILES="config ethers firewall.ini network.ini"
 
# The name of the cd iso image that will be generated.
IMG_NAME=cdfw.iso
 
# If you are burning a one time image to a CDR,
# you should NOT blank the disk, change to disable blanking
isCDR=no
# isCDR=Yes
 
# Option string for cdrecord, "cdrecord --scanbus" may be useful
# or for kernel 2.6 dev=/dev/hdc for atapi drives
CDRECOPT="dev=0,6,0 speed=4  -v -s -data"
 
######### Begin Initialization ##########
 
IMG=`basename ${ISO_URL}`
EDITDIR=${BASEDIR}/${EDITDIR_NAME}
 
 
if [ ! -x ${WGET} ]; then
   echo "${WGET} not installed."
   WGET=/bin/false
fi
 
if [ ! -x ${MKISOFS} ]; then
   echo "Please install mkisofs or change"
   echo "executable location in configuration"
   echo "Bailing out."
   exit 1
fi
 
if [ ! -x ${CDRECORD} ]; then
   echo "Please install cdrecord or change"
   echo "executable location in configuration"
   CDRECORD=/bin/false
fi
 
function die {
   echo
   echo $1
   echo "You do not appear to have proper settings or permissions,"
   echo "bailing out!"
   exit 1
}
 
function populate {
   echo -n "Copying configuration files to ${MASTERDIR}... "
   for file in ${CONFFILES}; do
      cp -a ${EDITDIR}/${file} ${MASTERDIR} || die "Could not copy configuration file ${file}."
   done
   echo "Configuration files copied."
}
 
######### Begin Procedure ##########
 
echo -n "Changing directory to ${BASEDIR}... "
cd ${BASEDIR} || die "Can not cd to ${BASEDIR}"
echo "Now in ${BASEDIR}"
 
echo "Checking existence of ${EDITDIR}... "
if [ -e ${EDITDIR} ]; then
   echo "${EDITDIR} already exists, continuing will erase any files there,"
   echo "press control+c to abort, otherwise anyother key to proceed."
   read -n 1 foo
   rm -rf ${EDITDIR} || die "Failed to remove ${EDITDIR}"
   echo "${EDITDIR} successfully removed."
fi
 
echo -n "Creating ${EDITDIR}... "
mkdir -p ${EDITDIR} || die "Can't create ${EDITDIR}"
echo "${EDITDIR} successfully created."
 
echo -n "Checking for image file... "
if [ -e ${IMG} ]; then
   echo "Already have image file, good."
else
   echo "You do not seem to have the image file."
   echo "Press cotrol+c to abort, any other key to retrieve."
   read -n 1 foo
   ${WGET} ${ISO_URL} || die "Can't download ${IMG}"
   echo "${IMG} succsessfully retrieved."
fi
 
echo -n "Checking existence of ${MOUNTDIR}, the loopback mount point... "
if [ -e ${MOUNTDIR} ]; then
   echo "Mountpoint already exists, good."
else
   echo "Mount point does not exist."
   echo -n "Creating mountpoint ${MOUNTDIR}... "
   mkdir -p ${MOUNTDIR} || die "Can not create ${MOUNTDIR}"
   echo "${MOUNTDIR} successfully created."
fi
 
echo -n "Mounting ${IMG} on loopback mountpoint ${MOUNTDIR}... "
mount  -t iso9660 ${IMG} ${MOUNTDIR} -o loop || die "Can not mount ${IMG} on ${MOUNTDIR}"
echo "${IMG} successfully mounted."
 
echo -n "Copying all files to the temporary edit directory ${EDITDIR}... "
cp -a ${MOUNTDIR}/* ${EDITDIR} || die "Copy failed."
echo "Files successfully copied."
 
echo -n "Unmounting loopback image... "
umount ${MOUNTDIR} || die "Could not unmount ${MOUNTDIR}"
echo "${MOUNTDIR} successfully unmounted"
 
 
if [ -d ${MASTERDIR} ]; then
   if [ "`ls ${MASTERDIR}`" = "" ]; then
      echo "The master files directory is empty!"
      echo "You must have delted your configurations."
      echo "Adding default configuration files."
      populate
   else
      echo "${MASTERDIR} exists and has the following in it."
      ls ${MASTERDIR}
      echo "Using above as configuration files."
   fi
else
   echo "The master files directory does not exist!"
   echo "Either this is the first time you have run this"
   echo "script or you have deleted your configurations."
   echo
   echo "Either way we are starting from scratch."
   echo
   echo -n "Creating ${MASTERDIR}... "
   mkdir -p ${MASTERDIR} || die "Could not create ${MASTERDIR}"
   echo "${MASTERDIR} created."
   populate
fi
 
echo 
echo "*****From another terminal or GUI*****"
echo "Edit, Replace, or Add files as necesary"
echo "in the directory ${MASTERDIR}"
echo "Future reference, modify before running this script."
echo
echo "Press any key to continue or control+c to abort."
read -n 1 foo
echo "Assuming configuration complete."
 
echo -n "Copying master configuration files from ${MASTERDIR}... "
cp -a ${MASTERDIR}/* ${EDITDIR} || die "Copying configuration to ${EDITDIR} failed."
echo "Configuration successfully imported."
 
 
echo -n "Changing directory to ${EDITDIR} to build iso image... "
cd ${EDITDIR} || die "Could not cd to ${EDITDIR}"
echo "Now in ${EDITDIR}"
 
echo -n "Creating iso image... "
${MKISOFS} -quiet -V "${CDNAME}" -o ${BASEDIR}/${IMG_NAME} -R -J -D -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table ${EDITDIR} || die "Could not mkisofs ${BASEDIR}/${IMG_NAME}"
echo "${BASEDIR}/${IMG_NAME} successfully created."
 
echo "I can write the newly created image to a cd,"
echo "if you have properly set up the options."
echo "Press any key to continue or control+c to abort."
read -n 1 foo
 
if [ ${isCDR} = "Yes" ]; then
   echo "Assuming disc in drive is a CDR, not blanking."
else
   echo "Blanking CDRW..."
   ${CDRECORD} ${CDRECOPT} blank=fast || die "CD blanking failed."
   echo "CDRW Successfully blanked."
fi
 
echo "Burning image ${IMG_NAME} to disc..."
${CDRECORD} -eject ${CDRECOPT} ${BASEDIR}/${IMG_NAME} || die "Burning CD failed."
echo "CD successfully created."
 
echo "All done, bye bye."
 
mkisofw.sh.txt · Last modified: 2008/03/19 11:07 by 24.16.202.255
 
Except where otherwise noted, content on this wiki is licensed under the following license:Public Domain
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Debian Driven by DokuWiki