Imported Debian patch 3.0-1
[debian/gnuradio] / debian / usrp-firmware.postinst
1 #! /bin/sh
2
3 set -e
4
5 #DEBHELPER#
6
7 if [ "$1" != "configure" ]; then
8         exit 0
9 fi
10
11 #
12 # Activate any unactivated USRPs that are plugged in at install time.
13 # This is basically a duplication of the loop in /etc/hotplug/usb.rc,
14 # but Md claims it's the best solution for synthesizing hotplug events
15 # for the USRPs plugged in at installation time.
16 #
17
18 #
19 # Don't bother doing this unless we have all the firmware we need, and
20 # /sbin/hotplug working. (Rationale: If we don't have hotplug working,
21 # this will not work next boot/plugin anyhow, so it would be very confusing
22 # for the user to have it all work up _until_ the next boot/plugin.)
23 #
24 [ -r /usr/share/usrp/rev2/std_4rx_0tx.rbf ] || exit 0
25 [ -x /sbin/hotplug ] || [ -x /sbin/udevd ] || exit 0
26
27 # We need sysfs to do this.
28 [ -d /sys/bus/usb/devices/ ] || exit 0
29
30 # Go through all USB devices and find unconfigured USRPs (ie. FX2 chips).
31 for device in /sys/bus/usb/devices/[0-9]*:*; do
32     devlink=$(readlink -f $device)
33     DEVPATH=${devlink#/sys}
34
35     [ -f $devlink/../idVendor ] || continue
36     PRODUCT="$(cat $devlink/../idVendor)/$(cat $devlink/../idProduct)/$(cat $devlink/../bcdDevice)"
37
38     if [ "$PRODUCT" = "fffe/0002/0002" ] || [ "$PRODUCT" = "fffe/0002/0004" ]; then
39         /usr/bin/usrper load_standard_bits
40     fi
41 done
42
43 exit 0