diff options
author | Jon Clausen <jac@nordu.net> | 2018-07-16 14:08:16 +0200 |
---|---|---|
committer | Jon Clausen <jac@nordu.net> | 2018-07-16 14:08:16 +0200 |
commit | 09632c0f8b69528f238bd850be27afa33fc1206b (patch) | |
tree | a5fbd73d20ab282aaa49ded08b3d88d818fef9e3 /create-boot-floppy | |
parent | 64bb4076f0ac9549a4fc0c746926e10d2bb178fa (diff) |
big bang, things are now working -ish
Diffstat (limited to 'create-boot-floppy')
-rwxr-xr-x | create-boot-floppy | 72 |
1 files changed, 60 insertions, 12 deletions
diff --git a/create-boot-floppy b/create-boot-floppy index 7494043..6178e76 100755 --- a/create-boot-floppy +++ b/create-boot-floppy @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # proof of concept script to create a bootable 'deployment' floppy # @@ -42,6 +42,9 @@ bootstrapping, and leave the system unmanaged. If -N, -K, -S options are not given, default values are provided. +The script needs ipxe and syslinux to run, and 'sudo' to copy things onto the +floppy image + EOF } @@ -80,10 +83,18 @@ function parse_commadline { 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 @@ -91,41 +102,57 @@ function parse_commadline { esac shift done +} + +function check_options { if [ "x${Host}" = "x" ] then echo "${Self}: --host is mandatory" print_usage exit 1 - elif [ "x${Domain}" = "x" ] + fi + if [ "x${Domain}" = "x" ] then echo "${Self}: --domain is mandatory" print_usage exit 1 - elif [ "x${IP}" = "x" ] + fi + if [ "x${IP}" = "x" ] then echo "${Self}: --ip is mandatory" print_usage exit 1 - elif [ "x${NM}" = "x" ] + fi + if [ "x${NM}" = "x" ] then echo "${Self}: --netmask is mandatory" print_usage exit 1 - elif [ "x${GW}" = "x" ] + fi + if [ "x${GW}" = "x" ] then echo "${Self}: --gateway is mandatory" print_usage exit 1 - elif [ "x${NS}" = "x" ] + fi + if [ "x${NS}" = "x" ] then NS="109.105.96.141" - elif [ "x${Kserver}" = "x" ] + fi + if [ "x${Kserver}" = "x" ] then Kserver="109.105.122.84" - elif [ "x${CosmosHash}" = "x" ] + 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" @@ -138,6 +165,7 @@ function parse_commadline { # CosmosHash="2f15e1edb02f14607084f167929bc145ed47954d" parse_commadline $@ +check_options #### # In a bid to be clever, we're adding the 'cosmos hash' to the install @@ -145,7 +173,7 @@ parse_commadline $@ # lost or 'go missing' from the initial invocation here, until the # anaconda/kickstart process takes over... -WorkDir="$HOME/tmp/${Host}.d" +WorkDir="${TmpDir}/${Host}.d" mkdir -p ${WorkDir}/mnt dd if=/dev/zero of=${WorkDir}/${Host}.img bs=2x80x18b count=1 @@ -182,6 +210,7 @@ set gw ${GW} set ns ${NS} set hn ${Host} set dn ${Domain} +set ks ${Kserver} ### # Set up network: @@ -203,8 +232,8 @@ show domain route ### # Set install parameters: -set base http://109.105.122.84/install/centos/7/os/x86_64 -kernel \\$"{"base"}"/images/pxeboot/vmlinuz text console=tty1 console=ttyS1,115200n8 ip=\\$"{"ip"}" netmask=\\$"{"nm"}" gateway=\\$"{"gw"}" repo=\\$"{"base"}" ks=http://\\$"{"Kserver"}"/install/ks/kas-fiona-10-02.cfg cosmoshash=${CosmosHash} +set base http://\\$"{"ks"}"/install/centos/7/os/x86_64 +kernel \\$"{"base"}"/images/pxeboot/vmlinuz text console=tty1 console=ttyS1,115200n8 ip=\\$"{"ip"}" netmask=\\$"{"nm"}" gateway=\\$"{"gw"}" repo=\\$"{"base"}" ks=http://\\$"{"ks"}"/install/ks/\\$"{"hn"}".ks cosmoshash=${CosmosHash} initrd \\$"{"base"}"/images/pxeboot/initrd.img ### # Boot into install @@ -218,6 +247,25 @@ EOF #read -sudo cp -a /usr/share/ipxe/ipxe.lkrn ${WorkDir}/mnt/ +if [ -r /etc/redhat-release ] +then + sudo cp -a /usr/share/ipxe/ipxe.lkrn ${WorkDir}/mnt/ +elif [ -r /etc/debian_version ] +then + sudo cp -a /boot/ipxe.lkrn ${WorkDir}/mnt/ +else + echo "neither redhat nor debian, I'm outta here..." + exit 1 +fi sudo extlinux --install ${WorkDir}/mnt/ sudo umount ${WorkDir}/mnt/ + +if [ ! "x${PublishPath}" = "x" ] +then + mkdir -p "${PublishPath}/${Host}.d/" + mv "${WorkDir}/${Host}.img" "${PublishPath}/${Host}.d/" + rm -rf ${WorkDir} +else + echo "no PublishPath set, leaving everything in ${WorkDir}" +fi + |