From UMaine Supercomputer
#!/bin/bash
BASE_DIR=$PWD
SOURCEDIR=$1
TARGETDIR=$2
if [ -z $1 ] || [ -z $2 ] ; then
echo "usage makeboot_dir <source image> <target>" ;
exit 0;
fi;
if [ -d $TARGETDIR ] || [ -e $TARGETDIR ] ; then
echo "target file/directory exists...";
PS3=" overwrite? (Y/n)";
select ans in "Yes" "No";
do
if [ "$ans" == "No" ] ; then
exit;
fi
rm -rf $TARGETDIR
break;
done;
fi;
mkdir $TARGETDIR;
cd $SOURCEDIR;
tar -cf - admin bin sbin etc lib dev root opt home* x|tar -C $BASE_DIR/$TARGETDIR -xf -;
cd $BASE_DIR/$TARGETDIR
#
# get other files
mkdir usr usr/sbin usr/lib;
cp -dp $SOURCEDIR/usr/sbin/chroot usr/sbin/.
cp -dp $SOURCEDIR/usr/sbin/udevmonitor usr/sbin/.
cp -dp $SOURCEDIR/usr/lib/libreadline.so* usr/lib/.
cp -dp $SOURCEDIR/usr/lib/libz.so* usr/lib/.
cp -dp $BASE_DIR/config/init .;
cp -rdp $BASE_DIR/config/var .;
#
# make mount points and tmp
mkdir mnt mnt1 proc sys tmp;
#
# correct permissions on tmp
chmod 1777 /tmp
#
# we need fastboot to make fedora's sys init script to
# not run fsck on non-existant disks
touch fastboot;