fixed usb mounting script but it still requires root perms
This commit is contained in:
parent
94afcfb80f
commit
2e206acca7
21
usm
21
usm
@ -1,27 +1,24 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
mntpnt="/mnt"
|
||||||
|
|
||||||
# pick out the drive but not sda because thats the main drive
|
# pick out the drive but not sda because thats the main drive
|
||||||
choice=`lsblk -lp | \
|
choice=`lsblk -lp | \
|
||||||
grep 'disk ' | \
|
grep -e 'part $' -e "part /mnt/*"| \
|
||||||
awk '{print $1, $4}' | \
|
awk '{print $1, $4}' | \
|
||||||
dmenu -i -p 'Drive to (un)mount'`
|
dmenu -i -p 'Drive to (un)mount'`
|
||||||
if [ -z "$choice" ]; then exit; fi
|
if [ -z "$choice" ]; then exit; fi
|
||||||
|
|
||||||
# Check if it's already mounted / something was even picked
|
|
||||||
dev=`echo $choice | awk '{print $1}'`
|
dev=`echo $choice | awk '{print $1}'`
|
||||||
name="`basename $dev`"
|
name="`basename $dev`"
|
||||||
if [ -z "$dev" ]; then exit; fi
|
if [ -z "$dev" ]; then exit; fi
|
||||||
|
|
||||||
|
# Check if it's already mounted / something was even picked
|
||||||
if grep -qs "$dev" /proc/mounts;
|
if grep -qs "$dev" /proc/mounts;
|
||||||
then
|
then
|
||||||
# unmount the drive
|
# unmount the drive
|
||||||
umount "~/.mounts/$name"
|
umount $dev
|
||||||
rm -d "~/.mounts/$name"
|
rm -d "$mntpnt/$name"
|
||||||
# check if we still need the .mounts directory or nah
|
|
||||||
if [ "`ls ~/.mounts/`" ]
|
|
||||||
then
|
|
||||||
rm -d ~/.mounts/
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
# Finally we can mount the thing
|
mkdir -p "$mntpnt/$name"
|
||||||
mkdir -p "~/.mounts/$name"
|
mount "$dev" "$mntpnt/$name"
|
||||||
mount "$dev" "~/.mounts/$name"
|
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user