diff options
Diffstat (limited to 'prep-boot-floppy-and-ks-config')
| -rwxr-xr-x | prep-boot-floppy-and-ks-config | 195 |
1 files changed, 191 insertions, 4 deletions
diff --git a/prep-boot-floppy-and-ks-config b/prep-boot-floppy-and-ks-config index 5e3f8cf..61dbd64 100755 --- a/prep-boot-floppy-and-ks-config +++ b/prep-boot-floppy-and-ks-config @@ -1,11 +1,198 @@ #!/bin/bash # -# This is a (placeholder for a) wrapper script +# This is a wrapper script # # The script expects a number of options, and with them it will first call # 'create-boot-floppy' and next 'adapt-ks-template' # -# The results of both scripts will be made available for download, and will be -# able to bootstrap a (CentOS 7) instance up to, and possibly including, -# cosmos+puppet bootstrap +Self=$(basename $0) + +function print_usage { + echo "usage: $Self <options>" +} + +function print_help { +cat <<EOF +$Self <options> +This is a wrapper for two scripts: + +adapt-ks-template adapts a kickstart template +create-boot-floppy creates a bootable floppy image + +Because the ipxe config and the kickstart config need many of the same options, +it's simpler to call a wrapper with *all* options, and have it call the +individual scripts. + +The results of both scripts will be moved to a directory, which is (assumed to +be) published by a webservice, thus making them available for download. +The combination of boot-floppy and kickstart config will be able to bootstrap +a (CentOS 7) instance up to, and possibly including, cosmos+puppet bootstrap + +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 + -P, --publish-path Path where results will be stored + -S, --cosmos-hash Hash used by cosmos to verify stuff + --sec-ip IP of secondary interface + --sec-nm Netmask of secondary interface + -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. + +EOF +} + + +function parse_commadline { + while [ "$#" -gt 0 ] ; do + case "$1" in + -h|--help) + print_help + exit 0 + ;; + -D|--domain) + Domain="$2" + shift + ;; + -G|--gateway) + GW="$2" + shift + ;; + -H|--host) + Host="$2" + shift + ;; + -I|--ip) + IP="$2" + shift + ;; + -K|--kserver) + Kserver="$2" + shift + ;; + -M|--netmask) + NM="$2" + shift + ;; + -N|--nameserver) + NS="$2" + shift + ;; + -P|--publish-path) + PublishPath="$2" + shift + ;; + -S|--cosmos-hash) + CosmosHash="$2" + shift + ;; + --sec-ip) + SecIP="${2}" + shift + ;; + --sec-nm) + SecNM="${2}" + shift + ;; + *) + echo "what do you mean \"$1\"?" + exit 1 + ;; + esac + shift + done +} + +function check_options { + # mandatory/needed + if [ "x${Domain}" = "x" ] + then + echo "${Self}: --domain is mandatory" + print_usage + exit 1 + fi + if [ "x${GW}" = "x" ] + then + echo "${Self}: --gateway is mandatory" + print_usage + exit 1 + fi + if [ "x${Host}" = "x" ] + then + echo "${Self}: --host 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${SecIP}" = "x" ] + then + echo "${Self}: --sec-ip is mandatory" + print_usage + exit 1 + fi + if [ "x${SecNM}" = "x" ] + then + echo "${Self}: --sec-nm is mandatory" + print_usage + exit 1 + fi + if [ "x${CosmosHash}" = "x" ] + then + CosmosHash="2f15e1edb02f14607084f167929bc145ed47954d" + fi + # optional/defaults: + if [ "x${Kserver}" = "x" ] + then + Kserver="109.105.122.84" + fi + if [ "x${NS}" = "x" ] + then + NS="109.106.96.141" + fi + if [ "x${PublishPath}" = "x" ] + then + PublishPath="/var/www/html/install" + fi +} + +parse_commadline ${@} +check_options + +TmpDir=$(mktemp -d) + +# expect to find the other scripts in the same folder this script is in: +#echo $0 +ScriptPath=$(echo $0 | sed -e "s#/${Self}##") +#echo $ScriptPath + +${ScriptPath}/create-boot-floppy -D ${Domain} -G ${GW} -H ${Host} \ + -I ${IP} -M ${NM} -T ${TmpDir} -P ${PublishPath} + +${ScriptPath}/adapt-ks-template -D ${Domain} -G ${GW} -H ${Host} \ + -I ${IP} -M ${NM} -T ${TmpDir} -P ${PublishPath} --sec-ip ${SecIP} \ + --sec-nm ${SecNM} + +# When this script calls the other two, PublishPath *is* set, so expect +# everything of value to be evacuated, and just clean up: + +rm -rf ${TmpDir} |
