From 9fdc5c3f07e3592fed8ef4202f6c1362ed773a9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Fri, 6 Apr 2018 18:49:43 +0200 Subject: personal-utils: fix gentoo-mount prints and check for DIR --- sys-apps/personal-utils/files/gentoo-mount | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'sys-apps/personal-utils/files/gentoo-mount') diff --git a/sys-apps/personal-utils/files/gentoo-mount b/sys-apps/personal-utils/files/gentoo-mount index f3cd674..812d7d5 100755 --- a/sys-apps/personal-utils/files/gentoo-mount +++ b/sys-apps/personal-utils/files/gentoo-mount @@ -35,6 +35,10 @@ if [ $(id -u) != 0 ]; then echo "This script has to be run only as root." >&2 exit 1 fi +if [ ! -d "$DIR" ]; then + echo "No DIR specified or no such directory exists: $DIR" >&2 + exit 1 +fi # Interactive mount @@ -48,13 +52,13 @@ imount() { return mount -o "$3" "$1" "$2" fi - echo "\e[1;32mPlease choose device\e[0m" + echo -e "\e[1;32mPlease choose device\e[0m" lsblk -o NAME,LABEL,SIZE,FSTYPE,MOUNTPOINT while true; do echo -n "Device: /dev/" read DEVICE if [ ! -b "/dev/$DEVICE" ]; then - echo "No such device: /dev/$DEVICE" >&2 + echo -e "No such device: /dev/$DEVICE" >&2 else break fi @@ -66,7 +70,7 @@ imount() { while [ -e "/dev/mapper/$CSNAME" ]; do CSNAME="${CSNAME}2" done - echo "\e[1;32mOpening encrypted filesystem\e[0m" + echo -e "\e[1;32mOpening encrypted filesystem\e[0m" cryptsetup open "/dev/$DEVICE" "$CSNAME" DEVICE="mapper/$CSNAME" fi @@ -83,7 +87,7 @@ imount() { local TMP="$(mktemp -d)" mount "/dev/$DEVICE" "$TMP" while true; do - echo "\e[1;32mPlease choose subvolume\e[0m" + echo -e "\e[1;32mPlease choose subvolume\e[0m" btrfs subvolume list -t "$TMP" # TODO default value? Probably same as name? echo -n "Subvolume: " @@ -102,24 +106,24 @@ imount() { } # Mount root filesystem ########################################################## -echo "\e[1;34mMount root filesystem\e[0m" +echo -e "\e[1;34mMount root filesystem\e[0m" imount "$DEV_ROOT" "$DIR" "" root # Mount system paths ############################################################# -echo "\e[1;34mMount system paths\e[0m" +echo -e "\e[1;34mMount system paths\e[0m" mount -t proc /proc "$DIR/proc" mount --rbind /dev "$DIR/dev" mount --rbind /sys "$DIR/sys" # Copy current resolv.conf ####################################################### -echo "\e[1;34mCopy system resolv.conf\e[0m" +echo -e "\e[1;34mCopy system resolv.conf\e[0m" cp /etc/resolv.conf "$DIR/etc/resolv.conf" # Mount boot partition ########################################################### -echo "\e[1;34mMount boot partition\e[0m" +echo -e "\e[1;34mMount boot partition\e[0m" imount "$DEV_BOOT" "$DIR/boot" # Mount home partition ########################################################### -echo "\e[1;34mMount home partition\e[0m" +echo -e "\e[1;34mMount home partition\e[0m" imount "$DEV_HOME" "$DIR/home" -- cgit v1.2.3