-
Notifications
You must be signed in to change notification settings - Fork 0
/
mnt
executable file
·21 lines (21 loc) · 818 Bytes
/
mnt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/bash
set -e
drives=$(lsblk -po "name,LABEL,FSTYPE,type,size,mountpoint")
mountPath="/home/`whoami`/mnt/"
[[ -d $mountPath ]] && : || mkdir $mountPath
echo "$drives"
echo
mount | grep /mnt | awk '{ print $1" "$3 }'
read -p "Enter disk to be mounted: " disk
echo
label=$( blkid | grep $disk | grep -Eo "LABEL=\"[a-zA-Z0-9_-]+*\"" | sed -r 's/LABEL=\"(.*?)\"/\1/' )
if [[ $label == "" ]]; then
read -p "Label not set. Please enter the folder name: " folder
[[ -d $mountPath$folder ]] && : || sudo mkdir $mountPath$folder
sudo mount /dev/$disk $mountPath$folder -o umask=000
echo drive $disk mounted on $mountPath$folder
else
[[ -d $mountPath$label ]] && : || mkdir $mountPath$label
sudo mount /dev/$disk $mountPath$label -o umask=000
echo Drive $disk with label $label mounted on $mountPath$label
fi