Debian: add controller-0 pxeboot grub menu setup utility

This update adds a new pxeboot_setup.sh script that can be used
to tailor the controller-0 BIOS and UEFI install grub menus for
for a specific lab's controller-0 target server installation.

Some controller-0 installation UEFI and BIOS grub menus' variable
replacement labels have been added to and others slightly modified
to better serve the new setup utility.

Features:

 - Updating both BIOS and EFI grub files
 - Preserves the command used to create tailored grub files
 - Preserves replaced grub files as .<name>
 - Supported variable replacements are

   xxxFEEDxxx - path between http server base and mounted iso
   xxxSYSTEMxxx - menu entry selection index ; default 2 (AIO)
   xxxINSTDEVxxx - install device name ; default /dev/sda
   xxxPXEBOOTxxx - /pxeboot offset path to bzImage/initrd
   xxxBASE_URLxxx - pxeboot server URL

Tool Usage:

The caller specifies an --input <path> argument to the debian
controller-0 installer grub file templates which contain the
above variable replacement labels.

The --output <path> argument is used to specify where to create
the variable replaced system specific grub files.

A --system <index> argument specififying the default menu entry
index to use.

The remaining arguments are used to specify various paths and
optionally the install device. Refer to the pxeboot_setup.sh
script header, code comment or full --help for more details.

Utility Arguments:

  --input   <path>
  --output  <path>
  --feed    <path>
  --pxeboot <path>
  --url     <url>
  --device  </dev/sdx>
  --system  <0..3>

Example Usage:

pxeboot_setup.sh --input /path/to/grub/template/dir
                 --output /path/to/target/iso/mount
                 --pxeboot pxeboot/offset/to/bzImage_initrd
                 --feed pxeboot/offset/to/target_feed
                 --url http://###.###.###.###
                 --instdev /dev/sde
                 --system 3

Test Plan: for both BIOS and UEFI servers

PASS: Verify End-To-End user experience using the script and menus
      from a mounted iso or feed to setup the grub install menus.

Script:

PASS: Verify grub menu selection by number and by string (default)
PASS: Verify system type install selection of all menu paths
PASS: Verify argument and option success path handling
PASS: Verify argument and option failure path handling
PASS: Verify shellcheck script static analysis
PASS: Verify saving of replaced menus as '.' files
PASS: Verify creation of command file in menus target dir
PASS: Verify default device and override handling
PASS: Verify exit 0 on success and exit 1 on failure.
PASS: Verify script usage help screen
PASS: Verify ttyS0 override to ttySx where x=0..3

Install:

PASS: Verify system install of all menu entries
PASS: Verify menu selection handling without numbered prefixes
PASS: Verify graphical and console submenu of each main menu
PASS: Verify graphical logging vs console logging

Story: 2009301
Task: 45547
Signed-off-by: Eric MacDonald <eric.macdonald@windriver.com>
Change-Id: I1faf3ea305557d990ed7b03418c45804b71878b7
This commit is contained in:
Eric MacDonald 2022-06-06 23:05:05 +00:00
parent d92914b9f2
commit 16636d9c8c
4 changed files with 397 additions and 34 deletions

View File

@ -29,6 +29,11 @@ override_dh_install:
install -v -m 644 pxe-grub.cfg.static $(ROOT)/var/pxeboot/pxelinux.cfg.files/grub.cfg.static install -v -m 644 pxe-grub.cfg.static $(ROOT)/var/pxeboot/pxelinux.cfg.files/grub.cfg.static
install -p -D -m 700 pxeboot-update.sh $(ROOT)/usr/sbin/pxeboot-update-${platform_release}.sh install -p -D -m 700 pxeboot-update.sh $(ROOT)/usr/sbin/pxeboot-update-${platform_release}.sh
# Add controller-0 pxeboot install grub menus and setup utility
install -p -D -m 644 pxeboot.cfg.debian $(ROOT)/var/pxeboot/pxelinux.cfg.files/pxeboot.cfg.debian
install -p -D -m 644 efi-pxeboot.cfg.debian $(ROOT)/var/pxeboot/pxelinux.cfg.files/efi-pxeboot.cfg.debian
install -p -D -m 755 pxeboot_setup.sh $(ROOT)/usr/sbin/pxeboot_setup.sh
# Legacy BIOS System Node Install grub menus # Legacy BIOS System Node Install grub menus
install -p -D -m 700 debian-pxe-controller-install $(ROOT)/var/pxeboot/pxelinux.cfg.files/pxe-controller-install-${platform_release} install -p -D -m 700 debian-pxe-controller-install $(ROOT)/var/pxeboot/pxelinux.cfg.files/pxe-controller-install-${platform_release}
install -p -D -m 700 debian-pxe-smallsystem-install $(ROOT)/var/pxeboot/pxelinux.cfg.files/pxe-smallsystem-install-${platform_release} install -p -D -m 700 debian-pxe-smallsystem-install $(ROOT)/var/pxeboot/pxelinux.cfg.files/pxe-smallsystem-install-${platform_release}

View File

@ -1,31 +1,53 @@
# default 20 second timeout
timeout=20 timeout=20
default=2 default='xxxSYSTEMxxx'
GRUB_HIDDEN_TIMEOUT=0 GRUB_HIDDEN_TIMEOUT=0
GRUB_TIMEOUT_STYLE='countdown' GRUB_TIMEOUT_STYLE='countdown'
menuentry 'StarlingX Debian LAT / Kickstart Boot Menu' { menuentry 'StarlingX Debian LAT / Kickstart Boot Menu' {
echo " " echo " "
} }
menuentry '1) UEFI Boot from hard drive' {
# Create a space in the menu
menuentry ' ' {
echo " "
}
menuentry 'UEFI Boot from hard drive' --id=disk {
search --set=root --label otaefi search --set=root --label otaefi
configfile /EFI/BOOT/grub.cfg configfile /EFI/BOOT/grub.cfg
} }
menuentry '2) UEFI Debian Controller Install' { submenu 'UEFI Debian Controller Install' --id=standard {
linuxefi xxxLAB_PXExxx/bzImage-std rdinit=/install defaultkernel=vmlinuz-*[!t]-amd64 instname=debian instbr=starlingx instab=0 traits=controller BOOTIF=$net_default_mac instdev=/dev/sda ks=xxxBASE_URLxxx/xxxLAB_FEEDxxx/kickstart/kickstart.cfg insturl=xxxBASE_URLxxx/xxxLAB_FEEDxxx/ostree_repo console=ttyS0,115200 console=tty1 biosdevname=0 biosplusefi=1 menuentry 'Serial Console' --id=serial {
initrdefi xxxLAB_PXExxx/initrd linuxefi xxxPXEBOOTxxx/bzImage-std rdinit=/install defaultkernel=vmlinuz-*[!t]-amd64 instname=debian instbr=starlingx instab=0 traits=controller BOOTIF=$net_default_mac instdev=xxxINSTDEVxxx ks=xxxBASE_URLxxx/xxxFEEDxxx/kickstart/kickstart.cfg insturl=xxxBASE_URLxxx/xxxFEEDxxx/ostree_repo console=ttyS0,115200 biosdevname=0 biosplusefi=1
initrdefi xxxPXEBOOTxxx/initrd
}
menuentry 'Graphical Console' --id=graphical {
linuxefi xxxPXEBOOTxxx/bzImage-std rdinit=/install defaultkernel=vmlinuz-*[!t]-amd64 instname=debian instbr=starlingx instab=0 traits=controller BOOTIF=$net_default_mac instdev=xxxINSTDEVxxx ks=xxxBASE_URLxxx/xxxFEEDxxx/kickstart/kickstart.cfg insturl=xxxBASE_URLxxx/xxxFEEDxxx/ostree_repo console=tty1 biosdevname=0 biosplusefi=1
initrdefi xxxPXEBOOTxxx/initrd
}
} }
menuentry '3) UEFI Debian All-in-one Install' { submenu 'UEFI Debian All-in-one Install' --id=aio {
linuxefi xxxLAB_PXExxx/bzImage-std rdinit=/install defaultkernel=vmlinuz-*[!t]-amd64 instname=debian instbr=starlingx instab=0 traits=controller,worker BOOTIF=$net_default_mac instdev=/dev/sda ks=xxxBASE_URLxxx/xxxLAB_FEEDxxx/kickstart/kickstart.cfg insturl=xxxBASE_URLxxx/xxxLAB_FEEDxxx/ostree_repo console=ttyS0,115200 console=tty1 biosdevname=0 biosplusefi=1 menuentry 'Serial Console' --id=serial {
initrdefi xxxLAB_PXExxx/initrd linuxefi xxxPXEBOOTxxx/bzImage-std rdinit=/install defaultkernel=vmlinuz-*[!t]-amd64 instname=debian instbr=starlingx instab=0 traits=controller,worker BOOTIF=$net_default_mac instdev=xxxINSTDEVxxx ks=xxxBASE_URLxxx/xxxFEEDxxx/kickstart/kickstart.cfg insturl=xxxBASE_URLxxx/xxxFEEDxxx/ostree_repo console=ttyS0,115200 biosdevname=0 biosplusefi=1
initrdefi xxxPXEBOOTxxx/initrd
}
menuentry 'Graphical Console' --id=graphical {
linuxefi xxxPXEBOOTxxx/bzImage-std rdinit=/install defaultkernel=vmlinuz-*[!t]-amd64 instname=debian instbr=starlingx instab=0 traits=controller,worker BOOTIF=$net_default_mac instdev=xxxINSTDEVxxx ks=xxxBASE_URLxxx/xxxFEEDxxx/kickstart/kickstart.cfg insturl=xxxBASE_URLxxx/xxxFEEDxxx/ostree_repo console=tty1 biosdevname=0 biosplusefi=1
initrdefi xxxPXEBOOTxxx/initrd
}
} }
menuentry '4) UEFI Debian All-in-one (lowlatency) Install' { submenu 'UEFI Debian All-in-one (lowlatency) Install' --id=aio-lowlat {
linuxefi xxxLAB_PXExxx/bzImage-rt rdinit=/install defaultkernel=vmlinuz-*-rt-amd64 instname=debian instbr=starlingx instab=0 traits=controller,worker,lowlatency efi=runtime BOOTIF=$net_default_mac instdev=/dev/sda ks=xxxBASE_URLxxx/xxxLAB_FEEDxxx/kickstart/kickstart.cfg insturl=xxxBASE_URLxxx/xxxLAB_FEEDxxx/ostree_repo console=ttyS0,115200 console=tty1 biosdevname=0 biosplusefi=1 menuentry 'Serial Console' --id=serial {
initrdefi xxxLAB_PXExxx/initrd linuxefi xxxPXEBOOTxxx/bzImage-rt rdinit=/install defaultkernel=vmlinuz-*-rt-amd64 instname=debian instbr=starlingx instab=0 traits=controller,worker,lowlatency efi=runtime BOOTIF=$net_default_mac instdev=xxxINSTDEVxxx ks=xxxBASE_URLxxx/xxxFEEDxxx/kickstart/kickstart.cfg insturl=xxxBASE_URLxxx/xxxFEEDxxx/ostree_repo console=ttyS0,115200 biosdevname=0 biosplusefi=1
initrdefi xxxPXEBOOTxxx/initrd
}
menuentry 'Graphical Console' --id=graphical {
linuxefi xxxPXEBOOTxxx/bzImage-rt rdinit=/install defaultkernel=vmlinuz-*-rt-amd64 instname=debian instbr=starlingx instab=0 traits=controller,worker,lowlatency efi=runtime BOOTIF=$net_default_mac instdev=xxxINSTDEVxxx ks=xxxBASE_URLxxx/xxxFEEDxxx/kickstart/kickstart.cfg insturl=xxxBASE_URLxxx/xxxFEEDxxx/ostree_repo console=tty1 biosdevname=0 biosplusefi=1
initrdefi xxxPXEBOOTxxx/initrd
}
} }

View File

@ -1,6 +1,7 @@
# default 20 second timout
timeout 200
serial 0 115200 serial 0 115200
timeout 50 default xxxSYSTEMxxx
default 4
# Menu Configuration # Menu Configuration
MENU WIDTH 80 MENU WIDTH 80
@ -15,26 +16,48 @@ MENU TIMEOUTROW 20
MENU TITLE StarlingX Debian LAT / Kickstart Boot Menu MENU TITLE StarlingX Debian LAT / Kickstart Boot Menu
label 0 label 0
menu label ^0) Boot from hard drive menu label Boot from hard drive
menu default
COM32 chain.c32 COM32 chain.c32
APPEND hd0 APPEND hd0
label 1 menu begin
menu label ^1) Debian Controller Install menu title Debian Controller Install
kernel xxxLAB_PXExxx/bzImage-std label 1
append initrd=xxxLAB_PXExxx/initrd rdinit=/install defaultkernel=vmlinuz-*[!t]-amd64 instname=debian instbr=starlingx instab=0 traits=controller instdev=/dev/sda ks=xxxBASE_URLxxx/xxxLAB_FEEDxxx/kickstart/kickstart.cfg insturl=xxxBASE_URLxxx/xxxLAB_FEEDxxx/ostree_repo console=ttyS0,115200 console=tty1 biosdevname=0 biosplusefi=1 menu label Serial Console
ipappend 2 kernel xxxPXEBOOTxxx/bzImage-std
append initrd=xxxPXEBOOTxxx/initrd rdinit=/install defaultkernel=vmlinuz-*[!t]-amd64 instname=debian instbr=starlingx instab=0 traits=controller instdev=xxxINSTDEVxxx ks=xxxBASE_URLxxx/xxxFEEDxxx/kickstart/kickstart.cfg insturl=xxxBASE_URLxxx/xxxFEEDxxx/ostree_repo console=ttyS0,115200 biosdevname=0 biosplusefi=1
ipappend 2
label 2
menu label Graphical Console
kernel xxxPXEBOOTxxx/bzImage-std
append initrd=xxxPXEBOOTxxx/initrd rdinit=/install defaultkernel=vmlinuz-*[!t]-amd64 instname=debian instbr=starlingx instab=0 traits=controller instdev=xxxINSTDEVxxx ks=xxxBASE_URLxxx/xxxFEEDxxx/kickstart/kickstart.cfg insturl=xxxBASE_URLxxx/xxxFEEDxxx/ostree_repo console=tty1 biosdevname=0 biosplusefi=1
ipappend 2
menu end
label 2 menu begin
menu label ^2) Debian All-in-one Install menu title Debian All-in-one Install
kernel xxxLAB_PXExxx/bzImage-std label 3
append initrd=xxxLAB_PXExxx/initrd rdinit=/install defaultkernel=vmlinuz-*[!t]-amd64 instname=debian instbr=starlingx instab=0 traits=controller,worker instdev=/dev/sda ks=xxxBASE_URLxxx/xxxLAB_FEEDxxx/kickstart/kickstart.cfg insturl=xxxBASE_URLxxx/xxxLAB_FEEDxxx/ostree_repo console=ttyS0,115200 console=tty1 biosdevname=0 biosplusefi=1 menu label Serial Console
ipappend 2 kernel xxxPXEBOOTxxx/bzImage-std
append initrd=xxxPXEBOOTxxx/initrd rdinit=/install defaultkernel=vmlinuz-*[!t]-amd64 instname=debian instbr=starlingx instab=0 traits=controller,worker instdev=xxxINSTDEVxxx ks=xxxBASE_URLxxx/xxxFEEDxxx/kickstart/kickstart.cfg insturl=xxxBASE_URLxxx/xxxFEEDxxx/ostree_repo console=ttyS0,115200 biosdevname=0 biosplusefi=1
label 3 ipappend 2
menu label ^2) Debian All-in-one (lowlatency) Install label 4
kernel xxxLAB_PXExxx/bzImage-rt menu label Graphical Console
append initrd=xxxLAB_PXExxx/initrd rdinit=/install defaultkernel=vmlinuz-*-rt-amd64 instname=debian instbr=starlingx instab=0 traits=controller,worker,lowlatency instdev=/dev/sda ks=xxxBASE_URLxxx/xxxLAB_FEEDxxx/kickstart/kickstart.cfg insturl=xxxBASE_URLxxx/xxxLAB_FEEDxxx/ostree_repo console=ttyS0,115200 console=tty1 biosdevname=0 biosplusefi=1 kernel xxxPXEBOOTxxx/bzImage-std
ipappend 2 append initrd=xxxPXEBOOTxxx/initrd rdinit=/install defaultkernel=vmlinuz-*[!t]-amd64 instname=debian instbr=starlingx instab=0 traits=controller,worker instdev=xxxINSTDEVxxx ks=xxxBASE_URLxxx/xxxFEEDxxx/kickstart/kickstart.cfg insturl=xxxBASE_URLxxx/xxxFEEDxxx/ostree_repo console=tty1 biosdevname=0 biosplusefi=1
ipappend 2
menu end
menu begin
menu title Debian All-in-one (lowlatency) Install
label 5
menu label Serial Console
kernel xxxPXEBOOTxxx/bzImage-rt
append initrd=xxxPXEBOOTxxx/initrd rdinit=/install defaultkernel=vmlinuz-*-rt-amd64 instname=debian instbr=starlingx instab=0 traits=controller,worker,lowlatency instdev=xxxINSTDEVxxx ks=xxxBASE_URLxxx/xxxFEEDxxx/kickstart/kickstart.cfg insturl=xxxBASE_URLxxx/xxxFEEDxxx/ostree_repo console=ttyS0,115200 biosdevname=0 biosplusefi=1
ipappend 2
label 6
menu label Graphical Console
kernel xxxPXEBOOTxxx/bzImage-rt
append initrd=xxxPXEBOOTxxx/initrd rdinit=/install defaultkernel=vmlinuz-*-rt-amd64 instname=debian instbr=starlingx instab=0 traits=controller,worker,lowlatency instdev=xxxINSTDEVxxx ks=xxxBASE_URLxxx/xxxFEEDxxx/kickstart/kickstart.cfg insturl=xxxBASE_URLxxx/xxxFEEDxxx/ostree_repo console=tty1 biosdevname=0 biosplusefi=1
ipappend 2
menu end

View File

@ -0,0 +1,313 @@
#!/bin/bash
#
# Copyright (c) 2016-2022 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
############################################################################
#
# This script is used to create lab specific controller-0 install grub menus.
# from template files through the following variable replacements.
#
# xxxPXEBOOTxxx : Replaces this string with the filesystem path between
# /pxeboot and where the kernel/initrd files are stored.
#
# example : --pxeboot vlm-boards/some_system_name/feed
#
# Will then replace all instances in template files of ...
#
# 'xxxPXEBOOTxxx' with 'vlm-boards/some_system_name/feed'
#
# xxxFEEDxxx : replace with pxeboot path to server's install feed
#
# example : --feed umalab/some_server_name_feed
#
# Will then replace all instances in template files of ...
#
# 'xxxFEEDxxx' with 'umalab/some_server_name_feed'
#
# xxxBASE_URLxxx : replace with url path to server's install feed
#
# example : --url http://###.###.###.###
#
# Will then replace all instances in template files of ...
#
# xxxBASE_URLxxx with http://###.###.###.###
#
# Optional Settings
#
# xxxINSTDEVxxx : set the install device ; defaults to /dev/sda if missing
# example : --device /dev/sde
#
# xxxSYSTEMxxx : specify the install system type ; default is AIO '2'
# example : --system 2
#
# system type values
#
# 0 - disk boot
# 1 - controller
# 2 - All-in-one (standard)
# 3 - All-in-one (lowlatency)
#
# Refer to usage function for option details.
#
############################################################################
trap ctrl_c INT
function ctrl_c {
echo "Exiting ..."
exit 1
}
# Debian Legacy BIOS and UEFI controller-0 install grub file names constants
BIOS_PXEBOOT_GRUB_FILE='pxeboot.cfg.debian'
UEFI_PXEBOOT_GRUB_FILE='efi-pxeboot.cfg.debian'
# User specified path to the menu templates directory ; default empty
MENUS_PATH=""
# server specific values
BASE_URL="" # the port based URL
FEED_PATH="" # path to the feed directory ; the mounted iso
PXE_PATH="" # offset path between /pxeboot and feed
GRUB_PATH="" # where to put the created grub files
# Optional Settings with default
INSTDEV="/dev/sda" # default install device to sda
TTY=0 # default of ttyS0
SYSTEM="" # default to menu
BIOS_SYSTEM=menu.c32 # Display the install menu by default
UEFI_SYSTEM=menu.c32 # Display the install menu by default
# The index of this array maps to the system install types specified
# by the --system option. See below.
UEFI_SYSTEM_TYPES_str=('disk' \
'standard>serial' \
'standard>graphical' \
'aio>serial' \
'aio>graphical' \
'aio-lowlat>serial' \
'aio-lowlat>graphical')
BACKUP=false
echo ""
function usage {
RC=0
[ ! -z "${1}" ] && RC="${1}"
echo ""
echo "Usage: $0 [Arguments Options]"
echo ""
echo "Arguments:"
echo ""
echo " -i | --input <input path> : Path to ${BIOS_PXEBOOT_GRUB_FILE} and ${UEFI_PXEBOOT_GRUB_FILE} grub template files"
echo " -o | --output <output path> : Path to created ${BIOS_PXEBOOT_GRUB_FILE} and ${UEFI_PXEBOOT_GRUB_FILE} grub files"
echo " -p | --pxeboot <pxeboot path> : Offset path between /pxeboot and bzImage/initrd"
echo " -f | --feed <feed path> : Offset path between http server base and mounted iso"
echo " -u | --url <pxe server url> : The pxeboot server's URL"
echo ""
echo "Options:"
echo ""
echo " -h | --help : Print this help info"
echo " -b | --backup : Create backup of updated grub files as .named files"
echo " -d | --device <install device> : Install device path ; default: /dev/sda"
echo " -s | --system <system install> : System install type ; default: 3"
echo " -t | --tty <port> : Override ttyS0 with port number 0..3 ; default 0 "
echo ""
echo " 0 = Disk Boot"
echo " 1 = Controller Install - Serial Console"
echo " 2 = Controller Install - Graphical Console"
echo " 3 = All-in-one Install - Serial Console (default)"
echo " 4 = All-in-one Install - Graphical Console"
echo " 5 = All-in-one (lowlatency) Install - Serial Console"
echo " 6 = All-in-one (lowlatency) Install - Graphical Console"
echo ""
echo ""
echo "Example:"
echo ""
echo "pxeboot_setup.sh -i /path/to/grub/template/dir"
echo " -o /path/to/target/iso/mount"
echo " -p pxeboot/offset/to/bzImage_initrd"
echo " -f pxeboot/offset/to/target_feed"
echo " -u http://###.###.###.###"
echo " -d /dev/sde"
echo " -s 5"
exit "${RC}"
}
[ "${*}" == "" ] && usage
# Process input options
script=$(basename "$0")
OPTS=$(getopt -o bd:f:hi:o:p:s:t:u: \
--long backup,device:,feed:,help,input:,output:,pxeboot:,system:,tty:,url: \
-n "${script}" -- "$@")
if [ $? != 0 ]; then
echo "Failed parsing options." >&2
usage 1
fi
eval set -- "$OPTS"
while true; do
case "$1" in
-b|--backup)
BACKUP=true
shift
;;
-d|--device)
INSTDEV="${2}"
shift 2
;;
-f|--feed)
FEED_PATH="${2}"
shift 2
;;
-h|--help)
usage 0
shift
;;
-i|--input)
MENUS_PATH="${2}"
shift 2
;;
-o|--output)
GRUB_PATH="${2}"
shift 2
;;
-p|--pxeboot)
PXE_PATH="${2}"
shift 2
;;
-t|--tty)
if echo "${2}" | grep -q -x '[0-9]\+' && [ ${2} -ge 0 ] && [ ${2} -le 3 ]; then
TTY="${2}"
else
echo "Error: ttySx where x=${2} is out of range [0..3]"
usage 1
fi
shift 2
;;
-s|--system)
if echo "${2}" | grep -q -x '[0-9]\+' && [ ${2} -ge 0 ] && [ ${2} -le 6 ]; then
SYSTEM=${2}
# UEFI: Translate the incoming system type to a string that
# specifies the 'default' menu path to be taken.
UEFI_SYSTEM="${UEFI_SYSTEM_TYPES_str[${2}]}"
# BIOS menu uses the system type number directly.
BIOS_SYSTEM="${2}"
else
echo "Error: system install type '${2}' is out of range [0..6]"
usage 1
fi
shift 2
;;
-u|--url)
BASE_URL="${2}"
shift 2
;;
--)
shift
break
;;
esac
done
if [ -z "${MENUS_PATH}" ] ; then
echo "Error: Grub file templates dir path is required: -i <path to grub file template dir>"
usage 1
elif [ ! -d "${MENUS_PATH}" ] ; then
echo "Error: Grub file templates dir ${MENUS_PATH} is not present."
usage 1
elif [ ! -e "${MENUS_PATH}/${BIOS_PXEBOOT_GRUB_FILE}" ] ; then
echo "Error: BIOS grub template file ${MENUS_PATH}/${BIOS_PXEBOOT_GRUB_FILE} is not present."
usage 1
elif [ ! -e "${MENUS_PATH}/${UEFI_PXEBOOT_GRUB_FILE}" ] ; then
echo "Error: UEFI grub template file ${MENUS_PATH}/${UEFI_PXEBOOT_GRUB_FILE} is not present."
usage 1
elif [ -z "${BASE_URL}" ]; then
echo "Error: HTTP Base pxeboot server URL is required: -u <pxe server url>"
usage 1
elif [ -z "${PXE_PATH}" ]; then
echo "Error: PXE boot path is required: -u <pxeboot path>"
usage 1
elif [ -z "${FEED_PATH}" ]; then
echo "Error: Target specific feed path is required: -f <feed path>"
usage 1
elif [ -z "${GRUB_PATH}" ]; then
echo "Error: Target specific grub path is required: -o <output path>"
usage 1
elif [ ! -d "${GRUB_PATH}" ]; then
echo "Error: Target specific grub path is missing: ${GRUB_PATH}"
usage 1
fi
cmd_file=""
if [ "${BACKUP}" = true ] ; then
# Save the command used to create these menus
# Needs to be done before the escape sequence below.
if [ -d "${GRUB_PATH}" ] ; then
cmd_file=${GRUB_PATH}/pxeboot_setup_cmd.sh
echo "${0} \\" > "${cmd_file}"
echo "-i ${MENUS_PATH} \\" >> "${cmd_file}"
echo "-o ${GRUB_PATH} \\" >> "${cmd_file}"
echo "-p ${PXE_PATH} \\" >> "${cmd_file}"
echo "-f ${FEED_PATH} \\" >> "${cmd_file}"
echo "-u ${BASE_URL} \\" >> "${cmd_file}"
if [ "${SYSTEM}" != "" ] ; then
echo "-d ${INSTDEV} \\" >> "${cmd_file}"
echo "-s ${SYSTEM}" >> "${cmd_file}"
else
echo "-d ${INSTDEV}" >> "${cmd_file}"
fi
fi
chmod 777 "${cmd_file}"
fi
#Escape paths for sed
PXE_PATH="${PXE_PATH//\//\\/}"
BASE_URL="${BASE_URL//\//\\/}"
FEED_PATH="${FEED_PATH//\//\\/}"
#Variable replacement
cp "${MENUS_PATH}"/"${BIOS_PXEBOOT_GRUB_FILE}" "${GRUB_PATH}"
sed -i "s#xxxBASE_URLxxx#${BASE_URL}#g;
s#xxxPXEBOOTxxx#${PXE_PATH}#g;
s#xxxFEEDxxx#${FEED_PATH}#g;
s#xxxINSTDEVxxx#${INSTDEV}#g;
s#xxxSYSTEMxxx#${BIOS_SYSTEM}#g;
s#ttyS0#ttyS${TTY}#g" \
"${GRUB_PATH}/${BIOS_PXEBOOT_GRUB_FILE}"
cp "${MENUS_PATH}"/"${UEFI_PXEBOOT_GRUB_FILE}" "${GRUB_PATH}"
sed -i "s#xxxBASE_URLxxx#${BASE_URL}#g;
s#xxxPXEBOOTxxx#${PXE_PATH}#g;
s#xxxFEEDxxx#${FEED_PATH}#g;
s#xxxINSTDEVxxx#${INSTDEV}#g;
s#xxxSYSTEMxxx#${UEFI_SYSTEM}#g;
s#ttyS0#ttyS${TTY}#g" \
"${GRUB_PATH}/${UEFI_PXEBOOT_GRUB_FILE}"
# leave these grub files as read/write for owner and group, read only world
chmod 664 "${GRUB_PATH}/${BIOS_PXEBOOT_GRUB_FILE}"
chmod 664 "${GRUB_PATH}/${UEFI_PXEBOOT_GRUB_FILE}"
if [ "${BACKUP}" = true ] ; then
# Save a backup of these created files
if [ -e "${GRUB_PATH}"/"${BIOS_PXEBOOT_GRUB_FILE}" ] ; then
cp -f "${GRUB_PATH}"/"${BIOS_PXEBOOT_GRUB_FILE}" "${GRUB_PATH}/.${BIOS_PXEBOOT_GRUB_FILE}"
cp -f "${GRUB_PATH}"/"${UEFI_PXEBOOT_GRUB_FILE}" "${GRUB_PATH}/.${UEFI_PXEBOOT_GRUB_FILE}"
fi
fi
tmp="The setup is complete"
if [ "${cmd_file}" != "" ] ; then
echo "${tmp} ; cmd saved to ${cmd_file}"
else
echo "${tmp}"
fi
exit 0