commit b4501dd6ea82c9ae18cd8f6551974df176ce5696 Author: bytewerk Date: Sun May 17 04:26:38 2015 +0200 initial commit diff --git a/mountUSB.sh b/mountUSB.sh new file mode 100644 index 0000000..9669e10 --- /dev/null +++ b/mountUSB.sh @@ -0,0 +1,15 @@ +#!/bin/sh +device=$1 + +if [ ${#device} -gt "3" ]; then + label=$(blkid "/dev/$device" -s LABEL -o value) + if [ ${#label} -gt "0" ]; then + mountName="$label" + else + mountName="$device" + fi +fi + +mkdir -p "/media/$mountName" +mount -o ro "/dev/disk/by-uuid/$(blkid "/dev/$device" -s UUID -o value)" "/media/$mountName" +echo "Mounted $(blkid "/dev/$device" -s UUID -o value) to $mountName inside media" diff --git a/udev.rule b/udev.rule new file mode 100644 index 0000000..29ee300 --- /dev/null +++ b/udev.rule @@ -0,0 +1 @@ +ACTION=="add", SUBSYSTEMS=="usb", KERNEL=="sd*", RUN+="/root/mountUSB.sh %k"