summaryrefslogtreecommitdiffstats
path: root/meta-agl-profile-core/recipes-support/udisks/files/automount.sh
blob: 90a510c967febd00337249468568a1d0cff3bcd2 (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"

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