1 #!/bin/sh /etc/rc.common
6 adb
-s "$serial" shell
"( $1 ) >/dev/null 2>&1"'; printf "\nEXIT_CODE: %i\n" $?' |
head -c 64 |
grep -qx 'EXIT_CODE: 0\r\?'
10 logger
-t adb-enablemodem
'INFO: waiting for device'
12 serial
="$(adb get-serialno)"
14 vendor_id
="$(adb -s "$serial" shell 'uci get product.usb.vid' | head -c 16 | tr -d '\r\n')"
15 product_id
="$(adb -s "$serial" shell 'uci get product.usb.pid' | head -c 16 | tr -d '\r\n')"
17 case "$vendor_id:$product_id" in
18 "0x2357:0x000D") # TP-LINK LTE MODULE
22 chmod +x /WEBSERVER/www/cgi-bin/*
23 fds="$(ls /proc/$$/fd | grep -v "^[012]$")"
27 start-stop-daemon -x httpd -S -- -h /WEBSERVER/www/
29 logger
-t adb-enablemodem
'INFO: httpd on modem started'
31 logger
-t adb-enablemodem
'ERROR: failed to start httpd on modem'
33 option_newid
='/sys/bus/usb-serial/drivers/option1/new_id'
34 if [ -e "$option_newid" ]; then
35 printf '%s %s' "$vendor_id" "$product_id" > "$option_newid"
39 if adb_exec
'start-stop-daemon -x httpd -K'; then
40 logger
-t adb-enablemodem
'INFO: httpd on modem stopped'
42 logger
-t adb-enablemodem
'ERROR: failed to stop httpd on modem'
48 logger
-t adb-enablemodem
"ERROR: unknown device $vendor_id:$product_id"
54 ( enablemodem_do start
) &
58 ( enablemodem_do stop
) &
62 ( enablemodem_do stop
; enablemodem_do start
) &