Add vfat-label script
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Sun, 25 Apr 2010 06:54:14 +0000 (23:54 -0700)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Sun, 25 Apr 2010 06:54:14 +0000 (23:54 -0700)
This script provides an interface similar to e2label to set the labels
on vfat-formatted disks.

It's basically a pretty thin wrapper around mtools, which mitigates
mtools' awkward syntax.

vfat-label.sh [new file with mode: 0755]

diff --git a/vfat-label.sh b/vfat-label.sh
new file mode 100755 (executable)
index 0000000..5168491
--- /dev/null
@@ -0,0 +1,35 @@
+#!/bin/bash -x
+
+usage() {
+       cat <<EOF
+vfat-label.sh: shows or sets the label on a vfat disk.
+Similar to e2label.
+
+To show the label:
+vfat-label.sh <dev-name>
+
+To set the label:
+vfat-label.sh <dev-name> <label-name>
+EOF
+       exit 1
+}
+
+die() {
+       echo "$@"
+       exit 1
+}
+
+which mlabel 1>/dev/null 2>/dev/null || \
+       die "You need to install mtools for this to work."
+
+if [ "x${1}" == "x-h" ]; then
+       usage
+fi
+
+if [ $# -eq 1 ]; then
+       mlabel -i "${1}" -s ::
+elif [ $# -eq 2 ]; then
+       mlabel -i "${1}" ::${2}
+else
+       usage
+fi