dualboot: run the script only in dualboot systems

Signed-off-by: Francisco Gil <francisco.gilmartinez@digi.com>
This commit is contained in:
Francisco Gil 2022-11-17 17:08:50 +01:00
parent 6ffbbb390a
commit 0328295ea8
1 changed files with 21 additions and 19 deletions

View File

@ -14,6 +14,8 @@
#=============================================================================== #===============================================================================
dualboot_init () { dualboot_init () {
if [ "$(fw_printenv -n dualboot 2>/dev/null)" = "yes" ]; then
echo -n "Starting dualboot check: "
ACTIVE_SYSTEM="$(fw_printenv -n active_system 2>/dev/null)" ACTIVE_SYSTEM="$(fw_printenv -n active_system 2>/dev/null)"
if [ -z "${ACTIVE_SYSTEM}" ]; then if [ -z "${ACTIVE_SYSTEM}" ]; then
if grep -qs environment /proc/mtd; then if grep -qs environment /proc/mtd; then
@ -22,7 +24,7 @@ dualboot_init () {
else else
BOOT_PART="$(fw_printenv -n mmcpart 2>/dev/null)" BOOT_PART="$(fw_printenv -n mmcpart 2>/dev/null)"
BOOT_DEV="$(fw_printenv -n mmcbootdev 2>/dev/null)" BOOT_DEV="$(fw_printenv -n mmcbootdev 2>/dev/null)"
CURRENT_PART="$(ls -l /dev/disk/by-partlabel/ | grep -i mmcblk${BOOT_DEV}p${BOOT_PART} | awk '{print $9}')" CURRENT_PART="$(sed -ne 's,PARTNAME=,,g;T;p' /sys/class/block/mmcblk"${BOOT_DEV}"p"${BOOT_PART}"/uevent)"
fw_setenv active_system "${CURRENT_PART}" fw_setenv active_system "${CURRENT_PART}"
fi fi
fi fi
@ -36,13 +38,13 @@ dualboot_init () {
fw_setenv bootcount 0 fw_setenv bootcount 0
fi fi
fi fi
echo "done."
fi
} }
case "$1" in case "$1" in
start) start)
echo -n "Starting dualboot check: "
dualboot_init dualboot_init
echo "done."
;; ;;
stop) stop)
;; ;;