add automount script
This commit is contained in:
parent
4629f7d76a
commit
e63b0f9009
|
@ -0,0 +1,35 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
mountpoint="/media/video"
|
||||||
|
mountoptions="ro"
|
||||||
|
device="sda1"
|
||||||
|
|
||||||
|
if [ ! -d "$mountpoint" ]; then
|
||||||
|
sudo mkdir $mountpoint
|
||||||
|
fi
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
|
||||||
|
dev_plug_state="$(lsblk | grep $device)"
|
||||||
|
dev_mount_state="$(mount | grep $device)"
|
||||||
|
|
||||||
|
if [ ! -z "$dev_plug_state" ] && [ -z "$dev_mount_state" ]; then
|
||||||
|
echo "Mount /dev/$device on $mountpoint with options $mountoptions"
|
||||||
|
sudo mount /dev/$device $mountpoint -o $mountoptions
|
||||||
|
echo "Done!"
|
||||||
|
|
||||||
|
elif [ ! -z "$dev_plug_state" ] && [ ! -z "$dev_mount_state" ]; then
|
||||||
|
echo "/dev/$device is already mounted on $mountpoint"
|
||||||
|
|
||||||
|
elif [ -z "$dev_plug_state" ] && [ -z "$dev_mount_state" ]; then
|
||||||
|
echo "/dev/$device not plugged in and is not mounted!"
|
||||||
|
|
||||||
|
elif [ -z "$dev_plug_state" ] && [ ! -z "$dev_mount_state" ]; then
|
||||||
|
echo "/dev/$device is not plugged in and is mounted on $mountpoint"
|
||||||
|
echo "Umounting $mountpoint"
|
||||||
|
sudo umount $mountpoint
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
sleep 1
|
||||||
|
done
|
Loading…
Reference in New Issue