2011-02-10 17:07:48 -07:00
|
|
|
#! /bin/sh -e
|
|
|
|
|
|
|
|
DRIVE=$1
|
|
|
|
if ! [ -b "$DRIVE" ]; then
|
|
|
|
echo "Usage: $0 DEVICE"
|
|
|
|
echo
|
|
|
|
echo "Prepares DEVICE with Capture The Flag goodness"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2011-02-22 14:05:51 -07:00
|
|
|
size=$(sfdisk -s $DRIVE)
|
2011-03-04 19:43:02 -07:00
|
|
|
fatsize=$(sfdisk -l /dev/sdb | awk '/^Disk/ {print $3 - 2;}')
|
2011-02-10 17:07:48 -07:00
|
|
|
|
|
|
|
FATFS=${DRIVE}1
|
|
|
|
EXTFS=${DRIVE}2
|
|
|
|
|
2012-04-24 10:03:14 -06:00
|
|
|
sfdisk $DRIVE <<EOF || true
|
2011-02-22 14:05:51 -07:00
|
|
|
,$fatsize,6,*
|
2011-02-10 17:07:48 -07:00
|
|
|
,,L
|
|
|
|
EOF
|
|
|
|
sync
|
|
|
|
|
|
|
|
mkdir -p /mnt/ctf-install
|
|
|
|
|
|
|
|
mkdosfs -n PACKAGES $FATFS
|
|
|
|
mke2fs -j -L VAR $EXTFS
|
|
|
|
|
2011-03-04 19:43:02 -07:00
|
|
|
cat /usr/lib/syslinux/mbr.bin > $DRIVE
|
2011-02-10 17:07:48 -07:00
|
|
|
mount $FATFS /mnt/ctf-install
|
2011-03-04 19:43:02 -07:00
|
|
|
mkdir /mnt/ctf-install/syslinux /mnt/ctf-install/disabled
|
2011-02-10 17:07:48 -07:00
|
|
|
umount /mnt/ctf-install
|
|
|
|
syslinux -d syslinux $FATFS
|
|
|
|
|
|
|
|
mount $FATFS /mnt/ctf-install
|
|
|
|
|
|
|
|
cat <<EOD >/mnt/ctf-install/syslinux/syslinux.cfg
|
|
|
|
DEFAULT ctf
|
|
|
|
LABEL ctf
|
|
|
|
KERNEL bzImage
|
|
|
|
INITRD dbtl.squashfs
|
2011-02-22 14:05:51 -07:00
|
|
|
|
|
|
|
LABEL dbtl
|
|
|
|
KERNEL bzImage
|
|
|
|
INITRD dbtl.squashfs
|
|
|
|
APPEND packages=disabled
|
2011-02-10 17:07:48 -07:00
|
|
|
EOD
|
|
|
|
|
2012-02-02 17:14:41 -07:00
|
|
|
cp rootfs.squashfs /mnt/ctf-install/syslinux/dbtl.squashfs
|
|
|
|
cp bzImage /mnt/ctf-install/syslinux/
|
2011-03-04 19:43:02 -07:00
|
|
|
cp $(dirname $0)/bin/*.pkg /mnt/ctf-install/disabled/
|
2012-02-02 17:14:41 -07:00
|
|
|
mv /mnt/ctf-install/disabled/00admin.pkg /mnt/ctf-install/
|
2011-02-10 17:07:48 -07:00
|
|
|
umount /mnt/ctf-install
|
|
|
|
rmdir /mnt/ctf-install
|
|
|
|
|
|
|
|
sync
|
|
|
|
|
|
|
|
echo "Done"
|