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.
This commit is contained in:
Kyle Rankin 2018-12-06 15:41:20 -08:00
parent 3eb62eed1a
commit dd3f650b81
No known key found for this signature in database
GPG Key ID: 555577116BFA74B9
2 changed files with 17 additions and 8 deletions

View File

@ -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."

View File

@ -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