diff options
author | Filip Moc <lede@moc6.cz> | 2017-05-25 21:55:32 +0200 |
---|---|---|
committer | John Crispin <john@phrozen.org> | 2017-05-27 07:54:40 +0200 |
commit | 43e4e1f4a530dd9a03fdad55ef62fe9c379561bf (patch) | |
tree | 2942ac2f52067e03e3849510b538eee082b5d2c8 /package/network | |
parent | a639cbfd00a47dc55b1e4cd47897fa0a3150d0e9 (diff) | |
download | upstream-43e4e1f4a530dd9a03fdad55ef62fe9c379561bf.tar.gz upstream-43e4e1f4a530dd9a03fdad55ef62fe9c379561bf.tar.bz2 upstream-43e4e1f4a530dd9a03fdad55ef62fe9c379561bf.zip |
Move enablemodem from ramips to new package adb-enablemodem and make it used also by TL-MR6400
Signed-off-by: Filip Moc <lede@moc6.cz>
Diffstat (limited to 'package/network')
-rw-r--r-- | package/network/utils/adb-enablemodem/Makefile | 26 | ||||
-rw-r--r-- | package/network/utils/adb-enablemodem/files/adb-enablemodem | 64 |
2 files changed, 90 insertions, 0 deletions
diff --git a/package/network/utils/adb-enablemodem/Makefile b/package/network/utils/adb-enablemodem/Makefile new file mode 100644 index 0000000000..3ffc64af0a --- /dev/null +++ b/package/network/utils/adb-enablemodem/Makefile @@ -0,0 +1,26 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=adb-enablemodem +PKG_VERSION:=2017-03-05 +PKG_RELEASE:=1 + +include $(INCLUDE_DIR)/package.mk + +define Package/adb-enablemodem + SECTION:=net + CATEGORY:=Network + SUBMENU:=WWAN + TITLE:=Enable modem via adb + DEPENDS:=+adb +endef + +define Build/Compile + true +endef + +define Package/adb-enablemodem/install + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) ./files/adb-enablemodem $(1)/etc/init.d/adb-enablemodem +endef + +$(eval $(call BuildPackage,adb-enablemodem)) diff --git a/package/network/utils/adb-enablemodem/files/adb-enablemodem b/package/network/utils/adb-enablemodem/files/adb-enablemodem new file mode 100644 index 0000000000..ddfc681a08 --- /dev/null +++ b/package/network/utils/adb-enablemodem/files/adb-enablemodem @@ -0,0 +1,64 @@ +#!/bin/sh /etc/rc.common + +START=99 + +adb_exec() { + adb -s "$serial" shell "( $1 ) >/dev/null 2>&1"'; printf "\nEXIT_CODE: %i\n" $?' | head -c 64 | grep -qx 'EXIT_CODE: 0\r\?' +} + +enablemodem_do() { + logger -t adb-enablemodem 'INFO: waiting for device' + adb wait-for-device + serial="$(adb get-serialno)" + + vendor_id="$(adb -s "$serial" shell 'uci get product.usb.vid' | head -c 16 | tr -d '\r\n')" + product_id="$(adb -s "$serial" shell 'uci get product.usb.pid' | head -c 16 | tr -d '\r\n')" + + case "$vendor_id:$product_id" in + "0x2357:0x000D") # TP-LINK LTE MODULE + case "$1" in + start) + if adb_exec ' + chmod +x /WEBSERVER/www/cgi-bin/* + fds="$(ls /proc/$$/fd | grep -v "^[012]$")" + for fd in $fds; do + eval "exec $fd>&-" + done + start-stop-daemon -x httpd -S -- -h /WEBSERVER/www/ + '; then + logger -t adb-enablemodem 'INFO: httpd on modem started' + else + logger -t adb-enablemodem 'ERROR: failed to start httpd on modem' + fi + option_newid='/sys/bus/usb-serial/drivers/option1/new_id' + if [ -e "$option_newid" ]; then + printf '%s %s' "$vendor_id" "$product_id" > "$option_newid" + fi + ;; + stop) + if adb_exec 'start-stop-daemon -x httpd -K'; then + logger -t adb-enablemodem 'INFO: httpd on modem stopped' + else + logger -t adb-enablemodem 'ERROR: failed to stop httpd on modem' + fi + ;; + esac + ;; + *) + logger -t adb-enablemodem "ERROR: unknown device $vendor_id:$product_id" + ;; + esac +} + +start() { + ( enablemodem_do start ) & +} + +stop() { + ( enablemodem_do stop ) & +} + +restart() { + ( enablemodem_do stop; enablemodem_do start ) & +} + |