aboutsummaryrefslogtreecommitdiff
path: root/m
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2020-10-31 00:06:23 +0100
committerJohn Ankarström <john@ankarstrom.se>2020-11-15 22:00:33 +0100
commitc1acfc730a50fe8049742ac0c2465db631262aac (patch)
tree60d49358963deaaaf4c221d9c3907e616f73b564 /m
parentf9c205bc1637004483d5e3f3734820f1a65a0eda (diff)
downloadalpine-c1acfc730a50fe8049742ac0c2465db631262aac.tar.gz
Add 'm' mount tool
Diffstat (limited to 'm')
-rwxr-xr-xm17
1 files changed, 17 insertions, 0 deletions
diff --git a/m b/m
new file mode 100755
index 0000000..6b38cfc
--- /dev/null
+++ b/m
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+if test `ls /mnt | wc -l` -gt 0
+then
+ umount /mnt && echo Drive unmounted.
+ exit 0
+fi
+
+drv=`lsblk -o name,model | awk /"${1:-U3}"/' {getline; print substr($1, 7)}'`
+if test -z "$drv"
+then
+ echo "Drive '${1:-U3}' not found." 1>&2
+ exit 1
+fi
+
+mount /dev/$drv /mnt && echo Drive mounted. && exit 0
+exit 1