diff options
author | Roman Yeryomin <roman@advem.lv> | 2012-10-06 16:47:03 +0300 |
---|---|---|
committer | Roman Yeryomin <roman@advem.lv> | 2013-05-26 00:44:48 +0300 |
commit | 5a0e79b3b34d22b9b60941ff20d205bb55a31ab7 (patch) | |
tree | 66bca65caacf1f697994a332b71917c67f443335 /package/query3g/files/query3g.sh | |
parent | f1b3affef4622229561e9101984b34aa610831d5 (diff) |
add query3g package
Signed-off-by: Roman <roman@nomad.(none)>
Diffstat (limited to 'package/query3g/files/query3g.sh')
-rw-r--r-- | package/query3g/files/query3g.sh | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/package/query3g/files/query3g.sh b/package/query3g/files/query3g.sh new file mode 100644 index 000000000..b591d61a3 --- /dev/null +++ b/package/query3g/files/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" ]; 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 |