[xujun@localhost luci-app-modemConnectionInformation]$
Makefile
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-modemConnectionInformation
PKG_VERSION=1.0
PKG_RELEASE:=1
PKG_MAINTAINER:=xujun<[email protected]>
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
include $(INCLUDE_DIR)/package.mk
define Package/luci-app-modemConnectionInformation
SECTION:=luci
CATEGORY:=LuCI
SUBMENU:=3. Applications
TITLE:=modemConnectionInformation for LuCI
PKGARCH:=all
endef
define Package/luci-app-modemConnectionInformation/description
This package contains LuCI configuration pages for modemConnectionInformation.
endef
define Build/Prepare
endef
define Build/Configure
endef
define Build/Compile
endef
define Package/luci-app-modemConnectionInformation/install
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/model/cbi
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/controller
$(INSTALL_CONF) ./files/root/etc/config/modemConnectionInformation $(1)/etc/config/modemConnectionInformation
$(INSTALL_BIN) ./files/root/etc/init.d/modemConnectionInformation $(1)/etc/init.d/modemConnectionInformation
$(INSTALL_DATA) ./files/root/usr/lib/lua/luci/model/cbi/modemConnectionInformation.lua $(1)/usr/lib/lua/luci/model/cbi/modemConnectionInformation.lua
$(INSTALL_DATA) ./files/root/usr/lib/lua/luci/controller/modemConnectionInformation.lua $(1)/usr/lib/lua/luci/controller/modemConnectionInformation.lua
endef
$(eval $(call BuildPackage,luci-app-modemConnectionInformation))
files/root/etc/config/modemConnectionInformation
config modemConnectionInformation
option apn ''
files/root/etc/init.d/modemConnectionInformation
#!/bin/sh /etc/rc.common
START=75
STOP=10
modemConnectionInformation() {
local apn
local user
local password
local auth
local pincode
config_get apn $1 apn
config_get user $1 user
config_get password $1 password
config_get auth $1 auth
config_get pincode $1 pincode
pidof quectel-CM | awk '{print $2}' > /tmp/quectel-CM
PID=$(cat /tmp/quectel-CM)
rm /tmp/quectel-CM
if [ ! $PID ]; then
if [ "$apn"x = ""x ]; then
quectel-CM &
else
if [ "$pincode"x = ""x ]; then
if [ "$user"x = ""x ]; then
quectel-CM -s $apn &
else
quectel-CM -s $apn $user $password $auth &
fi
else
if [ "$user"x = ""x ]; then
quectel-CM -s $apn -p $pincode &
else
quectel-CM -s $apn $user $password $auth -p $pincode &
fi
fi
fi
else
echo "quectel-CM: is already running"
fi
}
start()
{
config_load modemConnectionInformation
config_foreach modemConnectionInformation modemConnectionInformation
}
stop() {
killall quectel-CM
}
files/root/usr/lib/lua/luci/controller/modemConnectionInformation.lua
module("luci.controller.modemConnectionInformation", package.seeall)
function index()
entry({"admin", "services", "modemConnectionInformation"}, cbi("modemConnectionInformation"), _("Modem Connection Information"), 101)
end
files/root/usr/lib/lua/luci/model/cbi/modemConnectionInformation.lua
require("luci.sys")
m = Map("modemConnectionInformation", translate("Modem Connection Information"), translate("Please fill out the entries below."))
s = m:section(TypedSection, "modemConnectionInformation", "")
s.addremove = false
s.anonymous = true
apn = s:option(Value, "apn", translate("APN"))
apn.optional = false
apn.rmempty = true
user = s:option(Value, "user", translate("PAP/CHAP username"))
user.optional = false
user.rmempty = true
password = s:option(Value, "password", translate("PAP/CHAP password"))
password.optional = false
password.rmempty = true
password.password = true
auth = s:option(ListValue, "auth", translate("Authentication Protocol"))
auth:value("0", "None")
auth:value("1", "PAP")
auth:value("2", "CHAP")
auth.default = "0"
pincode = s:option(Value, "pincode", translate("PIN code"))
pincode.optional = false
pincode.rmempty = true
local apply = luci.http.formvalue("cbi.apply")
if apply then
io.popen("/etc/init.d/modemConnectionInformation restart")
end
return m