-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathusb-tethering
executable file
·71 lines (57 loc) · 1.5 KB
/
usb-tethering
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
####
# Default profile
USB_IDVENDOR=0fce
USB_IDPRODUCT=7169
USB_IPRODUCT="Unknown"
USB_ISERIAL="Unknown"
USB_IMANUFACTURER="GNU/Linux Device"
USB_IFACE=""
####
# Override profile
if [ -f /etc/default/hybris-device ]; then
source /etc/default/hybris-device
fi
ANDROID_USB=/sys/class/android_usb/android0
USB_FUNCTIONS=rndis
LOCAL_IP=10.15.19.82
write() {
echo -n "$2" > "$1"
}
usb_setup() {
write $ANDROID_USB/enable 0
write $ANDROID_USB/idVendor $USB_IDVENDOR
write $ANDROID_USB/idProduct $USB_IDPRODUCT
write $ANDROID_USB/iManufacturer "$USB_IMANUFACTURER"
write $ANDROID_USB/iProduct "$USB_IPRODUCT"
write $ANDROID_USB/iSerial "$USB_ISERIAL"
write $ANDROID_USB/functions $USB_FUNCTIONS
write $ANDROID_USB/enable 1
}
usb_info() {
write $ANDROID_USB/iSerial "$1"
echo "$1" >> /var/log/usb_info.log
}
ip_setup() {
if [ -n "$USB_IFACE" ]; then
ifconfig $USB_IFACE $LOCAL_IP
return
fi
ifconfig rndis0 $LOCAL_IP && USB_IFACE=rndis0
if [ -z "$USB_IFACE" ]; then
ifconfig usb0 $LOCAL_IP && USB_IFACE=usb0
fi
if [ -z "$USB_IFACE" ]; then
usb_info "could not setup USB tethering!"
return 1
fi
usb_info "$USB_IMANUFACTURER on $USB_IFACE $LOCAL_IP"
}
dhcpd_start() {
INTERFACES="$USB_IFACE"
/usr/sbin/dhcpd -4 -q -cf /etc/hybris-usb/dhcpd.conf -pf /run/hybris-usb/dhcpd4.pid -lf /run/hybris-usb/dhcpd4.lease
}
usb_setup
ip_setup
dhcpd_start
exit $?