2
# part of usb_modeswitch 2.1.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
. /lib/udev/hotplug.functions
70
wait_for_file /usr/sbin/usb_modeswitch_dispatcher
71
exec usb_modeswitch_dispatcher $1 $2 2>>/dev/null
76
exec 1<&- 2<&- 5<&- 7<&-
78
. /lib/udev/hotplug.functions
79
wait_for_file /usr/sbin/usb_modeswitch_dispatcher
80
if [ -e "/etc/init/usb-modeswitch-upstart.conf" ]; then
81
exec /sbin/initctl emit --no-wait usb-modeswitch-upstart UMS_PARAM=$1
82
elif [ -e "/etc/systemd/system/usb_modeswitch@.service" ]; then
83
exec /usr/bin/systemctl --no-block start usb_modeswitch@$1.service
85
exec /usr/sbin/usb_modeswitch_dispatcher --switch-mode $1 &