fwupdate: fix partition detection when /boot is unmounted

This commit is contained in:
Calin Crisan 2019-10-19 22:52:56 +03:00
parent a5a74b302c
commit 16cfb28aa9

View File

@ -97,9 +97,16 @@ function cleanup_on_exit() {
#### disk & partition devices ####
BOOT_DEV=$(mount | grep /boot | cut -d ' ' -f 1)
ROOT_DEV=${BOOT_DEV:0:-1}2
DATA_DEV=${BOOT_DEV:0:-1}3
DISK_DEV=$(mount | grep /boot | cut -d ' ' -f 1)
if [[ -n "${BOOT_DEV}" ]]; then
ROOT_DEV=${BOOT_DEV:0:-1}2
DATA_DEV=${BOOT_DEV:0:-1}3
else # boot partition not mounted, trying with data partition
DATA_DEV=$(mount | grep /data | cut -d ' ' -f 1)
BOOT_DEV=${DATA_DEV:0:-1}1
ROOT_DEV=${BOOT_DEV:0:-1}2
fi
DISK_DEV=${BOOT_DEV}
if [[ "${ROOT_DEV}" =~ ^([/a-z0-9]+)(p[0-9])$ ]]; then # e.g. /dev/mmcblk0p2
DISK_DEV=${BASH_REMATCH[1]}
elif [[ "${ROOT_DEV}" =~ ^([/a-z0-9]+)([0-9])$ ]]; then # e.g. /dev/sdc2
@ -431,8 +438,12 @@ function extract_status() {
fi
fi
if [[ -f ${FW_FILE_EXTR} && -f ${ROOT_INFO_FILE} ]]; then
echo "done"
if [[ -f ${FW_FILE_EXTR} ]]; then
if [[ -f ${ROOT_INFO_FILE} ]]; then
echo "done"
else
echo "running"
fi
fi
}