Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding some stuff from the other repo. #1

Merged
merged 2 commits into from Oct 13, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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