summaryrefslogtreecommitdiffstats
path: root/package/query3g/files/usr/bin/query3g.sh
diff options
context:
space:
mode:
authorRoman Yeryomin <roman@advem.lv>2013-07-19 09:51:19 +0300
committerRoman Yeryomin <roman@advem.lv>2013-07-19 09:51:19 +0300
commitfde05611c4f3ecf7a5d45032d8fd53cfc0420d5f (patch)
tree240f82039d9b60aed2432bfbe2d1c9101ee8a84c /package/query3g/files/usr/bin/query3g.sh
parentcc536db22b447ccd6f158066909989f43ce83e32 (diff)
parent5bfe1cdae38c39a4fe7ca891aac31233165e3531 (diff)
Merge branch 'realtek-unstable' of git://git.tet.rtu.lv/openwrt-realtek into realtek-unstable
Diffstat (limited to 'package/query3g/files/usr/bin/query3g.sh')
-rwxr-xr-xpackage/query3g/files/usr/bin/query3g.sh42
1 files changed, 42 insertions, 0 deletions
diff --git a/package/query3g/files/usr/bin/query3g.sh b/package/query3g/files/usr/bin/query3g.sh
new file mode 100755
index 000000000..33cfe2379
--- /dev/null
+++ b/package/query3g/files/usr/bin/query3g.sh
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+reset=/usr/bin/usbreset
+comgt=/usr/bin/gcom
+script=/usr/share/query3g.gcom
+
+last_reset="x"
+
+wan_proto="$(uci -q get network.wan.proto)"
+
+if [ "$wan_proto" = "3g" ]; then
+ ifdown wan
+fi
+
+for port in 0 1 2 3 4 5 6 7 8 9; do
+ for tty in $(find /sys/devices/ -name "ttyUSB$port" -type d | sort -u); do
+ [ -f "$tty/../../idProduct" ] || continue
+
+ local dir="$(cd "$tty/../.."; pwd)"
+ local uid="$(basename "$dir")"
+ local dev="/dev/$(basename "$tty")"
+ local vid="$(cat "$tty/../../idVendor")"
+ local pid="$(cat "$tty/../../idProduct")"
+
+ if [ "$last_reset" != "$vid:$pid" ] && [ "$vid:$pid" != "0685:7000" ]; then
+ last_reset="$vid:$pid"
+# $reset "$vid:$pid" >/dev/null
+
+ local try=0
+ while [ $((try++)) -lt 5 ] && [ ! -e "$dev" ]; do sleep 1; done
+ fi
+
+ if $comgt -s "$script" -d "$dev" 2>/dev/null; then
+ echo "PORT:$dev"
+ echo "VID:$vid"
+ echo "PID:$pid"
+ echo "UID:$uid"
+ exit 0
+ fi
+ done
+done
+exit 1