blob: 23e0456af51f188619e913da059928b6c9159a74 (
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][0-9]); 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
|