Skip to content

Commit

Permalink
Merge pull request #1 from myles/master
Browse files Browse the repository at this point in the history
Adding some stuff from the other repo.
  • Loading branch information
myles committed Oct 13, 2016
2 parents 5fc7feb + 3e329cd commit 3bbcf1f
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 15 deletions.
73 changes: 59 additions & 14 deletions 2-testing/03-debian-preseed/iso/gen_iso.sh
Expand Up @@ -2,29 +2,71 @@

set -ex

iso_img='debian-8.6.0-amd64-CD-1.iso'
preseed="preseed.cfg"

help() {
cat << EOF
Usage: ${0##*/} [-h] -i debian.iso -p preseed.cfg outfile.iso
Given a Debian iso image, produce a new ISO image with preseed.cfg installed
in order to facilitate an automated install.
-h display help and exit
-i debian.iso specify input iso image
-p preseed.cfg debian preseed configuration for automated install
outfile.iso output iso image with preseed slipstreamed
This script creates several temporary directories in current directory and requires sudo, rsync and genisoimage commands to be available.
EOF
}

OPTIND=1

options="hi:p::"
iso_img=""
preseed=""

while getopts $options option
do
case $option in
i ) iso_img=`realpath $OPTARG`;;
p ) preseed=`realpath $OPTARG`;;
h ) help; exit 1;;
\? ) echo "Unknown option: -$OPTARG" >&2; exit 1;;
: ) echo "Missing option argument for -$OPTARG" >&2; exit 1;;
esac
done
shift "$((OPTIND-1))"
preseed_final=$@

if [ -z "${iso_img}" ] || [ ! -f "${iso_img}" ]
then
echo "Missing -i debian.iso argument" >&2
exit 1
fi

if [ -z "${preseed}" ] || [ ! -f "${preseed}" ]
then
echo "Missing -p preseed.cfg argument" >&2
exit 1
fi

if [ -z "${preseed_final}" ]
then
echo "Please specify output file" >&2
exit 1
fi

work_dir="img_dir"
preseed_final="debian-amd64-preseed.iso"
tmp_dir="loopdir"
irmod="irmod"

rel_workdir=${work_dir}
iso_img="${PWD}/${iso_img}"
preseed="${PWD}/${preseed}"
work_dir="${PWD}/${work_dir}"
loopdir="${PWD}/${loopdir}"
preseed_final="${PWD}/${preseed_final}"
irmod="${PWD}/${irmod}"




if [ ! -f "${preseed}" ]
then
echo "${preceed} file not found"
exit 1
fi

sudo rm -f "${preseed_final}"
sudo rm -rf "${work_dir}"
sudo rm -rf "${tmp_dir}"
Expand All @@ -50,4 +92,7 @@ sudo bash -c "find . | cpio -H newc --create --verbose | gzip -9 > ${work_dir}/i
sudo genisoimage -o ${preseed_final} -r -J -no-emul-boot -boot-load-size 4 -boot-info-table -b isolinux/isolinux.bin -c isolinux/boot.cat ${work_dir}

cd ..
sudo umount "${tmp_dir}"
sudo umount "${tmp_dir}"
sudo rm -rf "${work_dir}"
sudo rm -rf "${tmp_dir}"
sudo rm -rf "${irmod}"
6 changes: 5 additions & 1 deletion 2-testing/03-debian-preseed/iso/preseed.cfg
@@ -1,4 +1,8 @@
# https://github.com/capistrano/packer/blob/master/http/preseed.cfg
# This is a modified version of kali linux preseed file taken from here
# https://www.kali.org/dojo/preseed.cfg

# This version is to be used to build virtual machines, i.e. libvirt guest
# Note that partmant-auto/disk argument is set to /dev/vda

d-i debian-installer/locale string en_US.UTF-8
d-i console-keymaps-at/keymap select us
Expand Down

0 comments on commit 3bbcf1f

Please sign in to comment.