From 430945d42063482cc2485dfec541a851df4f7556 Mon Sep 17 00:00:00 2001 From: Arun Prakash Jana Date: Thu, 18 Apr 2019 23:48:18 +0530 Subject: Plugin nmount: toggle mount status of a device --- plugins/nmount | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 plugins/nmount (limited to 'plugins/nmount') diff --git a/plugins/nmount b/plugins/nmount new file mode 100755 index 0000000..a0782e4 --- /dev/null +++ b/plugins/nmount @@ -0,0 +1,23 @@ +#!/usr/bin/env sh + +# Description: Toggle mount status of a device using pmount +# If the device is mounted, it will be unmounted and vice versa. +# +# Shell: POSIX compliant +# Author: Arun Prakash Jana + +lsblk +echo +echo -n "device (e.g. sdc2): " +read dev +echo + +if grep -qs "$dev " /proc/mounts; then + pumount "$dev" + echo $dev unmounted. +else + pmount "$dev" + echo "$dev" mounted to "$(lsblk -n /dev/"$dev" | rev | cut -d' ' -f1 | rev)". +fi + +read dummy -- cgit v1.2.3-70-g09d2