Imported Debian patch 3.0-1
[debian/gnuradio] / debian / usrp.hotplug
1 #! /bin/sh
2
3 GROUP=usrp
4
5 # Set the permissions for the USRP devices right.
6 set_permissions() {
7     if [ -f "$1" ]
8     then
9         if getent group $GROUP > /dev/null; then
10             chmod 660 "$DEVICE"
11             chown root.$GROUP "$1"
12         fi
13     fi
14 }
15
16 #
17 # If we do not have /sbin/hotplug, we are being called by post-sarge udev
18 # emulating hotplug. In that case, all of this is handled by our udev rules,
19 # so we don't need to duplicate the work done here.
20
21 if ! [ -x /sbin/hotplug ]; then
22     exit
23 fi
24
25 if [ "$ACTION" != "add" ]; then
26     exit
27 fi
28
29 # FIXME: Map the USB device ID to usrper's idea of "which USRP".
30 #        For now, we just assume the user only has a single one.
31
32 case $PRODUCT in
33     # USRP without loaded firmware 
34     fffe/2/2 | fffe/2/4)
35         sleep 1    # required on some machines
36         /usr/bin/usrper load_standard_bits
37         set_permissions "$DEVICE"
38     ;;
39
40     # USRP with loaded firmware
41     fffe/2/102 | fffe/2/104)
42         set_permissions "$DEVICE"
43     ;;
44 esac
45
46
47