From: davidplunkett Date: Fri, 29 Mar 2019 23:54:18 +0000 (+0000) Subject: change ixpe steps so all settings are in ipxe.efi X-Git-Tag: 1.0.0~14 X-Git-Url: https://gerrit.akraino.org/r/gitweb?a=commitdiff_plain;h=a51d4fa73f97a351a3dfe6b2a8a26c91dff1d980;p=redfish.git change ixpe steps so all settings are in ipxe.efi Update logic to create a single ipxe script with all host settings and jump to the correct settings based on the mac address of the nic detected when ipxe boots. All servers now boot the same ipxe.efi file. Change-Id: Ib1c2bc9a93096995173f7f23bd03a33777948231 Signed-off-by: davidplunkett --- diff --git a/apply_dellxml.sh b/apply_dellxml.sh index 47af171..865a047 100755 --- a/apply_dellxml.sh +++ b/apply_dellxml.sh @@ -92,6 +92,10 @@ else echo "Using template [$REDFISH_ROOT/$TEMPLATE]" fi +# SET ADDITIONAL VARIABLES BASED ON RC FILE +SRV_IPXE_URL=http://$BUILD_WEBIP:$BUILD_WEBPORT/ipxe.efi +XMLFILE=$SRV_NAME.${TEMPLATE%\.template} + # CHECK VARIABLES USED IN TEMPLATE CHECKLIST=$(grep -oP '(?<=@@)[^@]+(?=@@)' "$REDFISH_ROOT/$TEMPLATE" | sort | uniq | xargs) for VAR in $CHECKLIST; do @@ -102,15 +106,11 @@ for VAR in $CHECKLIST; do fi done -# SET ADDITIONAL VARIABLES BASED ON RC FILE -SRV_IPXE_URL=http://$BUILD_WEBIP:$BUILD_WEBPORT/ipxe-$SRV_IPXE_INF-$SRV_VLAN.efi -XMLFILE=$SRV_NAME.${TEMPLATE%\.template} - if [ -z "$NO_CONFIRM" ]; then echo "" read -r -p "Preparing to apply xml file [$TEMPLATE] to server [$SRV_NAME] using oob ip [$SRV_OOB_IP]. Are you sure? [y/N] " response case "$response" in - [yY][eE][sS]|[yY]) + [yY][eE][sS]|[yY]) ;; *) echo "Script aborted!" @@ -161,7 +161,7 @@ if [ -z "$NO_APPLY_HW" ]; then exit 1 fi else - ## SKIPPING REBOOT + ## SKIPPING REBOOT echo "WARNING: Skipping application of hardware settings - normally used for testing only" fi @@ -170,3 +170,4 @@ ETIME=$(date +%s) echo "SUCCESS: Completed update of BIOS/RAID settings on [$SRV_NAME] at" `date` echo "Elapsed time was $(( ($ETIME - $STIME) / 60 )) minutes and $(( ($ETIME - $STIME) % 60 )) seconds" + diff --git a/apply_hpejson.sh b/apply_hpejson.sh index 8e401f5..1b3259e 100755 --- a/apply_hpejson.sh +++ b/apply_hpejson.sh @@ -92,6 +92,10 @@ else echo "Using template [$REDFISH_ROOT/$TEMPLATE]" fi +# SET ADDITIONAL VARIABLES BASED ON RC FILE +SRV_IPXE_URL=http://$BUILD_WEBIP:$BUILD_WEBPORT/ipxe-$SRV_IPXE_INF-$SRV_VLAN.efi +JSONFILE=$SRV_NAME.${TEMPLATE%\.template} + # CHECK VARIABLES USED IN TEMPLATE CHECKLIST=$(grep -oP '(?<=@@)[^@]+(?=@@)' "$REDFISH_ROOT/$TEMPLATE" | sort | uniq | xargs) for VAR in $CHECKLIST; do @@ -102,10 +106,6 @@ for VAR in $CHECKLIST; do fi done -# SET ADDITIONAL VARIABLES BASED ON RC FILE -SRV_IPXE_URL=http://$BUILD_WEBIP:$BUILD_WEBPORT/ipxe-$SRV_IPXE_INF-$SRV_VLAN.efi -JSONFILE=$SRV_NAME.${TEMPLATE%\.template} - if [ -z "$NO_CONFIRM" ]; then echo "" read -r -p "Preparing to apply json file [$TEMPLATE] to server [$SRV_NAME] using oob ip [$SRV_OOB_IP]. Are you sure? [y/N] " response @@ -169,3 +169,4 @@ ETIME=$(date +%s) echo "SUCCESS: Completed update of BIOS/RAID settings on [$SRV_NAME] at" `date` echo "Elapsed time was $(( ($ETIME - $STIME) / 60 )) minutes and $(( ($ETIME - $STIME) % 60 )) seconds" + diff --git a/base.ipxe.template b/base.ipxe.template new file mode 100644 index 0000000..67f957e --- /dev/null +++ b/base.ipxe.template @@ -0,0 +1,70 @@ +#!ipxe +# +# Copyright 2019 AT&T Intellectual Property. All other rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +echo Scanning network cards looking for a match +set idx:int32 0 +:loop + isset ${net${idx}/mac} || goto failed + echo checking net${idx} with chip ${net${idx}/chip} and MAC ${net${idx}/mac} + set nic net${idx} + goto host_${net${idx}/mac} || + inc idx + goto loop + +# ERROR - loop finished without finding a match or boot failed +:failed + echo + echo ERROR: Boot failed!!! Nic mac addresses did not match any known host. + echo Type ifstat for a list of intefaces and mac addresses + shell + +:boot + echo Attempting boot using nic=${nic} vlan=${vlan} ip=${myip} mask=${mynm} gw=${mygw} mac=${${nic}/mac} + isset ${vlan} || goto skip_vlan + vcreate --tag ${vlan} ${nic} || goto :failed + set nic ${nic}-${vlan} +:skip_vlan + isset ${myip} || goto dhcp + isset ${myip} && set ${nic}/ip ${myip} || goto failed + isset ${mynm} && set ${nic}/netmask ${mynm} || goto failed + isset ${mygw} && set ${nic}/gateway ${mygw} || goto failed + isset ${mydns} && set ${nic}/dns ${mydns} || + ifopen ${nic} || goto failed + goto loadkernel +:dhcp + ifconf --configurator dhcp ${nic} || goto failed + +:loadkernel + echo Preparing to start Ubuntu Xenial installer for host [${myname}] using settings: + echo initrd: ${myinitrd} + echo kernel: ${mykernel} + echo params: ${myparams} + prompt --key 0x02 --timeout 15000 Pausing 15 seconds... Press Ctrl-B for the iPXE command line... && shell || + + kernel ${mykernel} ${myparams} || goto failed + initrd ${myinitrd} || goto failed + boot || goto failed + +# END - SCRIPT NEVER REACHES THIS POINT + +# BEGIN HOST ENTRIES +# each host section +# should start a label with the format :host_macaddr +# should set the required variables to boot +# must end with goto boot + + diff --git a/boot.ipxe.template b/boot.ipxe.template index b671fdb..4bdf9cf 100644 --- a/boot.ipxe.template +++ b/boot.ipxe.template @@ -1,6 +1,6 @@ #!ipxe # -# Copyright 2018 AT&T Intellectual Property. All other rights reserved. +# Copyright 2019 AT&T Intellectual Property. All other rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,11 +14,26 @@ # See the License for the specific language governing permissions and # limitations under the License. # -set vlan @@IPXE_VLAN@@ -set nic @@IPXE_INTF@@ -echo Starting network on vlan [${vlan}] using nic [${nic}]... -vcreate --tag ${vlan} ${nic} || -ifconf --configurator dhcp ${nic}-${vlan} || ifstat -isset ${filename} && chain ${filename} || echo Boot file [${filename}] does not exist or is invalid... -prompt --key 0x02 --timeout 0 Press Ctrl-B for the iPXE command line... && shell || + +:host_@@SRV_MAC@@ + set myname @@SRV_NAME@@ + set vlan @@SRV_VLAN@@ + set myip @@SRV_IP@@ + set mynm @@SRV_NETMASK@@ + set mygw @@SRV_GATEWAY@@ + set myinterface interface=@@SRV_BLD_INF@@ + set mystaticnet netcfg/disable_autoconfig=true netcfg/vlan_id=@@SRV_VLAN@@ netcfg/get_ipaddress=@@SRV_IP@@ netcfg/get_netmask=@@SRV_NETMASK@@ netcfg/get_gateway=@@SRV_GATEWAY@@ netcfg/get_nameservers=@@SRV_DNS@@ netcfg/get_domain=@@SRV_DOMAIN@@ netcfg/confirm_static=true + set ramdisk root=/dev/ram0 load_ramdisk=1 ramdisk_size=524288 + set iname initrd-@@SRV_OSVER@@ + set uroot ubuntu-@@SRV_OSWEB_DIR@@ + set myweb http://@@BUILD_WEBIP@@:@@BUILD_WEBPORT@@/ + set mymirror mirror/http/directory=/${uroot} mirror/http/hostname=${myweb} + set liveinstaller live-installer/net-image=${myweb}/${uroot}/install/filesystem.squashfs + set baseinstaller base-installer/kernel/override-image=linux-generic@@SRV_OSKRN_EXT@@ + + set mykernel ${myweb}/linux-@@SRV_OSVER@@ + set myparams ${ramdisk} showopts auto=true locale=en_US initrd=${iname} hostname=${myname} url=${myweb}/${myname}.seed ${myinterface} ${mystaticnet} ${baseinstaller} ${liveinstaller} ${mymirror} + set myinitrd ${myweb}/${iname} + goto boot + diff --git a/create_ipxe.sh b/create_ipxe.sh index b092f98..c7bc05a 100755 --- a/create_ipxe.sh +++ b/create_ipxe.sh @@ -62,15 +62,6 @@ if [ -n "$RCFILE" ] && [ -f "$RCFILE" ]; then source $RCFILE fi -IPXE_VLAN=${IPXE_VLAN:-1} -IPXE_INTF=${IPXE_INTF:-net1} - -## CHECK IF IPXE EFI FILE ALREADY EXISTS -if [ -f "$WEB_ROOT/ipxe-$IPXE_INTF-$IPXE_VLAN.efi" ]; then - echo "Skipping ipxe build because efi file [$WEB_ROOT/ipxe-$IPXE_INTF-$IPXE_VLAN.efi] already exists" - exit 0 -fi - ## GIT CLONE IPXE IF $IPXE_ROOT DOES NOT EXIST if [ ! -d "$IPXE_ROOT" ]; then echo "Cloning ipxe source from [$IPXE_GIT] to [$IPXE_ROOT]" @@ -84,16 +75,44 @@ if [ ! -f "$IPXE_ROOT/src/config/general.h" ]; then fi sed -i 's|//#define VLAN_CMD|#define VLAN_CMD|g' $IPXE_ROOT/src/config/general.h +## CHECK THAT SRV_MAC IS SET +if [ -z "$SRV_MAC" ]; then + echo "ERROR: Invalid or missing variable SRV_MAC [$SRV_MAC]" + exit 1 +fi + +#### CREATE HOST_MAC.IPXE #### +SRV_OSVER=$(echo $SRV_BLD_SCRIPT | grep -Eo '(hwe-)?[0-9]+\.[0-9]+\.[0-9]+-[^.-]+') +SRV_OSKRN_EXT=-$(echo $SRV_BLD_SCRIPT | grep -Eo 'hwe-[0-9]+\.[0-9]+') +SRV_OSWEB_DIR=$(echo $SRV_BLD_SCRIPT | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+-[^.-]+') + +## COPY TEMPLATE (WITHOUT COMMENTS TO REDUCE SIZE) AND REPLACE VALUES +HOST_IPXE_FILE=$AKRAINO_ROOT/server-config/host_${SRV_MAC//:/}.ipxe +grep -v '^#.*$' $REDFISH_ROOT/boot.ipxe.template > $HOST_IPXE_FILE +for VAR in $(set | grep -P "^SRV_|^BUILD_" | cut -f 1 -d'='); do + sed -i -e "s|@@$VAR@@|${!VAR}|g" $HOST_IPXE_FILE +done + +if [ ! -f "$HOST_IPXE_FILE" ]; then + echo "ERROR: failed creating script [$HOST_IPXE_FILE]" + exit 1 +fi + ## CREATE BOOT.IPXE -rm -f $IPXE_ROOT/boot.ipxe -sed -e "s|@@IPXE_VLAN@@|$IPXE_VLAN|g" \ - -e "s|@@IPXE_INTF@@|$IPXE_INTF|g" \ - $REDFISH_ROOT/boot.ipxe.template > $IPXE_ROOT/boot.ipxe +cat $REDFISH_ROOT/base.ipxe.template $AKRAINO_ROOT/server-config/host_*.ipxe > $IPXE_ROOT/boot.ipxe if [ ! -f "$IPXE_ROOT/boot.ipxe" ]; then echo "ERROR: failed creating script [$IPXE_ROOT/boot.ipxe]" exit 1 fi +## CHECK THAT ALL VALUES WERE REPLACED +MISSING=$(grep -Po "@@.*?@@" $IPXE_ROOT/boot.ipxe | sort | uniq) +if [ -n "$MISSING" ] ; then + echo "ERROR: Required variable(s) for $IPXE_ROOT/boot.ipxe were not located in the resource file [$RCFILE]" + echo ${MISSING//@@/} | xargs -n 1 | sed -e 's/^/ /g' + exit 1 +fi + ## BUILD IPXE rm -f $IPXE_ROOT/src/bin-x86_64-efi/ipxe.efi echo "Building ipxe from [$IPXE_ROOT/src] with embeded script [$IPXE_ROOT/boot.ipxe]" @@ -104,7 +123,8 @@ if [ ! -f "$IPXE_ROOT/src/bin-x86_64-efi/ipxe.efi" ]; then fi ## COPY IPXE TO WEB ROOT -cp -f $IPXE_ROOT/src/bin-x86_64-efi/ipxe.efi $WEB_ROOT/ipxe-$IPXE_INTF-$IPXE_VLAN.efi +cp -f $IPXE_ROOT/src/bin-x86_64-efi/ipxe.efi $WEB_ROOT/ipxe.efi + +echo "Created ipxe file [$WEB_ROOT/ipxe.efi] in web root [$WEB_ROOT]" -echo "Created ipxe file [$WEB_ROOT/ipxe-$IPXE_INTF-$IPXE_VLAN.efi] in web root [$WEB_ROOT]" diff --git a/install_server_os.sh b/install_server_os.sh index 264c34a..b9796f8 100755 --- a/install_server_os.sh +++ b/install_server_os.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright 2018 AT&T Intellectual Property. All other rights reserved. +# Copyright 2018-2019 AT&T Intellectual Property. All other rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,9 +15,9 @@ # limitations under the License. # -# Script to install region server. +# Script to install OS on baremetal server. # -# usage: ./install_regionserver.sh [--rc settingsfile] [--no-confirm] [--no-apply-hw] [--help] +# usage: ./install_server_os.sh [--rc settingsfile] [--no-confirm] [--no-apply-hw] [--help] # Define Variables # @@ -113,9 +113,7 @@ if [ -z "$BUILD_WEBIP" ]; then fi # SET ADDITIONAL VARIABLES BASED ON RC FILE -IPXE_VLAN=$SRV_VLAN -IPXE_INTF=$SRV_IPXE_INF -IPXE_URL=http://$BUILD_WEBIP:$BUILD_WEBPORT/ipxe-$SRV_IPXE_INF-$SRV_VLAN.efi +IPXE_URL=http://$BUILD_WEBIP:$BUILD_WEBPORT/ipxe.efi SRV_FIRSTBOOT_TEMPLATE=${SRV_FIRSTBOOT_TEMPLATE:-firstboot.sh.template} if [ -z "$NO_CONFIRM" ]; then @@ -175,6 +173,7 @@ case $SRV_OEM in echo "ERROR: Unable to get Dell nic mac address from [$SRV_OOB_IP]" exit 1; fi + echo "Using SRV_MAC [$SRV_MAC] for nic [$SRV_HTTP_BOOT_DEV]" fi ;; HP|HPE) @@ -197,8 +196,8 @@ if [ "$?" -ne 0 ]; then fi ## CREATE IPXE FILE -echo "Creating ixpe.efi for web root in folder [$WEB_ROOT] using interface [$SRV_IPXE_INF] and vlan [$SRV_VLAN]" -if ! (IPXE_VLAN=$SRV_VLAN IPXE_INTF=$SRV_IPXE_INF $REDFISH_ROOT/create_ipxe.sh); then +echo "Creating ixpe.efi for web root in folder [$WEB_ROOT] using interface [$SRV_MAC] and vlan [$SRV_VLAN]" +if ! . $REDFISH_ROOT/create_ipxe.sh; then echo "ERROR: failed to add ipxe file to web root" exit 1 fi @@ -263,13 +262,11 @@ subnet $SRV_SUBNET netmask $SRV_NETMASK { option subnet-mask $SRV_NETMASK; option routers $SRV_GATEWAY; option domain-name-servers $SRV_DNSCSV; - option domain-name "$SRV_DOMAIN"; - option ipxe-web-server "$BUILD_WEBIP:$BUILD_WEBPORT"; } EOF if ! route -n | grep "$SRV_SUBNET" | grep " U " >/dev/null ; then - echo "Subner [$SRV_SUBNET] is not a local network, attempting to find local subnet for dhcp service" + echo "Subnet [$SRV_SUBNET] is not a local network, attempting to find local subnet for dhcp service" echo "The dhcp service requires at least one subnet in the configuration to be a local subnet" LOCAL_INF=$(ip route get $SRV_IP | grep "$SRV_IP" | awk '{print $3}') LOCAL_SUBNET=$(route -n | grep " U " | grep "$LOCAL_INF" | head -n 1 | awk '{print $1}') @@ -288,12 +285,6 @@ EOF fi fi -## CHECK THAT SRV_BLD_SCRIPT EXISTS -if [ ! -f "$WEB_ROOT/$SRV_BLD_SCRIPT" ]; then - echo "ERROR: Missing SRV_BLD_SCRIPT [$SRV_BLD_SCRIPT] from web root [$WEB_ROOT]" - exit 1 -fi - echo "Updating dhcp configuration [$DHCP_ROOT/dhcpd.conf] with server [$SRV_NAME]" ## DELETE ANY HOST ENTRY WITH THE SAME MAC ADDRESS OR NAME perl -i -p0e "s/^host.*?$SRV_MAC.*?\n\}\n//gms" $DHCP_ROOT/dhcpd.conf @@ -303,12 +294,10 @@ host $SRV_NAME { hardware ethernet $SRV_MAC; fixed-address $SRV_IP; option host-name $SRV_NAME; - option ipxe-interface "$SRV_BLD_INF"; - if substring (option vendor-class-identifier,0,9) = "PXEClient" { - filename "http://$BUILD_WEBIP:$BUILD_WEBPORT/$SRV_BLD_SCRIPT"; - } } EOF +## DELETE ANY HOST ENTRY MISSING HOSTNAME WHICH WILL PREVENT DHCPD FROM STARTING +perl -i -p0e "s/^host \s*?{.*\n}\n//gms" $DHCP_ROOT/dhcpd.conf ## START/RESTART DHCP SERVICE echo "Starting dhcp server using folder [$DHCP_ROOT] on interface [$BUILD_INTERFACE]" @@ -444,3 +433,4 @@ exec 1>&- exit 0 + diff --git a/script.ipxe.template b/script.ipxe.template deleted file mode 100644 index 8b967af..0000000 --- a/script.ipxe.template +++ /dev/null @@ -1,34 +0,0 @@ -#!ipxe -# -# Copyright 2018 AT&T Intellectual Property. All other rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -set web-server ${128:string} -set base-url http://${web-server} -set interface ${129:string} - -echo Using vlan [${vlan}] nic [${nic}] from embedded boot.ipxe -echo Using base-url [${base-url}] and interface [${interface}] -echo Starting Ubuntu Xenial installer for [${mac}] on [${hostname}] - -prompt --key 0x02 --timeout 15000 Press Ctrl-B for the iPXE command line... && shell || - -kernel ${base-url}/@@KERNEL@@ root=/dev/ram0 load_ramdisk=1 initrd=@@INITRD@@ showopts ramdisk_size=65535 auto=true locale=en_US hostname=${hostname} url=${base-url}/${hostname}.seed interface=${interface} netcfg/vlan_id=${vlan} base-installer/kernel/override-image=@@BASE_KERNEL@@ live-installer/net-image=${base-url}/@@UBUNTU_ROOT@@/install/filesystem.squashfs mirror/http/directory=/@@UBUNTU_ROOT@@ mirror/http/hostname=${web-server} -initrd ${base-url}/@@INITRD@@ -boot || goto failed - -:failed -echo Boot from ${base-url} failed -shell - diff --git a/serverrc.template b/serverrc.template index 70b2d8a..08a34c8 100644 --- a/serverrc.template +++ b/serverrc.template @@ -28,24 +28,18 @@ SRV_OOB_IP=192.168.41.254 SRV_OOB_USR=root SRV_OOB_PWD=calvin -# mac address of server to be used during the build - not required for Dell servers +# mac address of server to be used during the build - not required for Dell 10G servers # SRV_MAC=3c:fd:fe:b8:10:60 -# name of network interface used during build when ipxe.efi is booted and when os is booted -# ipxe numbers ports from 0-n in pci bus order. -# the netx value will depend on how many nics are in the server -# and which pci device number is assigned to the slot -SRV_IPXE_INF=net4 - # the build interface is the nic used by the Ubuntu installed to load the OS SRV_BLD_INF=enp94s0f0 # the boot device is the device name on which the OS will be loaded SRV_BOOT_DEVICE=sda -# ipxe script to use - based on the os version and kernel to install -# valid options are script-hwe-16.04.6-amd64.ipxe or script-16.04.6-amd64.ipxe -SRV_BLD_SCRIPT=script-hwe-16.04.6-amd64.ipxe +# Ubuntu kernel and version to use for os install +# valid options are hwe-16.04.6-amd64 or 16.04.6-amd64 +SRV_BLD_SCRIPT=hwe-16.04.6-amd64 # template xml file to set bios and raid configuration settings SRV_BIOS_TEMPLATE=dell_r740_g14_uefi_base.xml.template diff --git a/setup_tools.sh b/setup_tools.sh index 9f9bc52..4884c26 100755 --- a/setup_tools.sh +++ b/setup_tools.sh @@ -85,9 +85,9 @@ done if [ ! -d "$REDFISH_ROOT" ]; then echo "Installing latest tools from [$REDFISH_REPO] to [$REDFISH_ROOT]" mkdir -p $REDFISH_ROOT - curl -L "$REDFISH_REPO" | tar -xzo -C $REDFISH_ROOT + curl -L "$REDFISH_REPO" | tar -xzo -C $REDFISH_ROOT fi -if [ ! -f "$REDFISH_ROOT/boot.ipxe.template" ]; then +if [ ! -f "$REDFISH_ROOT/base.ipxe.template" ]; then echo "ERROR: failed cloning tools from [$REDFISH_GIT] to [$REDFISH_ROOT]" exit 1 fi @@ -129,3 +129,4 @@ fi echo "Tools are ready in [$AKRAINO_ROOT]" export REDFISH_TOOLS_SETUP="True" + diff --git a/update_webroot.sh b/update_webroot.sh index 280cf7f..a6914ce 100755 --- a/update_webroot.sh +++ b/update_webroot.sh @@ -64,19 +64,19 @@ fi echo "Checking iso [$UBUNTU_ISO]" ## CHECK IF ISO EXISTS -if [ -n "$UBUNTU_ISO" ] && [ ! -f $UBUNTU_ISO ]; then +if [ -n "$UBUNTU_ISO" ] && [ ! -f $UBUNTU_ISO ]; then echo "ERROR: ISO file [$UBUNTU_ISO] does not exists" exit 1 fi ## CHECK IF ISO IS VALID mkdir -p $WEB_ROOT -if [ -z $UBUNTU_ISO ] || ! xorriso --indev $UBUNTU_ISO --check-media &>/dev/null; then +if [ -z $UBUNTU_ISO ] || ! xorriso --indev $UBUNTU_ISO --check-media &>/dev/null; then echo "WARNING: ISO file [$UBUNTU_ISO] appears to be missing or corrupt. Downloading instead." xorriso --indev $UBUNTU_ISO --check-media 2>&1 | sed -e "s/^/ /g" export UBUNTU_ISO=${UBUNTU_URL##*/} echo "WARNING: Attempting to use [$UBUNTU_ISO] instead." - if ! [ -f $WEB_ROOT/$UBUNTU_ISO ]; then + if ! [ -f $WEB_ROOT/$UBUNTU_ISO ]; then echo "Downloading Ubuntu iso from [$UBUNTU_URL] to [$UBUNTU_ISO]" curl -Lo $WEB_ROOT/$UBUNTU_ISO $UBUNTU_URL else @@ -89,7 +89,7 @@ UBUNTU_ISO=$WEB_ROOT/${UBUNTU_ISO##*/} echo "Updating web root folder [$WEB_ROOT] with ubuntu iso [$UBUNTU_ISO] contents" ## CHECK AGAIN IF ISO EXISTS/IS ISO FORMAT -if [ ! -f $UBUNTU_ISO ] || ! xorriso --indev $UBUNTU_ISO --check-media &>/dev/null; then +if [ ! -f $UBUNTU_ISO ] || ! xorriso --indev $UBUNTU_ISO --check-media &>/dev/null; then echo "ERROR: ISO file [$UBUNTU_ISO] does not exists or is corrupt" xorriso --indev $UBUNTU_ISO --check-media | sed -e "s/^/ /g" exit 1 @@ -131,19 +131,7 @@ STD_INITRD=initrd-$ISO_VERSION-$ISO_ARCH cp -f $UBUNTU_FOLDER/install/netboot/ubuntu-installer/$ISO_ARCH/linux $WEB_ROOT/$STD_KERNEL gunzip -c $UBUNTU_FOLDER/install/netboot/ubuntu-installer/$ISO_ARCH/initrd.gz > $WEB_ROOT/$STD_INITRD -## CREATE SCRIPT-ISO_VERSION-ISO_ARCH.IPXE FILE -sed -e "s|@@KERNEL@@|$HWE_KERNEL|g" \ - -e "s|@@INITRD@@|$HWE_INITRD|g" \ - -e "s|@@BASE_KERNEL@@|$HWE_OIMAGE|g" \ - -e "s|@@UBUNTU_ROOT@@|$UBUNTU_ROOT|g" \ - $REDFISH_ROOT/script.ipxe.template > $WEB_ROOT/script-hwe-$ISO_VERSION-$ISO_ARCH.ipxe - -sed -e "s|@@KERNEL@@|$STD_KERNEL|g" \ - -e "s|@@INITRD@@|$STD_INITRD|g" \ - -e "s|@@BASE_KERNEL@@|$STD_OIMAGE|g" \ - -e "s|@@UBUNTU_ROOT@@|$UBUNTU_ROOT|g" \ - $REDFISH_ROOT/script.ipxe.template > $WEB_ROOT/script-$ISO_VERSION-$ISO_ARCH.ipxe - echo "Files for Ubuntu version [$ISO_VERSION] [$ISO_ARCH] are ready in folder [$WEB_ROOT]" -echo "Use script-hwe-$ISO_VERSION-$ISO_ARCH.ipxe or script-$ISO_VERSION-$ISO_ARCH.ipxe in the dhcp config depending on the kernel version required." +echo "Use hwe-$ISO_VERSION-$ISO_ARCH or $ISO_VERSION-$ISO_ARCH depending on the kernel version required." +