From 0715862fa51b69fcab60c76b5506d258e08586f5 Mon Sep 17 00:00:00 2001 From: Kristine Bujold Date: Mon, 26 Nov 2018 13:53:44 -0500 Subject: [PATCH] PXE Boot Server robustness This commits add the creation of a symlink for EFI/grub.cfg. It also allows the user to overwrite an existing directory, the user will be prompted to confirm this action. Closes-Bug: 1794863 Change-Id: I566a3b39c601921cd73cca3f291f43e5dc0ef626 Signed-off-by: Kristine Bujold --- bsp-files/pxeboot_setup.sh | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/bsp-files/pxeboot_setup.sh b/bsp-files/pxeboot_setup.sh index 08563738..95a2f169 100755 --- a/bsp-files/pxeboot_setup.sh +++ b/bsp-files/pxeboot_setup.sh @@ -65,7 +65,10 @@ if [ ! -d ${COPY_DIR} ] ; then fi else echo "$COPY_DIR already exists" - exit 0 + read -p "WARNING: Files in this folder will get overwritten, continue? [y/N] " confirm + if [[ "${confirm}" != "y" ]]; then + exit 1 + fi fi #Copy the vmlinuz and initrd files to the destination directory @@ -89,6 +92,11 @@ cp -Rf ${COPY_DIR}/pxeboot/* ${COPY_DIR}/ #Rename the UEFI grub config mv ${COPY_DIR}/pxeboot_grub.cfg ${COPY_DIR}/grub.cfg +#Create a symlink of the UEFI grub config, the bootloader could be also looking +#for it under the EFI/ folder depending on if the PXE Server is configured with a +#TFTP Server or dnsmasq +ln -sf ../grub.cfg ${COPY_DIR}/EFI/grub.cfg + #Variable replacement sed -i "s#xxxHTTP_URLxxx#${BASE_URL}#g; s#xxxHTTP_URL_PATCHESxxx#${BASE_URL}/patches#g; @@ -105,7 +113,11 @@ rm -Rf ${COPY_DIR}/pxeboot if [ -n "$TFTP_DIR" ]; then #Create pxelinux.cfg directory and default link - mkdir ${TFTP_DIR}/pxelinux.cfg + if [ ! -d ${TFTP_DIR}/pxelinux.cfg ] ; then + mkdir ${TFTP_DIR}/pxelinux.cfg + fi chmod 755 ${TFTP_DIR}/pxelinux.cfg - ln -s ../pxeboot.cfg ${TFTP_DIR}/pxelinux.cfg/default + ln -sf ../pxeboot.cfg ${TFTP_DIR}/pxelinux.cfg/default fi + +echo "The setup is complete"