From 0cca65054bd67b7b9f5722cc3b5e51067833ba15 Mon Sep 17 00:00:00 2001 From: Jon Clausen Date: Tue, 31 Jul 2018 08:19:52 +0200 Subject: added create-boot-iso --- create-boot-iso | 273 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 273 insertions(+) create mode 100755 create-boot-iso diff --git a/create-boot-iso b/create-boot-iso new file mode 100755 index 0000000..f1ec4cf --- /dev/null +++ b/create-boot-iso @@ -0,0 +1,273 @@ +#!/bin/bash +# +# proof of concept script to create a bootable 'deployment' ISO +# +# This one can run on 'linux', to generate an ISO to bootstrap a kickstart +# install. + +Self=$(basename $0) + +function print_usage { + echo "usage: $Self " +} + +function print_help { +cat < + +Script to create a bootable 'install' ISO image. + +The image uses ipxe to retrieve a kernel to boot, and sets URLs for the +'install' initrd and kickstart config the kernel should use. + +The whole thing is pretty CentOS 7 -centric at this point. + +Options given to this script will set values for the bootstrapping of the +*install* stage only. All values may subsequently be overridden from the +kickstart stage, once that is retrieved and control is handed over to it. + +Options: + -D, --domain domain, to complete FQDN + -G, --gateway Gateway of target system + -H, --host hostname of the target system + -I, --ip IP address of target system + -K, --kserver Kickstart server + -M, --netmask Netmask of target system + -N, --nameserver Nameserver of target system + -S, --cosmos-hash Hash used by cosmos to verify stuff + -h, --help this + +If --cosmos-hash is set to 'disabled', the kickstart stage should skip cosmos +bootstrapping, and leave the system unmanaged. + +If -N, -K, -S options are not given, default values are provided. + +The script needs ipxe and 'mkisofs' to run, and 'sudo' to copy things onto the +floppy image + +EOF +} + +function parse_commadline { + while [ "$#" -gt 0 ] ; do + case "$1" in + -h|--help) + print_help + exit 0 + ;; + -H|--host) + Host="$2" + shift + ;; + -D|--domain) + Domain="$2" + shift + ;; + -I|--ip) + IP="$2" + shift + ;; + -M|--netmask) + NM="$2" + shift + ;; + -G|--gateway) + GW="$2" + shift + ;; + -N|--nameserver) + NS="$2" + shift + ;; + -K|--kserver) + Kserver="$2" + shift + ;; + -P|--publish-path) + PublishPath="$2" + shift + ;; + -S|--cosmos-hash) + CosmosHash="$2" + shift + ;; + -T|--tmp-dir) + TmpDir="${2}" + shift + ;; + *) + echo "what do you mean \"$1\"?" + exit 1 + ;; + esac + shift + done +} + +function check_options { + if [ "x${Host}" = "x" ] + then + echo "${Self}: --host is mandatory" + print_usage + exit 1 + fi + if [ "x${Domain}" = "x" ] + then + echo "${Self}: --domain is mandatory" + print_usage + exit 1 + fi + if [ "x${IP}" = "x" ] + then + echo "${Self}: --ip is mandatory" + print_usage + exit 1 + fi + if [ "x${NM}" = "x" ] + then + echo "${Self}: --netmask is mandatory" + print_usage + exit 1 + fi + if [ "x${GW}" = "x" ] + then + echo "${Self}: --gateway is mandatory" + print_usage + exit 1 + fi + if [ "x${NS}" = "x" ] + then + NS="109.105.96.141" + fi + if [ "x${Kserver}" = "x" ] + then + Kserver="109.105.122.84" + fi + if [ "x${CosmosHash}" = "x" ] + then + CosmosHash="2f15e1edb02f14607084f167929bc145ed47954d" + fi + if [ "x${TmpDir}" = "x" ] + then + TmpDir=$(mktemp -d) + else + mkdir -p "${TmpDir}" + fi +} + +# Host="kas-fiona-10-02" +# Domain="nordu.net" +# IP="109.105.122.135" +# NM="255.255.255.192" +# GW="109.105.122.129" +# NS="109.105.96.141" +# Kserver="109.105.122.84" +# CosmosHash="2f15e1edb02f14607084f167929bc145ed47954d" + +parse_commadline $@ +check_options + +#### +# In a bid to be clever, we're adding the 'cosmos hash' to the install +# kernel cmdline. This is the one place that cannot be forged, changed, get +# lost or 'go missing' from the initial invocation here, until the +# anaconda/kickstart process takes over... + +WorkDir="${TmpDir}/${Host}.d" +IsoRoot="${WorkDir}/isoroot" +mkdir -p "${IsoRoot}/isolinux" +mkdir -p "${IsoRoot}/kernel" +mkdir -p "${IsoRoot}/images" + + +cat >${IsoRoot}/isolinux/isolinux.cfg <${IsoRoot}/isolinux/${Host}.ipxe <