config/shell: improve mount handling

This commit is contained in:
xeruf 2022-01-08 21:47:30 +01:00
parent 675304b919
commit 899b023b81
3 changed files with 12 additions and 3 deletions

View File

@ -359,7 +359,6 @@ mvx() {
yadm add "$1" ".config/$1" 2>/dev/null
}
# Create directory and move into it
mkcd() {
mkdir -p "$1" && cd "$1"
@ -370,9 +369,10 @@ mkcd() {
umoul() {
if test "$1"
then arg="$1"
mountpoint="$(test -d "$arg" && realpath "$arg" || echo "${XDG_RUNTIME_DIR}/mnt/$arg")"
mountpoint="$(test -d "$arg" && realpath "$arg" || echo "${MNT:-${XDG_RUNTIME_DIR}/mnt}/$arg")"
mountpoint "$mountpoint" 2>/dev/null || test -b "$mountpoint" ||
mountpoint="$(mount --show-labels | grep "$arg" | cut -d' ' -f3)"
test "$mountpoint" || return 1
else mountpoint="$PWD"
while test "$mountpoint" != "/"; do
mountpoint "$mountpoint" >/dev/null && break

View File

@ -11,7 +11,7 @@ then
exit $code
fi
if grep -e "LABEL=$arg[^\w/]" /etc/fstab
if grep -e "^LABEL=$arg[^\w/]" /etc/fstab
then mount -L "$@"; exit $?
fi
if grep -e "[^\w=/]$arg[^\w/]" /etc/fstab

9
.local/bin/scripts/update-e2b Executable file
View File

@ -0,0 +1,9 @@
#!/bin/sh
# Update an Easy2Boot USB Stick after adding ISOs
# To be called with target as arg
dir="${1:-${MNT:-${XDG_RUNTIME_DIR}/mnt}/E2B}"
find "$dir" -name "*32-*.iso" -exec mv -v {} {}def32 \;
find "$dir" -name "*.iso" -exec mv -v {} {}def64 \;
drive=$(mount | grep "$dir" | cut -d' ' -f1)
sudo umount $drive
sudo udefrag $drive