├── README.md ├── root └── etc │ ├── config │ └── hypermodem │ ├── uci-defaults │ └── luci-hypermodem │ └── init.d │ └── hypermodem ├── luasrc ├── controller │ └── hypermodem.lua └── model │ └── cbi │ └── hypermodem.lua ├── Makefile └── po └── zh-cn └── hypermodem.po /README.md: -------------------------------------------------------------------------------- 1 | # luci-app-hypermodem -------------------------------------------------------------------------------- /root/etc/config/hypermodem: -------------------------------------------------------------------------------- 1 | config service 2 | option device '/dev/cdc-wdm0' 3 | option ipv6 '1' 4 | option enabled '0' 5 | 6 | -------------------------------------------------------------------------------- /root/etc/uci-defaults/luci-hypermodem: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | uci -q batch <<-EOF >/dev/null 4 | delete ucitrack.@hypermodem[-1] 5 | add ucitrack hypermodem 6 | set ucitrack.@hypermodem[-1].init=hypermodem 7 | commit ucitrack 8 | EOF 9 | 10 | rm -f /tmp/luci-indexcache 11 | exit 0 12 | -------------------------------------------------------------------------------- /luasrc/controller/hypermodem.lua: -------------------------------------------------------------------------------- 1 | module("luci.controller.hypermodem", package.seeall) 2 | 3 | function index() 4 | if not nixio.fs.access("/etc/config/hypermodem") then 5 | return 6 | end 7 | 8 | entry({"admin", "network", "hypermodem"}, cbi("hypermodem"), _("Hyper Modem Server"), 80).dependent = false 9 | end 10 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2015 OpenWrt.org 3 | # 4 | # This is free software, licensed under the GNU General Public License v2. 5 | # See /LICENSE for more information. 6 | # 7 | 8 | include $(TOPDIR)/rules.mk 9 | 10 | LUCI_TITLE:=Hyper Modem Server 11 | LUCI_DEPENDS:=+luci-compat 12 | 13 | include $(TOPDIR)/feeds/luci/luci.mk 14 | 15 | # call BuildPackage - OpenWrt buildroot signature 16 | -------------------------------------------------------------------------------- /po/zh-cn/hypermodem.po: -------------------------------------------------------------------------------- 1 | msgid "" 2 | msgstr "" 3 | "Project-Id-Version: \n" 4 | "POT-Creation-Date: \n" 5 | "PO-Revision-Date: \n" 6 | "Last-Translator: momokind \n" 7 | "Language-Team: \n" 8 | "MIME-Version: 1.0\n" 9 | "Content-Type: text/plain; charset=UTF-8\n" 10 | "Content-Transfer-Encoding: 8bit\n" 11 | "Language: zh_CN\n" 12 | "X-Generator: Poedit 2.3.1\n" 13 | 14 | msgid "Base Setting" 15 | msgstr "基本设置" 16 | 17 | msgid "Hyper Modem Server" 18 | msgstr "超级移动网络拨号服务" 19 | 20 | msgid "Modem Server For OpenWrt" 21 | msgstr "OpenWrt移动网络拨号服务" 22 | 23 | msgid "Enable IPv6" 24 | msgstr "启用IPv6协商" 25 | -------------------------------------------------------------------------------- /luasrc/model/cbi/hypermodem.lua: -------------------------------------------------------------------------------- 1 | -- Copyright 2016 David Thornley 2 | -- Licensed to the public under the Apache License 2.0. 3 | 4 | mp = Map("hypermodem") 5 | mp.title = translate("Hyper Modem Server") 6 | mp.description = translate("Modem Server For OpenWrt") 7 | 8 | s = mp:section(TypedSection, "service", "Base Setting") 9 | s.anonymous = true 10 | 11 | enabled = s:option(Flag, "enabled", translate("Enable")) 12 | enabled.default = 0 13 | enabled.rmempty = false 14 | 15 | ipv6 = s:option(Flag, "ipv6", translate("Enable IPv6")) 16 | ipv6.default = 1 17 | ipv6.rmempty = false 18 | 19 | device = s:option(Value, "device", translate("Modem device")) 20 | device.rmempty = false 21 | 22 | local device_suggestions = nixio.fs.glob("/dev/cdc-wdm*") 23 | 24 | if device_suggestions then 25 | local node 26 | for node in device_suggestions do 27 | device:value(node) 28 | end 29 | end 30 | 31 | apn = s:option(Value, "apn", translate("APN")) 32 | apn.rmempty = true 33 | 34 | username = s:option(Value, "username", translate("PAP/CHAP username")) 35 | username.rmempty = true 36 | 37 | password = s:option(Value, "password", translate("PAP/CHAP password")) 38 | password.rmempty = true 39 | 40 | auth = s:option(Value, "auth", translate("Authentication Type")) 41 | auth.rmempty = true 42 | auth:value("", translate("-- Please choose --")) 43 | auth:value("both", "PAP/CHAP (both)") 44 | auth:value("pap", "PAP") 45 | auth:value("chap", "CHAP") 46 | auth:value("none", "NONE") 47 | 48 | return mp 49 | -------------------------------------------------------------------------------- /root/etc/init.d/hypermodem: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | # Copyright (C) 2006-2014 OpenWrt.org 3 | 4 | START=94 5 | STOP=13 6 | USE_PROCD=1 7 | 8 | pre_set() 9 | { 10 | [ "$(uci get network.wan.ifname)" != "$1" ] && { 11 | uci set network.wwan='interface' 12 | uci set network.wwan.ifname="$1" 13 | uci set network.wwan.proto='dhcp' 14 | if [ "$ipv6" = 1 ]; then 15 | uci set network.wwan6='interface' 16 | uci set network.wwan6.ifname="$1" 17 | uci set network.wwan6.proto='dhcpv6' 18 | uci set network.wwan6.extendprefix='1' 19 | fi 20 | uci commit network 21 | 22 | num=`uci show firewall |grep "name='wan'" |wc -l` 23 | wwan_num=`uci get firewall.@zone[$num].network |grep -w wwan |wc -l` 24 | wwan6_num=`uci get firewall.@zone[$num].network |grep -w wwan6 |wc -l` 25 | if [ "$wwan_num" = "0" ]; then 26 | uci add_list firewall.@zone[$num].network='wwan' 27 | fi 28 | if [ "$ipv6" = 1 ]; then 29 | if [ "$wwan6_num" = "0" ]; then 30 | uci add_list firewall.@zone[$num].network='wwan6' 31 | fi 32 | fi 33 | uci commit firewall 34 | 35 | ifup wwan 36 | if [ "$ipv6" = 1 ]; then 37 | ifup wwan6 38 | fi 39 | } 40 | 41 | [ "$(uci get network.wan6.ifname)" == "$1" ] && { 42 | uci set network.wan6.extendprefix='1' 43 | uci commit network 44 | } 45 | } 46 | 47 | run_dial() 48 | { 49 | local enabled 50 | config_get_bool enabled $1 enabled 51 | 52 | if [ "$enabled" = "1" ]; then 53 | local apn 54 | local user 55 | local password 56 | local auth 57 | local ipv6 58 | local device 59 | 60 | config_get apn $1 apn 61 | config_get user $1 user 62 | config_get password $1 password 63 | config_get auth $1 auth 64 | config_get ipv6 $1 ipv6 65 | config_get device $1 device 66 | 67 | devname="$(basename "$device")" 68 | devicepath="$(find /sys/class/ -name $devname)" 69 | devpath="$(readlink -f $devicepath/device/)" 70 | ifname="$( ls "$devpath"/net )" 71 | 72 | procd_open_instance 73 | procd_set_param command quectel-CM 74 | if [ "$ipv6" = 1 ]; then 75 | procd_append_param command -4 -6 76 | fi 77 | if [ "$apn" != "" ];then 78 | procd_append_param command -s $apn 79 | fi 80 | if [ "$user" != "" ]; then 81 | procd_append_param command $user 82 | fi 83 | if [ "$password" != "" ]; then 84 | procd_append_param command $password 85 | fi 86 | if [ "$auth" != "" ]; then 87 | procd_append_param command $auth 88 | fi 89 | if [ "$device" != "" ]; then 90 | procd_append_param command -i $ifname 91 | fi 92 | procd_set_param respawn 93 | procd_close_instance 94 | 95 | if [ -d /sys/class/net/rmnet_mhi0 ]; then 96 | pre_set rmnet_mhi0.1 97 | elif [ -d /sys/class/net/wwan0_1 ]; then 98 | pre_set wwan0_1 99 | elif [ -d /sys/class/net/wwan0.1 ]; then 100 | pre_set wwan0.1 101 | elif [ -d /sys/class/net/wwan0 ]; then 102 | pre_set wwan0 103 | fi 104 | fi 105 | 106 | sleep 15 107 | } 108 | 109 | service_triggers() 110 | { 111 | procd_add_reload_trigger "hypermodem" 112 | } 113 | 114 | start_service() { 115 | config_load hypermodem 116 | config_foreach run_dial service 117 | } 118 | 119 | stop_service() 120 | { 121 | killall quectel-CM >/dev/null 2>&1 122 | } 123 | --------------------------------------------------------------------------------