luci-app-modemConnectionInformation

[xujun@localhost luci-app-modemConnectionInformation]$ tree
.
├── files
│   └── root
│       ├── etc
│       │   ├── config
│       │   │   └── modemConnectionInformation
│       │   └── init.d
│       │       └── modemConnectionInformation
│       └── usr
│           └── lib
│               └── lua
│                   └── luci
│                       ├── controller
│                       │   └── modemConnectionInformation.lua
│                       └── model
│                           └── cbi
│                               └── modemConnectionInformation.lua
└── Makefile

12 directories, 5 files

[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<792799761@qq.com>

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


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值