diff --git a/dotfiles-old/bin/mnt b/dotfiles-old/bin/mnt new file mode 100755 index 0000000..45152da --- /dev/null +++ b/dotfiles-old/bin/mnt @@ -0,0 +1,34 @@ +#!/bin/sh +set -e + +DEV="/dev" +MNT="/mnt" + +# preliminary checks +[ -n "$2" ] || [ -z "$1" ] \ + && printf "Usage: %b [device in %b/]" "$0" "$DEV" >>/dev/stderr \ + && exit 1 \ + || true +! [ "$(id -u)" = 0 ] \ + && printf "%b: This script must be run as root.\n" "$0" >>/dev/stderr \ + && exit 1 \ + || true + +# 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 "%b: '%b/%b' already exists, but isn't a directory.\n" "$0" "$MNT" "$1" >>/dev/stderr \ + && exit 1 \ + || true +[ -d "$MNT/$1" ] \ + || mkdir "$MNT/$1" +! [ "$(ls -A "$MNT/$1" | wc -c)" = 0 ] \ + && printf "%b: '%b/%b' is a directory, but isn't empty.\n" "$0" "$MNT" "$1" >>/dev/stderr \ + && exit 1 \ + || true +! [ -e "/dev/$1" ] \ + && printf "%b: '%b/%b' doesn't exist.\n" "$0" "$DEV" "$1" >>/dev/stderr \ + && exit 1 \ + || true + +# ok, we're safe +mount "$DEV/$1" "$MNT/$1" diff --git a/dotfiles-old/manifest_file b/dotfiles-old/manifest_file index 9415670..a421643 100644 --- a/dotfiles-old/manifest_file +++ b/dotfiles-old/manifest_file @@ -18,5 +18,6 @@ .config/i3status/config bin/data bin/displaym +bin/mnt bin/volume src/dmenu/config.h