blob: bb0b1ae918dfdafa4ad7ad0eb7570645b23ebbd7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
#!/bin/sh
pathtoname() {
udevadm info -p /sys/"$1" | awk -v FS== '/DEVNAME/ {print $2}'
}
MOUNT_OPTIONS="ro,flush"
rmdir /media/* &> /dev/null || true
for DEVNAME in $(udisks --enumerate-device-files|grep -e sd[a-z]); do
udisks --mount-options $MOUNT_OPTIONS --mount $DEVNAME
done
stdbuf -oL -- udevadm monitor --udev -s block | while read -r -- _ _ event devpath _; do
if [ "$event" = add ]; then
DEVNAME=$(pathtoname "$devpath")
udisks --mount-options $MOUNT_OPTIONS --mount $DEVNAME
fi
done
|