From bd9a156fe821da43ab021059bd2669cd29e19f33 Mon Sep 17 00:00:00 2001 From: Matt Devo Date: Fri, 16 Oct 2015 15:27:18 -0500 Subject: [PATCH] Add option to make PXE default boot target --- cbox-firmware-update.sh | 15 ++++++++++++++- functions.sh | 20 +++++++++++++++++--- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/cbox-firmware-update.sh b/cbox-firmware-update.sh index e80ef7b..b3a6f82 100644 --- a/cbox-firmware-update.sh +++ b/cbox-firmware-update.sh @@ -16,6 +16,7 @@ cbfstoolcmd="/tmp/cbfstool" preferUSB=false useHeadless=false addPXE=false +pxeDefault=false # Must run as root if [ $(whoami) != "root" ]; then @@ -91,6 +92,11 @@ echo -e "" read -p "Add PXE network booting capability? (This is not needed for by most users) [y/N] " if [[ "$REPLY" == "y" || "$REPLY" == "Y" ]]; then addPXE=true + echo -e "" + read -p "Boot PXE by default? (will fall back to SSD/USB) [y/N] " + if [[ "$REPLY" == "y" || "$REPLY" == "Y" ]]; then + pxeDefault=true + fi fi #check for/get flashrom @@ -175,7 +181,14 @@ if [ $? -eq 0 ]; then fi #addPXE? if [ "$addPXE" = true ]; then - ${cbfstoolcmd} ${coreboot_file} add -f /tmp/10ec8168.rom -n pci10ec,8168.rom -t optionrom + ${cbfstoolcmd} ${coreboot_file} add -f /tmp/10ec8168.rom -n pci10ec,8168.rom -t optionrom + #PXE default? + if [ "$pxeDefault" = true ]; then + ${cbfstoolcmd} ${coreboot_file} extract -n bootorder -f /tmp/bootorder > /dev/null 2>&1 + ${cbfstoolcmd} ${coreboot_file} remove -n bootorder > /dev/null 2>&1 + sed -i '1s/^/\/pci@i0cf8\/pci-bridge@1c\/*@0\n/' /tmp/bootorder + ${cbfstoolcmd} ${coreboot_file} add -n bootorder -f /tmp/bootorder -t raw + fi fi #flash coreboot firmware echo -e "\nInstalling firmware: ${coreboot_file}" diff --git a/functions.sh b/functions.sh index 33bafdb..b052334 100644 --- a/functions.sh +++ b/functions.sh @@ -12,7 +12,7 @@ # #define these here for easy updating -script_date="[2015-10-15]" +script_date="[2015-10-16]" OE_version_base="OpenELEC-Generic.x86_64" OE_version_stable="5.0.8" @@ -30,6 +30,7 @@ seabios_file=${seabios_hsw_box} OE_url="http://releases.openelec.tv/" KB_url="https://www.distroshare.com/distros/download/62_64/" +pxe_optionrom="10ec8168.rom" #other globals usb_devs="" @@ -43,6 +44,7 @@ gbbflagscmd="" preferUSB=false useHeadless=false addPXE=false +pxeDefault=false #device groups device="" @@ -471,6 +473,11 @@ if [ "${coreboot_file}" == "${coreboot_hsw_box}" ]; then read -p "Add PXE network booting capability? (This is not needed for by most users) [y/N] " if [[ "$REPLY" == "y" || "$REPLY" == "Y" ]]; then addPXE=true + echo -e "" + read -p "Boot PXE by default? (will fall back to SSD/USB) [y/N] " + if [[ "$REPLY" == "y" || "$REPLY" == "Y" ]]; then + pxeDefault=true + fi fi fi @@ -510,11 +517,18 @@ if [ $? -eq 0 ]; then fi #addPXE? if [ "$addPXE" = true ]; then - curl -s -L -O "${dropbox_url}10ec8168.rom" + curl -s -L -O "${dropbox_url}${pxe_optionrom}" if [ $? -ne 0 ]; then echo_red "Unable to download PXE option ROM; PXE capability cannot be added." else - ${cbfstoolcmd} ${coreboot_file} add -f 10ec8168.rom -n pci10ec,8168.rom -t optionrom + ${cbfstoolcmd} ${coreboot_file} add -f ${pxe_optionrom} -n pci10ec,8168.rom -t optionrom + #PXE default? + if [ "$pxeDefault" = true ]; then + ${cbfstoolcmd} ${coreboot_file} extract -n bootorder -f /tmp/bootorder > /dev/null 2>&1 + ${cbfstoolcmd} ${coreboot_file} remove -n bootorder > /dev/null 2>&1 + sed -i '1s/^/\/pci@i0cf8\/pci-bridge@1c\/*@0\n/' /tmp/bootorder + ${cbfstoolcmd} ${coreboot_file} add -n bootorder -f /tmp/bootorder -t raw + fi fi fi #flash coreboot firmware