source: trunk/solaris/openct-hotplug-dist @ 611

Revision 611, 1.6 KB checked in by aj, 7 years ago (diff)

Add files to make using openct on solaris easier.

  • Property svn:executable set to *
Line 
1#!/bin/sh
2#
3# USB Hotplug script for OpenCT on Solaris
4#
5# This script should be run by sysevent daemon (sysevent[conf]d).
6#
7# This can be configured by issuing the followin comand as "root".
8#
9# syseventadm add -v SUNW -p ddi -c EC_devfs -s ESC_devfs_devi_add \
10#       /usr/sbin/openct-hotplug '${di.path}'
11#
12# The script will search for the applicable /dev link file for
13# the given device. If such link is found it means that the
14# device is bound in the system through the ugen device driver
15# and should be accessable by OpenCT.  An openct-control command
16# is then issued to attach the device.
17#
18OPENCT_CONTROL=/usr/sbin/openct-control
19DEVICE=$1
20
21for CNTRL0 in `ls /devices$DEVICE:[0-9a-f]*.[0-9a-f]*.cntrl0 2>/dev/null`
22do
23    #echo "CNTRL0=$CNTRL0"
24    VENDOR_PRODUCT=`echo $CNTRL0 | sed "s|/devices$DEVICE:\([0-9a-f]*\.[0-9a-f]*\).cntrl0|\1|"`
25    #echo "VENDOR_PRODUCT=$VENDOR_PRODUCT"
26    for CNTRL0_INSTANCE in `ls /dev/usb/$VENDOR_PRODUCT/*/cntrl0 2>/dev/null`
27    do
28        #echo "CNTRL0_INSTANCE=$CNTRL0_INSTANCE"
29        if `ls -l "$CNTRL0_INSTANCE" | grep "$DEVICE" >/dev/null`
30        then
31            #echo "$CNTRL0_INSTANCE points to /pci@1f,0/pci@5/usb@0,1/device@2"
32            VENDOR=`echo $VENDOR_PRODUCT | sed "s|\([0-9a-f]*\)\.\([0-9a-f]*\)|\1|"`
33            PRODUCT=`echo $VENDOR_PRODUCT | sed "s|\([0-9a-f]*\)\.\([0-9a-f]*\)|\2|"`
34            #echo "VENDOR=$VENDOR"
35            #echo "PRODUCT=$PRODUCT"
36            ID_INSTANCE=`printf "usb:%04x/%04x" 0x$VENDOR 0x$PRODUCT`
37            logger -i -p local0.notice -t openct-hotplug "$OPENCT_CONTROL attach $CNTRL0_INSTANCE $ID_INSTANCE"
38            $OPENCT_CONTROL attach $CNTRL0_INSTANCE $ID_INSTANCE
39        fi
40    done
41done
42exit 0
Note: See TracBrowser for help on using the repository browser.