From c3e82555466f5ed781c0b043906627b3e8366a24 Mon Sep 17 00:00:00 2001 From: Stefan Mavrodiev Date: Wed, 9 May 2018 16:39:08 +0300 Subject: [PATCH] Auto-detect root partition --- .../teres1-lcd-hdmi-switch/change-display | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/SOFTWARE/A64-TERES/teres1-lcd-hdmi-switch/change-display b/SOFTWARE/A64-TERES/teres1-lcd-hdmi-switch/change-display index 1bcad276..da27ac63 100644 --- a/SOFTWARE/A64-TERES/teres1-lcd-hdmi-switch/change-display +++ b/SOFTWARE/A64-TERES/teres1-lcd-hdmi-switch/change-display @@ -5,12 +5,26 @@ if [[ $EUID -ne 0 ]]; then exit 1 fi +# Find root device +for cmd in $(cat /proc/cmdline); do + [[ $(cut -d'=' -f1 <<< $cmd) == "root" ]] && \ + root_device=$(cut -d'=' -f2 <<< $cmd) && \ + boot_device="${root_device%?}1" && break +done +[[ -z $boot_device ]] && echo "Unknown boot device. Exiting..." >&2 && exit 1 + +# Make sure correct boot partition is mounted +df | grep -q $boot_device && umount /boot +mount $boot_device /boot + choices=$(dialog \ --title "Configure display output" \ --menu "\nChoose an option: \n" 10 60 7 \ 1 "Enable HDMI display output" \ - 2 "Enable LCD display output" 2>&1 >/dev/tty) + 2 "Enable LCD display output" \ + 2>&1 >/dev/tty) +[[ -z $choices ]] && exit 0 for choice in $choices do case $choice in @@ -28,8 +42,6 @@ do esac done - - # Display reboot confirmation dialog \ --title "Almost done" \