summaryrefslogtreecommitdiff
path: root/bigclown-gateway/files/hotplug
blob: fb1ef59f0470d50fbb9f5fb21389f9b7afab5a1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/sh
DEVNAME="$(ls "/sys/$DEVPATH" | grep "^ttyUSB[0-9]*$")"
[ -n "$DEVNAME" ] || exit 0
[ "$ID_VENDOR" = "0403" ] || exit 0
[ "$ID_MODEL" = "6015" ] || exit 0
echo "$ID_SERIAL" | grep -q ".*bc-usb-dongle.*" || exit 0

action_add() {
	local id=0
	while [ -e "/dev/bcUD$id" ]; do
		id=$(expr $id + 1)
	done
	ln -sf "/dev/$DEVNAME" "/dev/bcUD$id"
}

action_remove() {
	local id=0
	while [ "$(readlink "/dev/bcUD$id")" = "$DEVNAME" ]; do
		[ -e "/dev/bcUD$id" ] || return 0
		id=$(expr $id + 1)
	done
	rm "/dev/bcUD$id"
}

case "$ACTION" in
	add)
		action_add
		;;
	remove)
		action_remove
		;;
esac