fix for linux standard heirarchy, fix stderr redir
This commit is contained in:
parent
a81ee1d982
commit
b1bdf665b6
14
bin/mnt
14
bin/mnt
@ -2,12 +2,13 @@
|
||||
set -e
|
||||
|
||||
DEV="/dev"
|
||||
MNT="/mnt"
|
||||
MNT="/media"
|
||||
[ -n "$SUDO" ] || SUDO="doas"
|
||||
|
||||
# preliminary checks
|
||||
[ -n "$2" ] || [ -z "$1" ] \
|
||||
&& printf "Usage: %s [device in %s/]\n" "$0" "$DEV" >>/dev/stderr \
|
||||
&& printf "Usage: %s [device in %s/]\n" \
|
||||
"$0" "$DEV" 1>&2 \
|
||||
&& exit 1 \
|
||||
|| true
|
||||
|
||||
@ -17,17 +18,20 @@ MNT="/mnt"
|
||||
|
||||
# exhaustive checks to ensure $DEV/$1 exists and that $MNT/$1 can be safely used as a mountpoint
|
||||
! [ -d "$MNT/$1" ] && [ -a "$MNT/$1" ] \
|
||||
&& printf "%s: '%s/%s' already exists, but isn't a directory.\n" "$0" "$MNT" "$1" >>/dev/stderr \
|
||||
&& printf "%s: '%s/%s' already exists, but isn't a directory.\n" \
|
||||
"$0" "$MNT" "$1" 1>&2 \
|
||||
&& exit 1 \
|
||||
|| true
|
||||
[ -d "$MNT/$1" ] \
|
||||
|| mkdir "$MNT/$1"
|
||||
! [ "$(ls -A "$MNT/$1" | wc -l | xargs echo)" = 0 ] \
|
||||
&& printf "%s: '%s/%s' is a directory, but isn't empty.\n" "$0" "$MNT" "$1" >>/dev/stderr \
|
||||
&& printf "%s: '%s/%s' is a directory, but isn't empty.\n" \
|
||||
"$0" "$MNT" "$1" 1>&2 \
|
||||
&& exit 1 \
|
||||
|| true
|
||||
! [ -e "/dev/$1" ] \
|
||||
&& printf "%s: '%s/%s' doesn't exist.\n" "$0" "$DEV" "$1" >>/dev/stderr \
|
||||
&& printf "%s: '%s/%s' doesn't exist.\n" \
|
||||
"$0" "$DEV" "$1" 1>&2 \
|
||||
&& exit 1 \
|
||||
|| true
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user