gentoo-asahi-releng/tools-hardened/desktop/files/Save/iso2usb.sh
Devan Franchini b80e4e5ff8 tools-hardened/desktop: initial commit of hardened amd64 desktop
This is a revamping of the TinHat build, see

    http://opensource.dyc.edu/tinhat

Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
2014-04-06 08:13:10 -04:00

97 lines
1.8 KiB
Bash

#!/bin/bash
WORKING=$(pwd)
welcome ()
{
echo
echo "================================================================================"
echo "= This script will transfer the contents of a bootable iso to a usb stick. ="
echo "= ="
echo "= WARNING: IT WILL DESTROY THE CONTENTS OF THE USB STICK!!! ="
echo "= ="
echo "================================================================================"
echo
}
check ()
{
echo
echo "Enter the device name of the USB drive, eg sda "
echo "Don't worry, I'll show you the device's partition table before we wipe it "
echo
echo -n "Device: "
read DEVICE
echo
parted /dev/${DEVICE} print
echo -n "Are you sure? (Type uppercase yes): "
read ANSWER
if [[ $ANSWER != "YES" ]] ; then
echo
echo "ABORT! ABORT! ABORT!"
echo
exit
fi
}
partition ()
{
dd if=/dev/zero of=/dev/${DEVICE} bs=1 count=1024 >/dev/null 2>&1
dd if=/usr/lib/syslinux/mbr.bin of=/dev/${DEVICE} >/dev/null 2>&1
parted -s /dev/${DEVICE} mklabel msdos mkpartfs primary fat32 0 100% >/dev/null 2>&1
parted -s /dev/${DEVICE} set 1 boot >/dev/null 2>&1
}
copyiso()
{
echo
echo "Enter the name of the iso image relative to ${WORKING} "
echo
echo -n "Name: "
read IMAGE
if [[ ! -f ${WORKING}/${IMAGE} ]] ; then
echo
echo "Cannot find iso image, exiting."
echo
exit
fi
cd ${WORKING}
mkdir -p iso usb
mount -o loop ${IMAGE} iso
mount /dev/${DEVICE}1 usb
cp iso/tinroot usb
cp iso/boot/tinhat usb
cp iso/boot/tinhat.igz usb
cp configs/syslinux.cfg usb
umount iso && rmdir iso
umount usb && rmdir usb
}
finishup()
{
syslinux /dev/${DEVICE}1
}
welcome
check
partition
copyiso
finishup