From dd3f650b81c93f8848c081af1a04d0773b5e9ea7 Mon Sep 17 00:00:00 2001 From: Kyle Rankin Date: Thu, 6 Dec 2018 15:41:20 -0800 Subject: [PATCH] Just load usb-storage module, not mount, bugfix in replace_config We need to handle the case where the specific config file doesn't exist, or else grep fails, so we touch the file ahead of time. Mounting the usb storage caused problems when you re-enter the menu a second time, so we will just load the storage module. --- initrd/bin/config-gui.sh | 10 +++++++++- initrd/etc/functions | 15 ++++++++------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/initrd/bin/config-gui.sh b/initrd/bin/config-gui.sh index 55b3831c..5d58e793 100755 --- a/initrd/bin/config-gui.sh +++ b/initrd/bin/config-gui.sh @@ -85,7 +85,15 @@ while true; do "u" ) whiptail --title 'Insert a USB thumb drive' \ --msgbox "Insert a USB thumb drive so we can detect the device" 16 60 - mount-usb + + enable_usb + + if ! lsmod | grep -q usb_storage; then + insmod /lib/modules/usb-storage.ko \ + || die "usb_storage: module load failed" + sleep 5 + fi + CURRENT_OPTION=`grep 'CONFIG_USB_BOOT_DEV=' /tmp/config | cut -f2 -d '=' | tr -d '"'` find /dev -name 'sd*' -o -name 'nvme*' > /tmp/filelist.txt file_selector "/tmp/filelist.txt" "Choose the default USB boot device.\n\nCurrently set to $CURRENT_OPTION." diff --git a/initrd/etc/functions b/initrd/etc/functions index e556c960..cd8e1395 100755 --- a/initrd/etc/functions +++ b/initrd/etc/functions @@ -218,18 +218,19 @@ preserve_rom() { done } replace_config() { - CONFIG_FILE=$1 - CONFIG_OPTION=$2 - NEW_SETTING=$3 + CONFIG_FILE=$1 + CONFIG_OPTION=$2 + NEW_SETTING=$3 + touch $CONFIG_FILE # first pull out the existing option from the global config and place in a tmp file - awk "gsub(\"^export ${CONFIG_OPTION}=.*\",\"export ${CONFIG_OPTION}=\\\"${NEW_SETTING}\\\"\")" /tmp/config > ${CONFIG_FILE}.tmp - awk "gsub(\"^${CONFIG_OPTION}=.*\",\"${CONFIG_OPTION}=\\\"${NEW_SETTING}\\\"\")" /tmp/config >> ${CONFIG_FILE}.tmp + awk "gsub(\"^export ${CONFIG_OPTION}=.*\",\"export ${CONFIG_OPTION}=\\\"${NEW_SETTING}\\\"\")" /tmp/config > ${CONFIG_FILE}.tmp + awk "gsub(\"^${CONFIG_OPTION}=.*\",\"${CONFIG_OPTION}=\\\"${NEW_SETTING}\\\"\")" /tmp/config >> ${CONFIG_FILE}.tmp # then copy any remaining settings from the existing config file, minus the option you changed - grep -v "^export ${CONFIG_OPTION}=" ${CONFIG_FILE} | grep -v "^${CONFIG_OPTION}=" >> ${CONFIG_FILE}.tmp + grep -v "^export ${CONFIG_OPTION}=" ${CONFIG_FILE} | grep -v "^${CONFIG_OPTION}=" >> ${CONFIG_FILE}.tmp - mv ${CONFIG_FILE}.tmp ${CONFIG_FILE} + mv ${CONFIG_FILE}.tmp ${CONFIG_FILE} } combine_configs() { sort /etc/config* | uniq > /tmp/config