bin: update partition management utilities

This commit is contained in:
xeruf 2021-12-05 20:49:32 +01:00
parent 900e73c018
commit 9c2347e99c
2 changed files with 10 additions and 9 deletions

View File

@ -4,11 +4,11 @@ arg=$1
test "$arg" = "--help" && echo "$0 <device> [mountpoint] [options...]" && exit 0 test "$arg" = "--help" && echo "$0 <device> [mountpoint] [options...]" && exit 0
if test "$arg" = "-u" if test "$arg" = "-u"
then then
mountpoint="$2" mountpoint="$2"
sudo umount --verbose "$mountpoint" sudo umount --verbose "$mountpoint"
code=$? code=$?
sudo rm -df "$mountpoint" sudo rm -df "$mountpoint"
exit $code exit $code
fi fi
if grep -e "LABEL=$arg[^\w/]" /etc/fstab if grep -e "LABEL=$arg[^\w/]" /etc/fstab
@ -17,13 +17,14 @@ fi
if grep -e "[^\w=/]$arg[^\w/]" /etc/fstab if grep -e "[^\w=/]$arg[^\w/]" /etc/fstab
then mount "$@"; exit $? then mount "$@"; exit $?
fi fi
mountpoint="${2:-${MNT:-${XDG_RUNTIME_DIR}/mnt}/$arg}" mountpoint="${2:-${MNT:-${XDG_RUNTIME_DIR}/mnt}/$(basename "$arg")}"
if grep -e "[^\w=/]$mountpoint[^\w/]" /etc/fstab if grep -e "[^\w=/]$mountpoint[^\w/]" /etc/fstab
then shift; mount "$mountpoint" "$@"; code=$?; cd $mountpoint; exit $code then shift; mount "$mountpoint" "$@"; code=$?; cd $mountpoint; exit $code
fi fi
case "$arg" in case "$arg" in
(sd*|loop*|nvme*|mm*|md*|dm*|vg*) partition="/dev/$arg";; (sd*|loop*|nvme*|mm*|md*|dm*|vg*) partition="/dev/$arg";;
(*) partition="-L $arg";; (/dev/*) partition="$arg";;
(*) partition="-L $arg";;
esac esac
shift $(expr 2 \& $# \> 1 \| 1) shift $(expr 2 \& $# \> 1 \| 1)
#uid=$(id --user),gid=$(id --group), \ #uid=$(id --user),gid=$(id --group), \

View File

@ -6,4 +6,4 @@ case "$1" in
(*) part=$1;; (*) part=$1;;
esac esac
shift shift
sudo rlwrap parted $part "$@" fdisk $part "$@"