summaryrefslogtreecommitdiff
path: root/.local/bin/dmenu/mount-device
diff options
context:
space:
mode:
authorSam Chudnick <sam@chudnick.com>2023-06-11 07:56:17 -0400
committerSam Chudnick <sam@chudnick.com>2023-06-11 07:56:17 -0400
commit9e82c96713989a7565eadac505b36e3dbe91cd5a (patch)
tree7c2f998cc9d06f97bfe10ce1ee844121b662f595 /.local/bin/dmenu/mount-device
parent3adcf542289a0883924ae9b9be8b898c36702c95 (diff)
Added, removed, renamed scripts
Diffstat (limited to '.local/bin/dmenu/mount-device')
-rwxr-xr-x.local/bin/dmenu/mount-device39
1 files changed, 0 insertions, 39 deletions
diff --git a/.local/bin/dmenu/mount-device b/.local/bin/dmenu/mount-device
deleted file mode 100755
index c2decd5..0000000
--- a/.local/bin/dmenu/mount-device
+++ /dev/null
@@ -1,39 +0,0 @@
1#!/bin/sh
2# Script for mounting block devices
3
4# Set askpass program for authentication
5#export SUDO_ASKPASS=/usr/bin/ssh-askpass
6
7# Check for and get device to mount from user
8devs="$(lsblk -lpo NAME,FSTYPE,SIZE,TYPE,MOUNTPOINT | grep "part\s*$\|crypto_LUKS" | awk '{print $1,"-",$3}')"
9[ "$devs" = "" ] && exit 0
10dev="$(echo "$devs" | dmenu -i -p "Select device" | cut -d ' ' -f 1)"
11[ "$dev" = "" ] && exit 0
12
13# Open and map drive if it is encrypted
14crypt=0
15[ "$(lsblk -no FSTYPE $dev)" = "crypto_LUKS" ] && crypt=1 && \
16 mapname="$(echo -n "" | dmenu -i -p "Enter device mapper name")" && \
17 sudo cryptsetup open $dev $mapname
18
19# Attempt to mount without mountpoint for devices in /etc/fstab
20sudo mount "$dev" 2>/dev/null && exit 0
21
22# Get mountpoint from user
23mntpnt="$(find /mnt -maxdepth 3 -type d 2>/dev/null | dmenu -i -p "Select mountpoint")"
24[ "$mntpnt" = "" ] && exit 1
25
26# If selected mountpoint does not exist ask to create it
27# If user decides not to create non-existent drive, exit
28[ ! -d $mntpnt ] && create="$(echo "No\nYes" | \
29 dmenu -i -p "$mntpnt does not exist, would you like to create it?")" && \
30 ([ "$create" = "Yes" ] && sudo -A mkdir -p $mntpnt || exit 0)
31
32# Mount the device
33if [ $crypt -eq 1 ]; then
34 sudo -A mount /dev/mapper/$mapname $mntpnt && pgrep -x dunst && \
35 notify-send "$dev mounted to $mntpnt"
36else
37 sudo -A mount $dev $mntpnt && pgrep -x dunst && \
38 notify-send "$dev mounted to $mntpnt"
39fi