diff options
Diffstat (limited to 'sys-apps/personal-utils/files/gentoo-mount')
-rwxr-xr-x | sys-apps/personal-utils/files/gentoo-mount | 22 |
1 files changed, 13 insertions, 9 deletions
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" |