2 # part of usb_modeswitch 2.0.1
5 if [ ! -e /var
/lib
/usb_modeswitch
/$1 ]; then
10 if [ $
(expr "$line" : "$2:$3") != 0 ]; then
13 done </var
/lib
/usb_modeswitch
/$1
14 if [ $
(expr "$line" : "$2:$3") != 0 ]; then
20 if [ $
(expr "$1" : "--.*") ]; then
30 if [ "$v_id" = "0x" ]; then
34 v_id
="$(printf %04x $(($v_id)))"
35 p_id
="$(printf %04x $(($p_id)))"
40 PATH
=/sbin
:/usr
/sbin
:$PATH
44 dir
=$
(ls -d /sys
$2/ttyUSB
* 2>/dev
/null
)
46 if [ ! -z "$dir" ]; then
50 device_in
"bind_list" $v_id $p_id
51 if [ "$?" = "1" ]; then
52 id_attr
="/sys/bus/usb-serial/drivers/option1/new_id"
53 if [ ! -e "$id_attr" ]; then
54 modprobe option
2>/dev
/null || true
56 if [ -e "$id_attr" ]; then
57 echo "$v_id $p_id ff" > $id_attr
59 modprobe
-r usbserial
2>/dev
/null
60 modprobe usbserial
"vendor=0x$v_id" "product=0x$p_id" 2>/dev
/null
67 device_in
"link_list" $v_id $p_id
68 if [ "$?" = "1" ]; then
69 if [ -e "/usr/sbin/usb_modeswitch_dispatcher" ]; then
70 exec usb_modeswitch_dispatcher
$1 $2 2>>/dev
/null
76 exec 1<&- 2<&- 5<&- 7<&-
79 while [ $count != 0 ]; do
80 if [ ! -e "/usr/sbin/usb_modeswitch_dispatcher" ]; then
84 if [ -e "/etc/init/usb-modeswitch-upstart.conf" ]; then
85 exec /sbin
/initctl emit
--no-wait usb-modeswitch-upstart UMS_PARAM
=$1
86 elif [ -e "/etc/systemd/system/usb_modeswitch@.service" ]; then
87 exec /usr
/bin
/systemctl
--no-block start usb_modeswitch@
$1.service
89 exec /usr
/sbin
/usb_modeswitch_dispatcher
--switch-mode $1 &