PDA

View Full Version : Bash script to extract the bt3-usb iso to your HDD ready for a HDD install.



drgr33n
12-02-2008, 09:03 AM
Hey guys

Just hacked up this little bash script to aid me in reinstalling bt3 onto my HDD. This script mounts the ISO and extracts all the LZM's to a folder on your HDD.

Then it packs up a HDD install ready to be extracted onto your HDD.



#!/bin/bash
# Backtrack 3 USB edition HDD extractor by drgr33n
echo "################################################## ####
### Backtrack 3 usb edition packer by drgr33n 2008 ###
################################################## ####"
echo "This script will extract all the data from the BT3 usb image and dump it in your root folder"

# User input
echo "Type the /path/to/the/BT3final_usb.iso followed by [ENTER] for EG /root/BT3final_usb.iso:"
read path

echo "Creaing the directories and mounting the image to /mnt/iso"
mkdir /root/bt3-final/
mkdir /mnt/backtrack-iso
mount -o loop $path /mnt/backtrack-iso/
cd backtrack-iso

# Make sure the backtrack folder exists!
if [ -d BT3 ] ; then
echo "BT3 Folder Found"
else
echo "Error! BT3 Folder not found check /path/to/bt3 iso"
exit 1
fi

if [ -d boot ] ; then
echo "boot Folder Found"
else
echo "Error! boot Folder not found check /path/to/bt3 iso"
exit 1
fi

# Extract it all to /root
cd BT3
cd base
list='echo *'
for file in $list
do
echo $file
lzm2dir $file /root/bt3-final/
done
cd ..
cd modules
list='echo *'
for file in $list
do
echo 'Extracting '$file
lzm2dir $file /root/bt3-final/
done
cd ..
cd optional
list='echo *'
for file in $list
do
echo 'Extracting '$file
lzm2dir $file /root/bt3-final/
done
cd /mnt/backtrack-iso
cp -R /boot /root/bt3-final
mkdir /root/bt3-final/{mnt,sys,proc}
cp --preserve -R /dev /mnt/sda1/dev
umount $path
echo "BT3 final extraction complete! Just copy onto your HDD, chroot and run lilo"
echo "Script by drgr33n / zarren2@hotmail.co.uk"