更新配置
This commit is contained in:
parent
313e67b7ca
commit
f7d0746d5b
43
rooter-builds/ext-huasifei/Makefile
Normal file
43
rooter-builds/ext-huasifei/Makefile
Normal file
@ -0,0 +1,43 @@
|
||||
#Owned by DairyMan@Whirlpool
|
||||
#
|
||||
#Copyright GNU act.
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=ext-huasifei
|
||||
PKG_VERSION:=1.000
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_MAINTAINER:=Created by DM/makefile by Cobia@whirlpool
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/ext-huasifei
|
||||
SECTION:=utils
|
||||
CATEGORY:=ROOter
|
||||
DEPENDS:=+luci +ext-rooter-basic +pingtest +ext-blacklist +ext-blockport \
|
||||
+extramenu +ext-domain \
|
||||
+luci-app-ddns +ddns-scripts \
|
||||
+luci-app-rootervpn +ext-wireguard \
|
||||
+webconsole +bwmon +464xlat \
|
||||
+iptables-mod-hashlimit \
|
||||
+ca-bundle +ca-certificates +libustream-wolfssl \
|
||||
+luci-app-ksmbd +usb-storage \
|
||||
+ext-p910nd +kmod-sched-cake +luci-app-nft-qos \
|
||||
+ext-command +ext-speedtest +luci-app-guestwifi \
|
||||
+openvpn-easy-rsa +openvpn-openssl \
|
||||
+ext-extra +luci-app-hotspot +luci-app-wol \
|
||||
+usbmuxd +libusbmuxd-utils +libimobiledevice-utils +kmod-usb-net-ipheth \
|
||||
+qlog +luci-ssl +usbutils +openssl-util +irqbalance +ext-splashconfig \
|
||||
+nano +picocom +wpad +wget +qfirehose
|
||||
TITLE:=ROOter support w/o MWan3 for Huasifei
|
||||
PKGARCH:=all
|
||||
endef
|
||||
|
||||
define Package/ext-huasifei/description
|
||||
Helper scripts to enable ROOter support for Huasifei
|
||||
endef
|
||||
|
||||
|
||||
define Build/Compile
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,ext-huasifei))
|
30
rooter-builds/ext-huasifei16/Makefile
Normal file
30
rooter-builds/ext-huasifei16/Makefile
Normal file
@ -0,0 +1,30 @@
|
||||
#Owned by DairyMan@Whirlpool
|
||||
#
|
||||
#Copyright GNU act.
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=ext-huasifei16
|
||||
PKG_VERSION:=1.000
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_MAINTAINER:=Created by DM/makefile by Cobia@whirlpool
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/ext-huasifei16
|
||||
SECTION:=utils
|
||||
CATEGORY:=ROOter
|
||||
DEPENDS:=+ext-huasifei \
|
||||
+luci-app-mwan3 +luci-app-dnsmasq-ipset
|
||||
TITLE:=ROOter support w/o MWan3 for Huasifei
|
||||
PKGARCH:=all
|
||||
endef
|
||||
|
||||
define Package/ext-huasifei16/description
|
||||
Helper scripts to enable ROOter support for Huasifei
|
||||
endef
|
||||
|
||||
|
||||
define Build/Compile
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,ext-huasifei16))
|
37
rooter-builds/ext-rbsxtr/Makefile
Normal file
37
rooter-builds/ext-rbsxtr/Makefile
Normal file
@ -0,0 +1,37 @@
|
||||
#Owned by DairyMan@Whirlpool
|
||||
#
|
||||
#Copyright GNU act.
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=ext-rbsxtr
|
||||
PKG_VERSION:=1.000
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_MAINTAINER:=Created by DM/makefile by Cobia@whirlpool
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/ext-rbsxtr
|
||||
SECTION:=utils
|
||||
CATEGORY:=ROOter
|
||||
DEPENDS:=+luci +luci-compat +ext-rooter-basic \
|
||||
+luci-app-rootervpn +ext-wireguard \
|
||||
+bwmon +464xlat \
|
||||
+ca-bundle +ca-certificates +libustream-wolfssl \
|
||||
+luci-app-sqm +kmod-sched-cake \
|
||||
+ext-command +ext-speedtest \
|
||||
+openvpn-easy-rsa +openvpn-openssl \
|
||||
+ext-extra \
|
||||
+nano +picocom +wget +webconsole
|
||||
TITLE:=ROOter support for RBSXTR routers
|
||||
PKGARCH:=all
|
||||
endef
|
||||
|
||||
define Package/ext-rbsxtr/description
|
||||
Helper scripts to enable ROOter support for RBSXTR routers
|
||||
endef
|
||||
|
||||
|
||||
define Build/Compile
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,ext-rbsxtr))
|
37
rooter-builds/ext-rbsxtr16/Makefile
Normal file
37
rooter-builds/ext-rbsxtr16/Makefile
Normal file
@ -0,0 +1,37 @@
|
||||
#Owned by DairyMan@Whirlpool
|
||||
#
|
||||
#Copyright GNU act.
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=ext-rbsxtr
|
||||
PKG_VERSION:=1.000
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_MAINTAINER:=Created by DM/makefile by Cobia@whirlpool
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/ext-rbsxtr
|
||||
SECTION:=utils
|
||||
CATEGORY:=ROOter
|
||||
DEPENDS:=+luci +luci-compat +ext-rooter-basic \
|
||||
+luci-app-rootervpn +ext-wireguard \
|
||||
+bwmon +464xlat \
|
||||
+ca-bundle +ca-certificates +libustream-wolfssl \
|
||||
+luci-app-sqm +kmod-sched-cake \
|
||||
+ext-command +ext-speedtest \
|
||||
+openvpn-easy-rsa +openvpn-openssl \
|
||||
+ext-extra \
|
||||
+nano +picocom +wget +webconsole
|
||||
TITLE:=ROOter support for RBSXTR routers
|
||||
PKGARCH:=all
|
||||
endef
|
||||
|
||||
define Package/ext-rbsxtr/description
|
||||
Helper scripts to enable ROOter support for RBSXTR routers
|
||||
endef
|
||||
|
||||
|
||||
define Build/Compile
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,ext-rbsxtr))
|
43
rooter-builds/ext-rooter-lite/Makefile
Normal file
43
rooter-builds/ext-rooter-lite/Makefile
Normal file
@ -0,0 +1,43 @@
|
||||
#Owned by DairyMan@Whirlpool
|
||||
#
|
||||
#Copyright GNU act.
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=ext-rooter-lite
|
||||
PKG_VERSION:=1.000
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_MAINTAINER:=Created by DM/makefile by Cobia@whirlpool
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/ext-rooter-lite
|
||||
SECTION:=utils
|
||||
CATEGORY:=ROOter
|
||||
DEPENDS:=+luci +ext-rooter-basic +pingtest +ext-logo \
|
||||
+luci-app-ddns +ddns-scripts \
|
||||
+luci-app-rootervpn +ext-wireguard \
|
||||
+bwmon +464xlat +webconsole \
|
||||
+ext-theme +luci-theme-argon +luci-theme-argondark +ext-login \
|
||||
+luci-theme-tomato \
|
||||
+ca-bundle +ca-certificates +libustream-wolfssl \
|
||||
+luci-app-ksmbd +usb-storage \
|
||||
+ext-p910nd +luci-app-sqm +kmod-sched-cake +luci-app-nft-qos \
|
||||
+ext-command +ext-speedtest \
|
||||
+openvpn-easy-rsa +openvpn-openssl \
|
||||
+ext-extra +luci-app-hotspot +luci-app-wol +luci-app-guestwifi \
|
||||
+usbmuxd +libusbmuxd-utils +libimobiledevice-utils +kmod-usb-net-ipheth \
|
||||
+qlog +luci-ssl +usbutils +openssl-util +irqbalance +ext-splashconfig \
|
||||
+nano +picocom +wpad-openssl +wget +qfirehose +luci-app-vpnbypass +ext-simplegps
|
||||
TITLE:=ROOter support w/o MWan3 for 16meg and larger routers
|
||||
PKGARCH:=all
|
||||
endef
|
||||
|
||||
define Package/ext-rooter-lite/description
|
||||
Helper scripts to enable ROOter w/o MWan3 on 16meg and larger routers
|
||||
endef
|
||||
|
||||
|
||||
define Build/Compile
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,ext-rooter-lite))
|
44
rooter-builds/ext-rooter16/Makefile
Normal file
44
rooter-builds/ext-rooter16/Makefile
Normal file
@ -0,0 +1,44 @@
|
||||
#Owned by DairyMan@Whirlpool
|
||||
#
|
||||
#Copyright GNU act.
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=ext-rooter16
|
||||
PKG_VERSION:=1.000
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_MAINTAINER:=Created by DM/makefile by Cobia@whirlpool
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/ext-rooter16
|
||||
SECTION:=utils
|
||||
CATEGORY:=ROOter
|
||||
DEPENDS:=+luci +ext-rooter-basic +pingtest +ext-logo \
|
||||
+luci-app-mwan3 +luci-app-dnsmasq-ipset \
|
||||
+luci-app-ddns +ddns-scripts \
|
||||
+luci-app-rootervpn +ext-wireguard \
|
||||
+bwmon +464xlat +webconsole \
|
||||
+ext-theme +luci-theme-argon +luci-theme-argondark \
|
||||
+luci-theme-tomato +ext-login \
|
||||
+ca-bundle +ca-certificates +libustream-wolfssl \
|
||||
+luci-app-ksmbd +usb-storage \
|
||||
+ext-p910nd +luci-app-sqm +kmod-sched-cake +luci-app-nft-qos \
|
||||
+ext-command +ext-speedtest +luci-app-guestwifi \
|
||||
+openvpn-easy-rsa +openvpn-openssl \
|
||||
+ext-extra +luci-app-hotspot +luci-app-wol \
|
||||
+usbmuxd +libusbmuxd-utils +libimobiledevice-utils +kmod-usb-net-ipheth \
|
||||
+qlog +luci-ssl +usbutils +openssl-util +irqbalance +ext-splashconfig \
|
||||
+nano +picocom +wpad-openssl +wget +qfirehose +luci-app-vpnbypass +ext-simplegps
|
||||
TITLE:=ROOter support for 16meg and larger routers
|
||||
PKGARCH:=all
|
||||
endef
|
||||
|
||||
define Package/ext-rooter16/description
|
||||
Helper scripts to enable ROOter on 16meg and larger routers
|
||||
endef
|
||||
|
||||
|
||||
define Build/Compile
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,ext-rooter16))
|
38
rooter-builds/ext-rooter4/Makefile
Normal file
38
rooter-builds/ext-rooter4/Makefile
Normal file
@ -0,0 +1,38 @@
|
||||
#Owned by DairyMan@Whirlpool
|
||||
#
|
||||
#Copyright GNU act.
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=ext-rooter4
|
||||
PKG_VERSION:=1.000
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_MAINTAINER:=Created by DM/makefile by Cobia@whirlpool
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/ext-rooter4
|
||||
SECTION:=utils
|
||||
CATEGORY:=ROOter
|
||||
DEPENDS:=+luci +ext-rooter-basic +ext-logo \
|
||||
+ca-bundle +ca-certificates \
|
||||
+luci-app-sqm +kmod-sched-cake \
|
||||
+luci-app-ddns +ddns-scripts \
|
||||
+ext-command +ext-p910nd +luci-app-guestwifi \
|
||||
+luci-app-hotspot +ext-extra \
|
||||
+picocom +wget +nano +464xlat
|
||||
TITLE:=install basic ROOter routers
|
||||
PKGARCH:=all
|
||||
endef
|
||||
|
||||
define Package/ext-rooter4/description
|
||||
Helper scripts to install basic ROOter routers
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
endef
|
||||
|
||||
define Package/ext-rooter4/install
|
||||
$(CP) ./files/* $(1)/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,ext-rooter4))
|
15
rooter-builds/ext-rooter4/files/etc/config/failover
Normal file
15
rooter-builds/ext-rooter4/files/etc/config/failover
Normal file
@ -0,0 +1,15 @@
|
||||
|
||||
config policy 'faillist'
|
||||
|
||||
config tracker 'failover'
|
||||
option reliability '1'
|
||||
option count '1'
|
||||
option pingtime '5'
|
||||
option pingwait '7'
|
||||
option down '2'
|
||||
option up '2'
|
||||
list trackip '8.8.8.8'
|
||||
|
||||
config enabled 'enabled'
|
||||
option enabled '0'
|
||||
|
1
rooter-builds/ext-rooter4/files/etc/flash
Normal file
1
rooter-builds/ext-rooter4/files/etc/flash
Normal file
@ -0,0 +1 @@
|
||||
FLASH="4"
|
@ -0,0 +1,39 @@
|
||||
module("luci.controller.failover", package.seeall)
|
||||
|
||||
function index()
|
||||
local page
|
||||
|
||||
if not nixio.fs.access("/etc/config/failover") then
|
||||
return
|
||||
end
|
||||
|
||||
page = entry({"admin", "network", "failover"}, cbi("rooter/failover"), "Internet Failover", 600)
|
||||
page.dependent = true
|
||||
|
||||
entry({"admin", "network", "get_fstatus"}, call("action_get_fstatus"))
|
||||
end
|
||||
|
||||
function action_get_fstatus()
|
||||
local file
|
||||
mArray = {}
|
||||
file = io.open("/tmp/wanstatus", "r")
|
||||
if file == nil then
|
||||
mArray["wan"] = " "
|
||||
else
|
||||
mArray["wan"] = file:read("*line")
|
||||
mArray["winter"] = file:read("*line")
|
||||
mArray["wstatus"] = file:read("*line")
|
||||
file:close()
|
||||
end
|
||||
file = io.open("/tmp/modemstatus", "r")
|
||||
if file == nil then
|
||||
mArray["modem"] = " "
|
||||
else
|
||||
mArray["modem"] = file:read("*line")
|
||||
mArray["minter"] = file:read("*line")
|
||||
mArray["mstatus"] = file:read("*line")
|
||||
file:close()
|
||||
end
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(mArray)
|
||||
end
|
@ -0,0 +1,140 @@
|
||||
local utl = require "luci.util"
|
||||
local uci = require "luci.model.uci".cursor()
|
||||
|
||||
function cbiAddWan(field)
|
||||
i = 0
|
||||
uci.cursor():foreach("failover", "member",
|
||||
function (section)
|
||||
line = section[".name"]
|
||||
s, e = line:find("Modem")
|
||||
if s == nil then
|
||||
field:value(section[".name"])
|
||||
if i == 0 then
|
||||
field.default = section[".name"]
|
||||
end
|
||||
i = 1
|
||||
end
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
function cbiAddModem(field)
|
||||
i = 0
|
||||
uci.cursor():foreach("failover", "member",
|
||||
function (section)
|
||||
line = section[".name"]
|
||||
s, e = line:find("Modem")
|
||||
if s ~= nil then
|
||||
field:value(section[".name"])
|
||||
if i == 0 then
|
||||
field.default = section[".name"]
|
||||
end
|
||||
i = 1
|
||||
end
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
m = Map("failover", translate("Internet Connection Failover"), translate("Enable a connection failover system between two Internet sources."))
|
||||
|
||||
m.on_after_commit = function(self)
|
||||
luci.sys.call("/usr/lib/rooter/luci/failchk.sh")
|
||||
end
|
||||
|
||||
enabl = m:section(NamedSection, "enabled", "enabled", "")
|
||||
enabl.addremove = false
|
||||
enabl.dynamic = false
|
||||
|
||||
e = enabl:option(Flag, "enabled", translate("Failover Enabled"))
|
||||
e.rmempty = false
|
||||
|
||||
policy = m:section(NamedSection, "faillist", "policy", "")
|
||||
policy.addremove = false
|
||||
policy.dynamic = false
|
||||
|
||||
use_wan = policy:option(ListValue, "use_wan", translate("Primary Internet Source"),
|
||||
translate("Select Primary Internet source."))
|
||||
cbiAddWan(use_wan)
|
||||
|
||||
use_modem = policy:option(ListValue, "use_modem", translate("Secondary Internet Source"),
|
||||
translate("Select Secondary (Backup) Internet source."))
|
||||
cbiAddModem(use_modem)
|
||||
|
||||
tracker = m:section(NamedSection, "failover", "tracker", "")
|
||||
tracker.addremove = false
|
||||
tracker.dynamic = false
|
||||
|
||||
reliability = tracker:option(Value, "reliability", translate("Tracking reliability"),
|
||||
translate("Acceptable values: 1-100. This many Tracking IP addresses must respond for the source to be deemed up"))
|
||||
reliability.datatype = "range(1, 100)"
|
||||
reliability.default = "1"
|
||||
|
||||
count = tracker:option(ListValue, "count", translate("Ping count"))
|
||||
count.default = "1"
|
||||
count:value("1")
|
||||
count:value("2")
|
||||
count:value("3")
|
||||
count:value("4")
|
||||
count:value("5")
|
||||
|
||||
interval = tracker:option(ListValue, "pingtime", translate("Ping interval"),
|
||||
translate("Amount of time between tracking tests"))
|
||||
interval.default = "5"
|
||||
interval:value("5", translate("5 seconds"))
|
||||
interval:value("10", translate("10 seconds"))
|
||||
interval:value("20", translate("20 seconds"))
|
||||
interval:value("30", translate("30 seconds"))
|
||||
interval:value("60", translate("1 minute"))
|
||||
interval:value("300", translate("5 minutes"))
|
||||
interval:value("600", translate("10 minutes"))
|
||||
interval:value("900", translate("15 minutes"))
|
||||
interval:value("1800", translate("30 minutes"))
|
||||
interval:value("3600", translate("1 hour"))
|
||||
|
||||
timeout = tracker:option(ListValue, "pingwait", translate("Ping timeout"))
|
||||
timeout.default = "2"
|
||||
timeout:value("1", translate("1 second"))
|
||||
timeout:value("2", translate("2 seconds"))
|
||||
timeout:value("3", translate("3 seconds"))
|
||||
timeout:value("4", translate("4 seconds"))
|
||||
timeout:value("5", translate("5 seconds"))
|
||||
timeout:value("6", translate("6 seconds"))
|
||||
timeout:value("7", translate("7 seconds"))
|
||||
timeout:value("8", translate("8 seconds"))
|
||||
timeout:value("9", translate("9 seconds"))
|
||||
timeout:value("10", translate("10 seconds"))
|
||||
|
||||
down = tracker:option(ListValue, "down", translate("Interface down"),
|
||||
translate("Interface will be deemed down after this many failed ping tests in a row"))
|
||||
down.default = "2"
|
||||
down:value("1")
|
||||
down:value("2")
|
||||
down:value("3")
|
||||
down:value("4")
|
||||
down:value("5")
|
||||
down:value("6")
|
||||
down:value("7")
|
||||
down:value("8")
|
||||
down:value("9")
|
||||
down:value("10")
|
||||
|
||||
up = tracker:option(ListValue, "up", translate("Interface up"),
|
||||
translate("Downed interface will be deemed up after this many successful ping tests in a row"))
|
||||
up.default = "2"
|
||||
up:value("1")
|
||||
up:value("2")
|
||||
up:value("3")
|
||||
up:value("4")
|
||||
up:value("5")
|
||||
up:value("6")
|
||||
up:value("7")
|
||||
up:value("8")
|
||||
up:value("9")
|
||||
up:value("10")
|
||||
|
||||
cb2 = tracker:option(DynamicList, "trackip", translate("Tracking IP"),
|
||||
translate("This IP address will be pinged to dermine if the link is up or down."))
|
||||
cb2.datatype = "ipaddr"
|
||||
|
||||
return m
|
||||
|
@ -0,0 +1,188 @@
|
||||
#!/bin/sh
|
||||
. /lib/functions.sh
|
||||
|
||||
ROOTER=/usr/lib/rooter
|
||||
|
||||
log() {
|
||||
logger -t "Failover System" "$@"
|
||||
}
|
||||
|
||||
log "Failover System is Started"
|
||||
|
||||
ifname1="ifname"
|
||||
if [ -e /etc/newstyle ]; then
|
||||
ifname1="device"
|
||||
fi
|
||||
|
||||
i=1
|
||||
STAT="0"
|
||||
track_ips=
|
||||
WAN_STATUS="0"
|
||||
MODEM_STATUS="0"
|
||||
MODEM_IFUP=true
|
||||
rm -f /tmp/wanstatus
|
||||
rm -f /tmp/modemstatus
|
||||
rm -f /tmp/mdown$CURRMODEM
|
||||
|
||||
get_interface() {
|
||||
OX=$1
|
||||
case $OX in
|
||||
"Wan" )
|
||||
inter="wan"
|
||||
;;
|
||||
"Hotspot" )
|
||||
inter="wwan"
|
||||
;;
|
||||
* )
|
||||
inter="wan${OX:5}"
|
||||
;;
|
||||
esac
|
||||
uci set failover.$OX.interface=$inter
|
||||
}
|
||||
|
||||
ping_interface() {
|
||||
interf=$(uci get failover.$1.interface)
|
||||
if [ $interf = "wwan" ]; then
|
||||
IFN="$(ubus -S call network.wireless status | jsonfilter -e '@.*.interfaces[@.config.mode="sta"].${ifname1}')"
|
||||
else
|
||||
IFN=$(uci get network.$interf.${ifname1})
|
||||
fi
|
||||
if [ ! -z $IFN ]; then
|
||||
STAT="1"
|
||||
host_up_count=0
|
||||
score_up=$UP
|
||||
score_dwn=$DOWN
|
||||
lost=0
|
||||
while true; do
|
||||
if [ ! -z "$track_ips" ]; then
|
||||
for track_ip in $track_ips; do
|
||||
ping -I $IFN -c $COUNT -W $TIMEOUT -s 4 -q $track_ip &> /dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
let host_up_count++
|
||||
else
|
||||
let lost++
|
||||
fi
|
||||
done
|
||||
if [ $host_up_count -lt $RELIAB ]; then
|
||||
let score_dwn--
|
||||
score_up=$UP
|
||||
if [ $score_dwn -eq 0 ]; then
|
||||
STAT="1"
|
||||
break
|
||||
fi
|
||||
else
|
||||
let score_up--
|
||||
score_dwn=$DOWN
|
||||
if [ $score_up -eq 0 ]; then
|
||||
STAT="2"
|
||||
break
|
||||
fi
|
||||
fi
|
||||
else
|
||||
log "No Tracking IP, stopping Failover"
|
||||
exit
|
||||
fi
|
||||
host_up_count=0
|
||||
sleep $INTERVAL
|
||||
done
|
||||
else
|
||||
STAT="0"
|
||||
fi
|
||||
}
|
||||
|
||||
make_status() {
|
||||
name=$2
|
||||
status=$3
|
||||
interface=$(uci get failover.$name.interface)
|
||||
echo "$name" > /tmp/$1"status"
|
||||
echo "$interface" >> /tmp/$1"status"
|
||||
case $status in
|
||||
"0" )
|
||||
echo "disabled" >> /tmp/$1"status"
|
||||
;;
|
||||
"1" )
|
||||
echo "offline" >> /tmp/$1"status"
|
||||
;;
|
||||
"2" )
|
||||
echo "online" >> /tmp/$1"status"
|
||||
;;
|
||||
"3" )
|
||||
echo "onlinedwn" >> /tmp/$1"status"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
list_track_ips() {
|
||||
track_ips="$1 $track_ips"
|
||||
}
|
||||
|
||||
rm -f /tmp/wanstatus
|
||||
rm -f /tmp/modemstatus
|
||||
|
||||
config_load failover
|
||||
config_list_foreach "failover" "trackip" list_track_ips
|
||||
|
||||
use_wan=$(uci get failover.faillist.use_wan)
|
||||
get_interface $use_wan
|
||||
use_modem=$(uci get failover.faillist.use_modem)
|
||||
get_interface $use_modem
|
||||
uci commit failover
|
||||
|
||||
interf=$(uci get failover.$use_wan.interface)
|
||||
uci set network.$interf.metric="99"
|
||||
uci commit network
|
||||
ifup $interf
|
||||
|
||||
TIMEOUT=$(uci get failover.failover.pingwait)
|
||||
INTERVAL=$(uci get failover.failover.pingtime)
|
||||
RELIAB=$(uci get failover.failover.reliability)
|
||||
DOWN=$(uci get failover.failover.down)
|
||||
UP=$(uci get failover.failover.up)
|
||||
COUNT=$(uci get failover.failover.count)
|
||||
|
||||
while true; do
|
||||
use_wan=$(uci get failover.faillist.use_wan)
|
||||
use_modem=$(uci get failover.faillist.use_modem)
|
||||
ping_interface $use_wan
|
||||
make_status "wan" $use_wan $STAT
|
||||
WAN_STATUS=$STAT
|
||||
if [ $WAN_STATUS = "2" ];then
|
||||
if [ $MODEM_IFUP = true -a $MODEM_STATUS == "2" ]; then
|
||||
MODEM_IFUP=false
|
||||
MODEM_STATUS="3"
|
||||
ifdown $(uci get failover.$use_modem.interface)
|
||||
fi
|
||||
else
|
||||
if [ $MODEM_IFUP = false -a $MODEM_STATUS != "0" ]; then
|
||||
MODEM_IFUP=true
|
||||
MODEM_STATUS="2"
|
||||
ifup $(uci get failover.$use_modem.interface)
|
||||
sleep 10
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $MODEM_STATUS != "3" ]; then
|
||||
ping_interface $use_modem
|
||||
make_status "modem" $use_modem $STAT
|
||||
MODEM_STATUS=$STAT
|
||||
MODEM_IFUP=true
|
||||
if [ $STAT = "1" ]; then
|
||||
echo "0" > /tmp/mdown$CURRMODEM
|
||||
else
|
||||
rm -f /tmp/mdown$CURRMODEM
|
||||
fi
|
||||
else
|
||||
interf=$(uci get failover.$use_modem.interface)
|
||||
IFN=$(uci get network.$interf.${ifname1})
|
||||
if [ -z $IFN ]; then
|
||||
MODEM_IFUP=false
|
||||
make_status "modem" $use_modem "0"
|
||||
MODEM_STATUS="0"
|
||||
else
|
||||
make_status "modem" $use_modem "3"
|
||||
MODEM_STATUS="3"
|
||||
MODEM_IFUP=false
|
||||
fi
|
||||
fi
|
||||
sleep 10
|
||||
done
|
@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
|
||||
ROOTER=/usr/lib/rooter
|
||||
|
||||
log() {
|
||||
logger -t "Failover Check" "$@"
|
||||
}
|
||||
|
||||
jkillall failover.sh
|
||||
ENB=$(uci get failover.enabled.enabled)
|
||||
if [ $ENB = "1" ]; then
|
||||
if [ -e $ROOTER/connect/failover.sh ]; then
|
||||
log "Restarting Failover System"
|
||||
$ROOTER/connect/failover.sh &
|
||||
fi
|
||||
fi
|
36
rooter-builds/ext-rooter8-vpn/Makefile
Normal file
36
rooter-builds/ext-rooter8-vpn/Makefile
Normal file
@ -0,0 +1,36 @@
|
||||
#Owned by DairyMan@Whirlpool
|
||||
#
|
||||
#Copyright GNU act.
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=ext-rooter8-vpn
|
||||
PKG_VERSION:=1.000
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_MAINTAINER:=Created by DM/makefile by Cobia@whirlpool
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/ext-rooter8-vpn
|
||||
SECTION:=utils
|
||||
CATEGORY:=ROOter
|
||||
DEPENDS:=+luci +ext-rooter4 +bwmon \
|
||||
+luci-app-rootervpn +ext-wireguard
|
||||
TITLE:=basic ROOter support for 8meg routers
|
||||
PKGARCH:=all
|
||||
endef
|
||||
|
||||
define Package/ext-rooter8-vpn/description
|
||||
basic ROOter support for 8meg routers
|
||||
endef
|
||||
|
||||
|
||||
define Build/Compile
|
||||
endef
|
||||
|
||||
define Package/ext-rooter8-vpn/install
|
||||
$(CP) ./files/* $(1)/
|
||||
|
||||
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,ext-rooter8-vpn))
|
1
rooter-builds/ext-rooter8-vpn/files/etc/flash8
Normal file
1
rooter-builds/ext-rooter8-vpn/files/etc/flash8
Normal file
@ -0,0 +1 @@
|
||||
FLASH="8"
|
44
rooter-builds/ext-rooterbcm16/Makefile
Normal file
44
rooter-builds/ext-rooterbcm16/Makefile
Normal file
@ -0,0 +1,44 @@
|
||||
#Owned by DairyMan@Whirlpool
|
||||
#
|
||||
#Copyright GNU act.
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=ext-rooterbcm16
|
||||
PKG_VERSION:=1.000
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_MAINTAINER:=Created by DM/makefile by Cobia@whirlpool
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/ext-rooterbcm16
|
||||
SECTION:=utils
|
||||
CATEGORY:=ROOter
|
||||
DEPENDS:=+luci +ext-rooter-basic +ext-logo \
|
||||
+luci-app-mwan3 +luci-app-dnsmasq-ipset \
|
||||
+luci-app-ddns +ddns-scripts \
|
||||
+luci-app-rootervpn +ext-wireguard \
|
||||
+webconsole +bwmon +464xlat \
|
||||
+ext-theme +luci-theme-argon +luci-theme-argondark \
|
||||
+luci-theme-tomato +ext-login \
|
||||
+ca-bundle +ca-certificates +libustream-wolfssl \
|
||||
+luci-app-ksmbd +usb-storage \
|
||||
+ext-p910nd +luci-app-sqm +kmod-sched-cake +luci-app-nft-qos \
|
||||
+ext-command +ext-speedtest +luci-app-guestwifi \
|
||||
+openvpn-easy-rsa +openvpn-openssl \
|
||||
+ext-extra +luci-app-wol \
|
||||
+usbmuxd +libusbmuxd-utils +libimobiledevice-utils +kmod-usb-net-ipheth \
|
||||
+qlog +luci-ssl +usbutils +openssl-util +irqbalance +ext-splashconfig \
|
||||
+nano +picocom +wpad +wget +qfirehose +luci-app-vpnbypass
|
||||
TITLE:=ROOter support for 16meg and larger Broadcom routers w/o Hotspot Manager
|
||||
PKGARCH:=all
|
||||
endef
|
||||
|
||||
define Package/ext-rooterbcm16/description
|
||||
Helper scripts to enable ROOter on 16meg and larger Broadcom routers w/o Hotspot Manager
|
||||
endef
|
||||
|
||||
|
||||
define Build/Compile
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,ext-rooterbcm16))
|
33
rooter-extra/ext-netselect/Makefile
Normal file
33
rooter-extra/ext-netselect/Makefile
Normal file
@ -0,0 +1,33 @@
|
||||
#Owned by DairyMan@Whirlpool
|
||||
#
|
||||
#Copyright GNU act.
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=ext-netselect
|
||||
PKG_VERSION:=1.000
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_MAINTAINER:=Created by DM/makefile by Cobia@whirlpool
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/ext-netselect
|
||||
SECTION:=utils
|
||||
CATEGORY:=ROOter
|
||||
SUBMENU:=Optional Applications
|
||||
TITLE:=support for Network Selection
|
||||
PKGARCH:=all
|
||||
endef
|
||||
|
||||
define Package/ext-netselect/description
|
||||
Helper scripts to enable Network Selection
|
||||
endef
|
||||
|
||||
|
||||
define Build/Compile
|
||||
endef
|
||||
|
||||
define Package/ext-netselect/install
|
||||
$(CP) ./files/* $(1)/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,ext-netselect))
|
@ -0,0 +1,73 @@
|
||||
module("luci.controller.netroam", package.seeall)
|
||||
|
||||
I18N = require "luci.i18n"
|
||||
translate = I18N.translate
|
||||
|
||||
function index()
|
||||
entry({"admin", "modem", "netroam"}, template("netroam/netroam"), translate("Network Selection"), 39)
|
||||
entry({"admin", "netroam", "getconnect"}, call("action_getconnect"))
|
||||
entry({"admin", "netroam", "getscan"}, call("action_getscan"))
|
||||
entry({"admin", "netroam", "connect"}, call("action_connect"))
|
||||
end
|
||||
|
||||
function action_getconnect()
|
||||
local rv ={}
|
||||
|
||||
connect = luci.model.uci.cursor():get("modem", "modem1", "connected")
|
||||
rv['connected'] = connect
|
||||
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(rv)
|
||||
end
|
||||
|
||||
function action_getscan()
|
||||
local netw = {}
|
||||
local netmc = {}
|
||||
local netlong = {}
|
||||
local netavail = {}
|
||||
local rv ={}
|
||||
|
||||
os.execute("/usr/lib/netroam/getcops.sh")
|
||||
|
||||
file = io.open("/tmp/copseqxx", "r")
|
||||
mfile = io.open("/tmp/copseqmc", "r")
|
||||
lfile = io.open("/tmp/copseqlg", "r")
|
||||
afile = io.open("/tmp/copseqav", "r")
|
||||
if file ~= nil then
|
||||
rv["data"] = "1"
|
||||
indx = 0
|
||||
repeat
|
||||
line = file:read("*line")
|
||||
if line == nil then
|
||||
break
|
||||
end
|
||||
mline = mfile:read("*line")
|
||||
netw[indx] = line
|
||||
netmc[indx] = mline
|
||||
lline = lfile:read("*line")
|
||||
netlong[indx] = lline
|
||||
aline = afile:read("*line")
|
||||
netavail[indx] = aline
|
||||
indx = indx +1
|
||||
until 1 == 0
|
||||
rv['network'] = netw
|
||||
rv['mccmnc'] = netmc
|
||||
rv['long'] = netlong
|
||||
rv['avail'] = netavail
|
||||
rv['indx'] = tostring(indx)
|
||||
file:close()
|
||||
mfile:close()
|
||||
lfile:close()
|
||||
afile:close()
|
||||
else
|
||||
rv["data"] = "0"
|
||||
end
|
||||
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(rv)
|
||||
end
|
||||
|
||||
function action_connect()
|
||||
local set = luci.http.formvalue("set")
|
||||
os.execute("/usr/lib/netroam/doconnect.sh " .. set)
|
||||
end
|
@ -0,0 +1,261 @@
|
||||
<%+header%>
|
||||
<script type="text/javascript" src="<%=resource%>/xhr.js"></script>
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
|
||||
var gotdata = "0";
|
||||
var netdata = new Array();
|
||||
var netmcc = new Array();
|
||||
var netlong = new Array();
|
||||
var netavail = new Array();
|
||||
var ulselect = -1;
|
||||
|
||||
XHR.poll(2, '<%=luci.dispatcher.build_url("admin", "netroam", "getconnect")%>', null,
|
||||
function(x, rv)
|
||||
{
|
||||
connected = rv.connected;
|
||||
if ( connected == "1" )
|
||||
{
|
||||
document.getElementById("noconnect").style.visibility="hidden";
|
||||
document.getElementById("noconnect").style.display="none";
|
||||
document.getElementById("scansec").style.visibility="visible";
|
||||
document.getElementById("scansec").style.display="";
|
||||
document.getElementById("scan").style.visibility="visible";
|
||||
document.getElementById("scan").style.display="";
|
||||
}
|
||||
else
|
||||
{
|
||||
document.getElementById("noconnect").style.visibility="visible";
|
||||
document.getElementById("noconnect").style.display="";
|
||||
document.getElementById("scan").style.visibility="hidden";
|
||||
document.getElementById("scan").style.display="none";
|
||||
document.getElementById("results").style.visibility="hidden";
|
||||
document.getElementById("results").style.display="none";
|
||||
}
|
||||
}
|
||||
|
||||
);
|
||||
|
||||
function clearListul(listboxID)
|
||||
{
|
||||
var mylistbox = document.getElementById(listboxID);
|
||||
if(mylistbox == null)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
mylistbox.innerHTML = '';
|
||||
}
|
||||
|
||||
function scannet(btn)
|
||||
{
|
||||
document.getElementById("results").style.visibility="hidden";
|
||||
document.getElementById("results").style.display="none";
|
||||
document.getElementById("scan").disabled=true;
|
||||
document.getElementById("getinfo").style.visibility="visible";
|
||||
document.getElementById("getinfo").style.display="";
|
||||
XHR.get('<%=luci.dispatcher.build_url("admin", "netroam", "getscan")%>',
|
||||
null,
|
||||
function(x, rv)
|
||||
{
|
||||
document.getElementById("results").style.visibility="visible";
|
||||
document.getElementById("results").style.display="";
|
||||
document.getElementById("scan").disabled=false;
|
||||
document.getElementById("getinfo").style.visibility="hidden";
|
||||
document.getElementById("getinfo").style.display="none";
|
||||
gotdata = rv.data;
|
||||
if ( gotdata == "1" )
|
||||
{
|
||||
document.getElementById("noresults").style.visibility="hidden";
|
||||
document.getElementById("noresults").style.display="none";
|
||||
document.getElementById("selected").style.visibility="visible";
|
||||
document.getElementById("selected").style.display="";
|
||||
clearListul("hotList1");
|
||||
netdata = rv.network;
|
||||
netmcc = rv.mccmnc;
|
||||
netlong = rv.long;
|
||||
netavail = rv.avail;
|
||||
hotv = 0;
|
||||
indx = parseInt(rv.indx);
|
||||
indxx = 0;
|
||||
for (i = 0; i < indx; i++) {
|
||||
txtline = netdata[i];
|
||||
if (netlong[i] == "2")
|
||||
{
|
||||
hotv = i;
|
||||
}
|
||||
txtline = txtline.replace(/ /g,"\240");
|
||||
|
||||
var ul = document.getElementById("hotList1");
|
||||
var li = document.createElement('li');
|
||||
lix = indxx + 1;
|
||||
li.id = 'li' + lix;
|
||||
li.setAttribute('onclick', "testclk(" + lix + ")");
|
||||
li.appendChild(document.createTextNode(txtline));
|
||||
ul.appendChild(li);
|
||||
indxx = indxx + 1;
|
||||
|
||||
}
|
||||
ulselect = hotv + 1;
|
||||
id = "li" + ulselect;
|
||||
document.getElementById(id).style.backgroundColor = '#4686fe';
|
||||
document.getElementById(id).style.color = 'white';
|
||||
|
||||
document.getElementById("selnet").innerHTML=netavail[hotv];
|
||||
if ( netlong[hotv] == "2" )
|
||||
{
|
||||
document.getElementById("change").disabled=true;
|
||||
}
|
||||
else
|
||||
{
|
||||
document.getElementById("change").disabled=false;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
document.getElementById("noresults").style.visibility="visible";
|
||||
document.getElementById("noresults").style.display="";
|
||||
document.getElementById("selected").style.visibility="hidden";
|
||||
document.getElementById("selected").style.display="none";
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function testclk(row)
|
||||
{
|
||||
var num = indx+1;
|
||||
for (i = 1; i <= num; i++) {
|
||||
id = "li" + i;
|
||||
if ( document.getElementById(id) != null )
|
||||
{
|
||||
document.getElementById(id).style.backgroundColor = 'inherit';
|
||||
document.getElementById(id).style.color = 'inherit';
|
||||
}
|
||||
}
|
||||
id = "li" + row;
|
||||
ulselect = row;
|
||||
document.getElementById(id).style.backgroundColor = '#4686fe';
|
||||
document.getElementById(id).style.color = 'white';
|
||||
s = ulselect-1;
|
||||
selectline = s;
|
||||
|
||||
document.getElementById('selnet').innerHTML=netavail[s];
|
||||
if ( netlong[s] == "2" )
|
||||
{
|
||||
document.getElementById("change").disabled=true;
|
||||
}
|
||||
else
|
||||
{
|
||||
document.getElementById("change").disabled=false;
|
||||
}
|
||||
}
|
||||
|
||||
function changenet(btn)
|
||||
{
|
||||
var s = ulselect-1;
|
||||
mmc = netmcc[s];
|
||||
if ( confirm("<%:Modem will be restarted to change to new network. Continue?%>") )
|
||||
{
|
||||
XHR.get('<%=luci.dispatcher.build_url("admin", "netroam", "connect")%>',
|
||||
{ set: mmc },
|
||||
function(x, rv)
|
||||
{
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//]]></script>
|
||||
|
||||
<form method="post" action="<%=REQUEST_URI%>">
|
||||
<div class="cbi-map" id="cbi-modem">
|
||||
<h2><a id="content" name="content"><%:Network Selection%></a></h2>
|
||||
<div class="cbi-map-descr"> </div>
|
||||
<head>
|
||||
<style>
|
||||
ul.select {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 2px;
|
||||
border: 1px solid grey;
|
||||
}
|
||||
|
||||
ul.select li {
|
||||
padding: 2px 6px;
|
||||
}
|
||||
ul.select li:hover {
|
||||
background-color: #ccc;
|
||||
cursor: pointer;
|
||||
}
|
||||
ul.select li.selected {
|
||||
background-color: blue;
|
||||
color: white;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<fieldset class="cbi-section" id="scanning">
|
||||
<legend><%:Scanning%></legend>
|
||||
|
||||
<table border="0" id="noconnect" style="visibility:hidden;">
|
||||
<tr>
|
||||
<td width="5%"></td>
|
||||
<td width="35%"><div align="center" style="font-size : 17px" id="backbw"><strong><%:Modem must be connected to scan for networks%></strong></div></td>
|
||||
<td width="60%"></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table border="0" id="scansec" style="visibility:hidden;">
|
||||
<tr>
|
||||
<td width="5%"></td>
|
||||
<td width="15%"><input type="button" id="scan" class="cbi-button cbi-button-apply" value="<%:Scan for Networks%>" onclick="return scannet(this)" /></td>
|
||||
<td width="80%"></td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
<table width="900" id="getinfo" border="0" style="visibility:hidden;" >
|
||||
<tr>
|
||||
<tr>
|
||||
<td width="5%"></td>
|
||||
<td width="25%" id="gps_text"><img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" /><strong><%:Scanning for Networks ... Please wait.%></strong>
|
||||
</td>
|
||||
<td width="70%"></td>
|
||||
</tr>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="cbi-section" id="results" style="visibility:hidden;">
|
||||
<legend><%:Networks Found%></legend>
|
||||
|
||||
<table border="0" id="noresults" style="visibility:hidden;">
|
||||
<tr>
|
||||
<td width="5%"></td>
|
||||
<td width="35%"><div align="center" style="font-size : 17px" ><strong><%:No Networks Found, Retry Scan%></strong></div></td>
|
||||
<td width="60%"></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<ul class="select" id="hotList1" style="width:800px; font-size: 20px; font-family:monospace;">
|
||||
</ul>
|
||||
|
||||
<table width="550" border="0">
|
||||
<tr>
|
||||
<td width="100%"> </td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table border="0" id="selected" style="visibility:hidden;">
|
||||
<tr>
|
||||
<td width="10%"><div align="left" style="font-size : 17px" ><strong><%:Selected Network%></strong></div></td>
|
||||
<td width="10%"><div align="left" style="font-size : 17px"id="selnet" ></div></td>
|
||||
<td width="15%"><input type="button" id="change" class="cbi-button cbi-button-apply" value="<%:Change to Network%>" onclick="return changenet(this)" /></td>
|
||||
<td width="45%"></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</fieldset>
|
||||
|
||||
</form>
|
||||
<%+footer%>
|
136
rooter-extra/ext-netselect/files/usr/lib/netroam/compress.lua
Normal file
136
rooter-extra/ext-netselect/files/usr/lib/netroam/compress.lua
Normal file
@ -0,0 +1,136 @@
|
||||
#!/usr/bin/lua
|
||||
|
||||
function trim(s)
|
||||
return (s:gsub("^%s*(.-)%s*$", "%1"))
|
||||
end
|
||||
|
||||
lang = trim(arg[1])
|
||||
copseq = "/tmp/copseq"
|
||||
netw = {}
|
||||
netwa = {}
|
||||
long = {}
|
||||
mccmnc = {}
|
||||
freq = {}
|
||||
germ = 0
|
||||
|
||||
file = io.open(copseq, "r")
|
||||
i = 0
|
||||
repeat
|
||||
line = file:read("*line")
|
||||
if line == nil then
|
||||
break
|
||||
end
|
||||
if line == "2" then
|
||||
if lang == "de" then
|
||||
netw[i] = "( Aktuelles Netzwerk )"
|
||||
else
|
||||
netw[i] = "( Current Network )"
|
||||
end
|
||||
end
|
||||
if line == "1" then
|
||||
if lang == "de" then
|
||||
netw[i] = "( Verfügbares Netzwerk )"
|
||||
else
|
||||
netw[i] = "( Availible Network )"
|
||||
end
|
||||
end
|
||||
if line == "3" then
|
||||
if lang == "de" then
|
||||
netw[i] = "( Verbotenes Netzwerk )"
|
||||
else
|
||||
netw[i] = "( Forbidden Network )"
|
||||
end
|
||||
end
|
||||
if line == "0" then
|
||||
if lang == "de" then
|
||||
netw[i] = "( Unbekanntes Netzwerk )"
|
||||
else
|
||||
netw[i] = "( Unknown Network )"
|
||||
end
|
||||
end
|
||||
netwa[i] = line
|
||||
line = file:read("*line")
|
||||
long[i] = line
|
||||
line = file:read("*line")
|
||||
line = file:read("*line")
|
||||
mccmnc[i] = line
|
||||
line = file:read("*line")
|
||||
freq[i] = line
|
||||
i = i + 1
|
||||
until 1==0
|
||||
file:close()
|
||||
maxlen = 0
|
||||
for j = 0, i-1 do
|
||||
nlen = string.len(long[j])
|
||||
if nlen > maxlen then
|
||||
maxlen = nlen
|
||||
end
|
||||
end
|
||||
for j = 0, i-1 do
|
||||
name = long[j] .. " "
|
||||
long[j] = string.sub(name, 1, maxlen + 1)
|
||||
end
|
||||
list = 0
|
||||
netfnd = {}
|
||||
netmcc = {}
|
||||
netfreq = {}
|
||||
netavail = {}
|
||||
netlong = {}
|
||||
for j = 0, i-1 do
|
||||
if list == 0 then
|
||||
netfnd[list] = long[j] .. netw[j] .. " "
|
||||
netmcc[list] = mccmnc[j]
|
||||
netfreq[list] = freq[j]
|
||||
netavail[list] = netwa[j]
|
||||
netlong[list] = long[j]
|
||||
list = list + 1
|
||||
else
|
||||
match = 0
|
||||
for k = 0, list-1 do
|
||||
if mccmnc[j] == netmcc[k] then
|
||||
match = 1
|
||||
indx = k
|
||||
break
|
||||
end
|
||||
end
|
||||
if match == 1 then
|
||||
k = indx
|
||||
if netfreq[k] == "7" and freq[j] == "2" then
|
||||
netfreq[k] = "9"
|
||||
end
|
||||
if netfreq[k] == "2" and freq[j] == "7" then
|
||||
netfreq[k] = "9"
|
||||
end
|
||||
else
|
||||
netfnd[list] = long[j] .. netw[j] .. " "
|
||||
netmcc[list] = mccmnc[j]
|
||||
netfreq[list] = freq[j]
|
||||
netavail[list] = netwa[j]
|
||||
netlong[list] = long[j]
|
||||
list = list + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
tfile = io.open(copseq .. "xx", "w")
|
||||
file = io.open(copseq .. "mc", "w")
|
||||
lfile = io.open(copseq .. "lg", "w")
|
||||
afile = io.open(copseq .. "av", "w")
|
||||
for k = 0, list-1 do
|
||||
if netfreq[k] == "9" then
|
||||
netfnd[k] = netfnd[k] .. "3G/LTE MCC/MNC - " .. string.sub(netmcc[k], 1, 3) .. " " .. string.sub(netmcc[k], 4)
|
||||
end
|
||||
if netfreq[k] == "2" then
|
||||
netfnd[k] = netfnd[k] .. "3G MCC/MNC - " .. string.sub(netmcc[k], 1, 3) .. " " .. string.sub(netmcc[k], 4)
|
||||
end
|
||||
if netfreq[k] == "7" then
|
||||
netfnd[k] = netfnd[k] .. "LTE MCC/MNC - " .. string.sub(netmcc[k], 1, 3) .. " " .. string.sub(netmcc[k], 4)
|
||||
end
|
||||
tfile:write(netfnd[k], "\n")
|
||||
file:write(netmcc[k], "\n")
|
||||
lfile:write(netavail[k], "\n")
|
||||
afile:write(netlong[k], "\n")
|
||||
end
|
||||
tfile:close()
|
||||
file:close()
|
||||
lfile:close()
|
||||
afile:close()
|
@ -0,0 +1,53 @@
|
||||
#!/bin/sh
|
||||
|
||||
ROOTER=/usr/lib/rooter
|
||||
ROOTER_LINK="/tmp/links"
|
||||
|
||||
log() {
|
||||
logger -t "ROAM" "$@"
|
||||
}
|
||||
|
||||
mccmnc=$1
|
||||
|
||||
log "Disconnect modem"
|
||||
|
||||
CURRMODEM=1
|
||||
uci set modem.modem$CURRMODEM.connected=0
|
||||
uci commit modem
|
||||
INTER=$(uci get modem.modeminfo$CURRMODEM.inter)
|
||||
|
||||
jkillall getsignal$CURRMODEM
|
||||
rm -f $ROOTER_LINK/getsignal$CURRMODEM
|
||||
jkillall con_monitor$CURRMODEM
|
||||
rm -f $ROOTER_LINK/con_monitor$CURRMODEM
|
||||
ifdown wan$INTER
|
||||
|
||||
PROT=$(uci get modem.modem$CURRMODEM.proto)
|
||||
CPORT=$(uci get modem.modem$CURRMODEM.commport)
|
||||
|
||||
case $PROT in
|
||||
"30" )
|
||||
ATCMDD="AT+CFUN=0"
|
||||
$ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD"
|
||||
;;
|
||||
"3" )
|
||||
WDMNX=$(uci get modem.modem$CURRMODEM.wdm)
|
||||
umbim -n -t 3 -d /dev/cdc-wdm$WDMNX disconnect
|
||||
;;
|
||||
* )
|
||||
$ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "reset.gcom" "$CURRMODEM"
|
||||
;;
|
||||
esac
|
||||
|
||||
log "Lock to network"
|
||||
|
||||
mcc=${mccmnc:0:3}
|
||||
mnc=${mccmnc:3}
|
||||
|
||||
ATCMDD="AT+COPS=1,2,\"$mccmnc\",7"
|
||||
echo "ATCMDD=\"$ATCMDD\"" > /tmp/rlock
|
||||
|
||||
log "Reconnect Modem"
|
||||
|
||||
$ROOTER_LINK/create_proto$CURRMODEM $CURRMODEM 1 &
|
||||
|
62
rooter-extra/ext-netselect/files/usr/lib/netroam/getcops.sh
Normal file
62
rooter-extra/ext-netselect/files/usr/lib/netroam/getcops.sh
Normal file
@ -0,0 +1,62 @@
|
||||
#!/bin/sh
|
||||
|
||||
ROOTER=/usr/lib/rooter
|
||||
ROOTER_LINK="/tmp/links"
|
||||
|
||||
log() {
|
||||
logger -t "ROAM" "$@"
|
||||
}
|
||||
|
||||
CURRMODEM=1
|
||||
CPORT=$(uci get modem.modem$CURRMODEM.commport)
|
||||
connect=$(uci get modem.modem$CURRMODEM.connected)
|
||||
if [ "$connect" != "1" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
ATCMDD="AT+COPS=?"
|
||||
#export TIMEOUT="120"
|
||||
OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD")
|
||||
#export TIMEOUT="5"
|
||||
OX=$(echo "$OX " | sed -e "s!+COPS: !+COPS:,!g")
|
||||
OX=$(echo "$OX" | grep "+COPS:")
|
||||
if [ -z "$OX" ]; then
|
||||
rm -f /tmp/copseq
|
||||
exit 0
|
||||
fi
|
||||
|
||||
CNT=2
|
||||
rm -f /tmp/copseq
|
||||
while [ true ]; do
|
||||
CCNT=$CNT
|
||||
AVAIL=$(echo $OX | cut -d, -f$CCNT)
|
||||
NXT=$(echo "$AVAIL" | grep "(")
|
||||
if [ ! -z "$NXT" ]; then
|
||||
AVAIL="${AVAIL#(}"
|
||||
let "CCNT=$CCNT+1"
|
||||
LONG=$(echo $OX | cut -d, -f$CCNT)
|
||||
temp="${LONG%\"}"
|
||||
LONG="${temp#\"}"
|
||||
let "CCNT=$CCNT+1"
|
||||
SHORT=$(echo $OX | cut -d, -f$CCNT)
|
||||
temp="${SHORT%\"}"
|
||||
SHORT="${temp#\"}"
|
||||
let "CCNT=$CCNT+1"
|
||||
NUMER=$(echo $OX | cut -d, -f$CCNT)
|
||||
temp="${NUMER%\"}"
|
||||
NUMER="${temp#\"}"
|
||||
let "CCNT=$CCNT+1"
|
||||
ACT=$(echo $OX | cut -d, -f$CCNT)
|
||||
ACT="${ACT%)}"
|
||||
echo "$AVAIL" >> /tmp/copseq
|
||||
echo "$LONG" >> /tmp/copseq
|
||||
echo "$SHORT" >> /tmp/copseq
|
||||
echo "$NUMER" >> /tmp/copseq
|
||||
echo "$ACT" >> /tmp/copseq
|
||||
let "CNT=$CCNT+1"
|
||||
else
|
||||
break
|
||||
fi
|
||||
done
|
||||
lang=$(uci -q get luci.main.lang)
|
||||
/usr/lib/netroam/compress.lua $lang
|
18
rooter-extra/ext-netselect/files/usr/lib/netroam/lock.sh
Normal file
18
rooter-extra/ext-netselect/files/usr/lib/netroam/lock.sh
Normal file
@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
|
||||
ROOTER=/usr/lib/rooter
|
||||
ROOTER_LINK="/tmp/links"
|
||||
|
||||
log() {
|
||||
logger -t "ROAM" "$@"
|
||||
}
|
||||
|
||||
CURRMODEM=$1
|
||||
CPORT=$(uci get modem.modem$CURRMODEM.commport)
|
||||
|
||||
if [ -e /tmp/rlock ]; then
|
||||
source /tmp/rlock
|
||||
OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD")
|
||||
log "$OX"
|
||||
rm -f /tmp/rlock
|
||||
fi
|
34
rooter-extra/ext-simplegps/Makefile
Normal file
34
rooter-extra/ext-simplegps/Makefile
Normal file
@ -0,0 +1,34 @@
|
||||
#Owned by DairyMan@Whirlpool
|
||||
#
|
||||
#Copyright GNU act.
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=ext-simplegps
|
||||
PKG_VERSION:=1.000
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PKG_MAINTAINER:=Created by DM/makefile by Cobia@whirlpool
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/ext-simplegps
|
||||
SECTION:=utils
|
||||
CATEGORY:=ROOter
|
||||
SUBMENU:=Optional Applications
|
||||
DEPENDS:=+msmtp
|
||||
TITLE:=support for gps
|
||||
PKGARCH:=all
|
||||
endef
|
||||
|
||||
define Package/ext-simplegps/description
|
||||
Helper scripts to enable gps
|
||||
endef
|
||||
|
||||
|
||||
define Build/Compile
|
||||
endef
|
||||
|
||||
define Package/ext-simplegps/install
|
||||
$(CP) ./files/* $(1)/
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,ext-simplegps))
|
1
rooter-extra/ext-simplegps/files/etc/havegps
Normal file
1
rooter-extra/ext-simplegps/files/etc/havegps
Normal file
@ -0,0 +1 @@
|
||||
0
|
26
rooter-extra/ext-simplegps/files/usr/lib/gps/convert.lua
Normal file
26
rooter-extra/ext-simplegps/files/usr/lib/gps/convert.lua
Normal file
@ -0,0 +1,26 @@
|
||||
#!/usr/bin/lua
|
||||
|
||||
ldeg = arg[1]
|
||||
lmin = arg[2]
|
||||
lsecd = arg[3]
|
||||
lhemi = arg[4]
|
||||
sect = arg[5]
|
||||
|
||||
lmin = lmin / 60
|
||||
if sect == nil then
|
||||
lsecd = (lsecd * 6) /1000
|
||||
end
|
||||
lsec = lsecd / 3600
|
||||
ldegree = ldeg + lmin + lsec
|
||||
if lhemi == "S" then
|
||||
ldegree = -ldegree
|
||||
end
|
||||
if lhemi == "W" then
|
||||
ldegree = -ldegree
|
||||
end
|
||||
|
||||
sdeg = string.format("%.4f",ldegree)
|
||||
|
||||
local tfile = io.open("/tmp/latlon", "w")
|
||||
tfile:write("CONVERT=\"", sdeg, "\"")
|
||||
tfile:close()
|
75
rooter-extra/ext-simplegps/files/usr/lib/gps/gps.sh
Normal file
75
rooter-extra/ext-simplegps/files/usr/lib/gps/gps.sh
Normal file
@ -0,0 +1,75 @@
|
||||
#!/bin/sh
|
||||
|
||||
ROOTER=/usr/lib/rooter
|
||||
ROOTER_LINK="/tmp/links"
|
||||
|
||||
log() {
|
||||
logger -t "GPS" "$@"
|
||||
}
|
||||
|
||||
ifname1="ifname"
|
||||
if [ -e /etc/newstyle ]; then
|
||||
ifname1="device"
|
||||
fi
|
||||
|
||||
chksierra() {
|
||||
SIERRAID=0
|
||||
if [ $idV = 1199 ]; then
|
||||
case $idP in
|
||||
"68aa"|"68a2"|"68a3"|"68a9"|"68b0"|"68b1" )
|
||||
SIERRAID=1
|
||||
;;
|
||||
"68c0"|"9040"|"9041"|"9051"|"9054"|"9056"|"90d3" )
|
||||
SIERRAID=1
|
||||
;;
|
||||
"9070"|"907b"|"9071"|"9079"|"901c"|"9091"|"901f"|"90b1" )
|
||||
SIERRAID=1
|
||||
;;
|
||||
esac
|
||||
elif [ $idV = 114f -a $idP = 68a2 ]; then
|
||||
SIERRAID=1
|
||||
elif [ $idV = 413c -a $idP = 81a8 ]; then
|
||||
SIERRAID=1
|
||||
elif [ $idV = 413c -a $idP = 81b6 ]; then
|
||||
SIERRAID=1
|
||||
fi
|
||||
}
|
||||
|
||||
CURRMODEM=$1
|
||||
idV=$(uci -q get modem.modem$CURRMODEM.idV)
|
||||
idP=$(uci -q get modem.modem$CURRMODEM.idP)
|
||||
CPORT=$(uci get modem.modem$CURRMODEM.commport)
|
||||
|
||||
log "Running GPS script"
|
||||
|
||||
QUECTEL=false
|
||||
if [ "$idV" = "2c7c" ]; then
|
||||
QUECTEL=true
|
||||
elif [ "$idV" = "05c6" ]; then
|
||||
QUELST="9090,9003,9215"
|
||||
if [[ $(echo "$QUELST" | grep -o "$idP") ]]; then
|
||||
QUECTEL=true
|
||||
fi
|
||||
fi
|
||||
if $QUECTEL; then
|
||||
if [ -e /usr/lib/gps/quectel.sh ]; then
|
||||
result=`ps | grep -i "quectel.sh" | grep -v "grep" | wc -l`
|
||||
if [ $result -lt 1 ]; then
|
||||
/usr/lib/gps/quectel.sh $CURRMODEM &
|
||||
fi
|
||||
fi
|
||||
return
|
||||
fi
|
||||
|
||||
chksierra
|
||||
if [ $SIERRAID -eq 1 ]; then
|
||||
if [ -e /usr/lib/gps/sierra.sh ]; then
|
||||
result=`ps | grep -i "sierra.sh" | grep -v "grep" | wc -l`
|
||||
if [ $result -lt 1 ]; then
|
||||
/usr/lib/gps/sierra.sh $CURRMODEM &
|
||||
fi
|
||||
fi
|
||||
return
|
||||
fi
|
||||
|
||||
|
23
rooter-extra/ext-simplegps/files/usr/lib/gps/gpskill.sh
Normal file
23
rooter-extra/ext-simplegps/files/usr/lib/gps/gpskill.sh
Normal file
@ -0,0 +1,23 @@
|
||||
#!/bin/sh
|
||||
|
||||
CURRMODEM=$1
|
||||
ROOTER=/usr/lib/rooter
|
||||
CPORT=$(uci get modem.modem$CURRMODEM.commport)
|
||||
PID=$(ps | grep "[q]uectel.sh $CURRMODEM" | awk '{print $1}')
|
||||
if [ -n "$PID" ]; then
|
||||
kill -9 $PID
|
||||
ATCMDD="AT+QGPSEND"
|
||||
OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD")
|
||||
rm -f /tmp/gps
|
||||
rm -f /tmp/gpsdata
|
||||
rm -f /tmp/gpsdata1
|
||||
fi
|
||||
PID=$(ps | grep "[s]ierra.sh $CURRMODEM" | awk '{print $1}')
|
||||
if [ -n "$PID" ]; then
|
||||
kill -9 $PID
|
||||
ATCMDD="AT!GPSEND=0"
|
||||
OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD")
|
||||
rm -f /tmp/gps
|
||||
rm -f /tmp/gpsdata
|
||||
rm -f /tmp/gpsdata1
|
||||
fi
|
92
rooter-extra/ext-simplegps/files/usr/lib/gps/processq.sh
Normal file
92
rooter-extra/ext-simplegps/files/usr/lib/gps/processq.sh
Normal file
@ -0,0 +1,92 @@
|
||||
#!/bin/sh
|
||||
|
||||
ROOTER=/usr/lib/rooter
|
||||
ROOTER_LINK="/tmp/links"
|
||||
|
||||
log() {
|
||||
logger -t "Quectel GPS" "$@"
|
||||
}
|
||||
|
||||
OX=$1
|
||||
|
||||
if [ -z "$OX" ]; then
|
||||
if [ -e /tmp/lastgps ]; then
|
||||
OX=$(cat /tmp/lastgps)
|
||||
else
|
||||
exit 0
|
||||
fi
|
||||
else
|
||||
OX=$(cat /tmp/gpsox)
|
||||
echo "$OX" > /tmp/lastgps
|
||||
fi
|
||||
|
||||
O=$(echo "$OX" | grep "+QGPSLOC:")
|
||||
if [ -z "$O" ]; then
|
||||
exit 0
|
||||
fi
|
||||
OX=$(echo $O" " | tr ":" ",")
|
||||
|
||||
LAT=$(echo $OX | cut -d, -f3)
|
||||
LON=$(echo $OX | cut -d, -f4)
|
||||
|
||||
llen=$(expr length "$LAT")
|
||||
if [ $llen -eq 10 ]; then
|
||||
LAT="0"$LAT
|
||||
fi
|
||||
if [ $llen -eq 9 ]; then
|
||||
LAT="00"$LAT
|
||||
fi
|
||||
llen=$(expr length "$LON")
|
||||
if [ $llen -eq 10 ]; then
|
||||
LON="0"$LON
|
||||
fi
|
||||
if [ $llen -eq 9 ]; then
|
||||
LON="00"$LON
|
||||
fi
|
||||
|
||||
latdeg=${LAT:0:3}
|
||||
latmin=${LAT:3:2}
|
||||
latsec=${LAT:6:4}
|
||||
lathemi=${LAT:10:1}
|
||||
londeg=${LON:0:3}
|
||||
lonmin=${LON:3:2}
|
||||
lonsec=${LON:6:4}
|
||||
lonhemi=${LON:10:1}
|
||||
lathemid=$lathemi
|
||||
lonhemid=$lonhemi
|
||||
|
||||
let "latsecd=$latsec*6/1000"
|
||||
let "lonsecd=$lonsec*6/1000"
|
||||
|
||||
latdeg="${latdeg#"${latdeg%%[!0]*}"}"
|
||||
latmin="${latmin#"${latmin%%[!0]*}"}"
|
||||
if [ $lathemi = "S" ]; then
|
||||
lathemi="South"
|
||||
else
|
||||
lathemi="North"
|
||||
fi
|
||||
delatitude=$latdeg" Deg "$latmin" Min "$latsecd" Sec "$lathemi
|
||||
if [ $lonhemi = "E" ]; then
|
||||
lonhemi="East"
|
||||
else
|
||||
lonhemi="West"
|
||||
fi
|
||||
londeg="${londeg#"${londeg%%[!0]*}"}"
|
||||
lonmin="${lonmin#"${lonmin%%[!0]*}"}"
|
||||
delongitude=$londeg" Deg "$lonmin" Min "$lonsecd" Sec "$lonhemi
|
||||
/usr/lib/gps/convert.lua $latdeg $latmin $latsec $lathemid
|
||||
source /tmp/latlon
|
||||
dlatitude=$CONVERT
|
||||
/usr/lib/gps/convert.lua $londeg $lonmin $lonsec $lonhemid
|
||||
source /tmp/latlon
|
||||
dlongitude=$CONVERT
|
||||
|
||||
lat="$delatitude ( $dlatitude )"
|
||||
long="$delongitude ( $dlongitude )"
|
||||
echo 'LATITUDE="'"$lat"'"' >> /tmp/gpsdata
|
||||
echo 'LONGITUDE="'"$long"'"' >> /tmp/gpsdata
|
||||
|
||||
echo "$lat" > /tmp/gpsdata1
|
||||
echo "$long" >> /tmp/gpsdata1
|
||||
|
||||
echo "0" > /tmp/gps
|
77
rooter-extra/ext-simplegps/files/usr/lib/gps/processs.sh
Normal file
77
rooter-extra/ext-simplegps/files/usr/lib/gps/processs.sh
Normal file
@ -0,0 +1,77 @@
|
||||
#!/bin/sh
|
||||
|
||||
ROOTER=/usr/lib/rooter
|
||||
ROOTER_LINK="/tmp/links"
|
||||
|
||||
log() {
|
||||
logger -t "Quectel GPS" "$@"
|
||||
}
|
||||
|
||||
OX=$1
|
||||
|
||||
if [ -z "$OX" ]; then
|
||||
if [ -e /tmp/lastgps ]; then
|
||||
OX=$(cat /tmp/lastgps)
|
||||
else
|
||||
exit 0
|
||||
fi
|
||||
else
|
||||
OX=$(cat /tmp/gpsox)
|
||||
echo "$OX" > /tmp/lastgps
|
||||
fi
|
||||
|
||||
O=$(echo "$OX" | grep "at!gpsloc?")
|
||||
if [ -z "$O" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
CURRMODEM=1
|
||||
CPORT=$(uci get modem.modem$CURRMODEM.commport)
|
||||
ATCMDD="at!gpssatinfo?"
|
||||
OY=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD")
|
||||
echo "$OY" > /tmp/satgps
|
||||
Y=$(cat /tmp/satgps)
|
||||
OY=$(echo $Y" " | tr " " ",")
|
||||
|
||||
|
||||
OX=$(echo $OX" " | tr " " ",")
|
||||
LATD=$(echo $OX | cut -d, -f3)
|
||||
LATM=$(echo $OX | cut -d, -f5)
|
||||
LATS=$(echo $OX | cut -d, -f7)
|
||||
LATH=$(echo $OX | cut -d, -f9)
|
||||
|
||||
LOND=$(echo $OX | cut -d, -f12)
|
||||
LONM=$(echo $OX | cut -d, -f14)
|
||||
LONS=$(echo $OX | cut -d, -f16)
|
||||
LONH=$(echo $OX | cut -d, -f18)
|
||||
lathemid=$LATH
|
||||
lonhemid=$LONH
|
||||
|
||||
if [ $LATH = "S" ]; then
|
||||
LATH="South"
|
||||
else
|
||||
LATH="North"
|
||||
fi
|
||||
if [ $LONH = "E" ]; then
|
||||
LONH="East"
|
||||
else
|
||||
LONH="West"
|
||||
fi
|
||||
delatitude=$LATD" Deg "$LATM" Min "$LATS" Sec "$LATH
|
||||
delongitude=$LOND" Deg "$LONM" Min "$LONS" Sec "$LONH
|
||||
/usr/lib/gps/convert.lua $LATD $LATM $LATS $lathemid 1
|
||||
source /tmp/latlon
|
||||
dlatitude=$CONVERT
|
||||
/usr/lib/gps/convert.lua $LOND $LONM $LONS $lonhemid 1
|
||||
source /tmp/latlon
|
||||
dlongitude=$CONVERT
|
||||
|
||||
lat="$delatitude ( $dlatitude )"
|
||||
long="$delongitude ( $dlongitude )"
|
||||
echo 'LATITUDE="'"$lat"'"' >> /tmp/gpsdata
|
||||
echo 'LONGITUDE="'"$long"'"' >> /tmp/gpsdata
|
||||
|
||||
echo "$lat" > /tmp/gpsdata1
|
||||
echo "$long" >> /tmp/gpsdata1
|
||||
|
||||
echo "0" > /tmp/gps
|
61
rooter-extra/ext-simplegps/files/usr/lib/gps/quectel.sh
Normal file
61
rooter-extra/ext-simplegps/files/usr/lib/gps/quectel.sh
Normal file
@ -0,0 +1,61 @@
|
||||
#!/bin/sh
|
||||
|
||||
ROOTER=/usr/lib/rooter
|
||||
ROOTER_LINK="/tmp/links"
|
||||
|
||||
log() {
|
||||
logger -t "Quectel GPS" "$@"
|
||||
}
|
||||
|
||||
ifname1="ifname"
|
||||
if [ -e /etc/newstyle ]; then
|
||||
ifname1="device"
|
||||
fi
|
||||
|
||||
CURRMODEM=$1
|
||||
if [ $CURRMODEM = "2" ]; then
|
||||
exit 0
|
||||
fi
|
||||
CPORT=$(uci get modem.modem$CURRMODEM.commport)
|
||||
rm -f /tmp/gps
|
||||
rm -f /tmp/lastgps
|
||||
if [ -z "$CPORT" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
ATCMDD="AT+QGPS?"
|
||||
OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD")
|
||||
err=$(echo "$OX" | grep "+QGPS: 1")
|
||||
if [ -z "$err" ]; then
|
||||
ATCMDD="AT+QGPS=1"
|
||||
OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD")
|
||||
fi
|
||||
|
||||
log "GPS setup and waiting"
|
||||
|
||||
ATCMDD="AT+QCFG=\"gpsdrx\""
|
||||
OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD")
|
||||
err=$(echo "$OX" | grep "0")
|
||||
if [ -n "$err" ]; then
|
||||
ATCMDD="AT+QCFG=\"gpsdrx\",1"
|
||||
OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD")
|
||||
fi
|
||||
ATCMDD="AT+QGPSCFG=\"outport\",\"none\""
|
||||
OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD")
|
||||
|
||||
while true; do
|
||||
refresh=30
|
||||
ATCMDD="AT+QGPSLOC=0"
|
||||
OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD")
|
||||
err=$(echo "$OX" | grep "ERROR")
|
||||
if [ -z "$err" ]; then
|
||||
echo "$OX" > /tmp/gpsox
|
||||
result=`ps | grep -i "processq.sh" | grep -v "grep" | wc -l`
|
||||
if [ $result -lt 1 ]; then
|
||||
/usr/lib/gps/processq.sh 1
|
||||
fi
|
||||
sleep $refresh
|
||||
else
|
||||
sleep 5
|
||||
fi
|
||||
done
|
64
rooter-extra/ext-simplegps/files/usr/lib/gps/sierra.sh
Normal file
64
rooter-extra/ext-simplegps/files/usr/lib/gps/sierra.sh
Normal file
@ -0,0 +1,64 @@
|
||||
#!/bin/sh
|
||||
|
||||
ROOTER=/usr/lib/rooter
|
||||
ROOTER_LINK="/tmp/links"
|
||||
|
||||
log() {
|
||||
logger -t "Sierra GPS" "$@"
|
||||
}
|
||||
|
||||
ifname1="ifname"
|
||||
if [ -e /etc/newstyle ]; then
|
||||
ifname1="device"
|
||||
fi
|
||||
|
||||
CURRMODEM=$1
|
||||
CPORT=$(uci get modem.modem$CURRMODEM.commport)
|
||||
rm -f /tmp/gps
|
||||
rm -f /tmp/lastgps
|
||||
if [ -z "$CPORT" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
ATCMDD="AT!CUSTOM?"
|
||||
OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD")
|
||||
|
||||
GPSsel=$(echo $OX | grep "GPSSEL")
|
||||
GPSenable=$(echo $OX | grep "GPSENABLE")
|
||||
if [ -z "$GPSsel" -o -z "$GPSenable" ]; then
|
||||
ATCMDD="AT!ENTERCND=\"A710\""
|
||||
OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD")
|
||||
if [ -z "$GPSsel" ]; then
|
||||
ATCMDD="at!custom=\"GPSSEL\",1"
|
||||
OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD")
|
||||
fi
|
||||
if [ -z "$GPSenable" ]; then
|
||||
ATCMDD="at!custom=\"GPSENABLE\",1"
|
||||
OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD")
|
||||
ATCMDD="AT+CFUN=0;+CFUN=1,1"
|
||||
OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD")
|
||||
exit
|
||||
fi
|
||||
ATCMDD="AT!ENTERCND=\"AWRONG\""
|
||||
OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD")
|
||||
fi
|
||||
|
||||
ATCMDD="AT!GPSTRACK=1,240,30,1000,5"
|
||||
OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD")
|
||||
|
||||
while true; do
|
||||
refresh=30
|
||||
ATCMDD="at!gpsloc?"
|
||||
OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD")
|
||||
err=$(echo "$OX" | grep "Not Available")
|
||||
if [ -z "$err" ]; then
|
||||
echo "$OX" > /tmp/gpsox
|
||||
result=`ps | grep -i "processs.sh" | grep -v "grep" | wc -l`
|
||||
if [ $result -lt 1 ]; then
|
||||
/usr/lib/gps/processs.sh 1
|
||||
fi
|
||||
sleep $refresh
|
||||
else
|
||||
sleep 5
|
||||
fi
|
||||
done
|
63
rooter-extra/mesh11sd/Makefile
Normal file
63
rooter-extra/mesh11sd/Makefile
Normal file
@ -0,0 +1,63 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v2.
|
||||
# See /LICENSE for more information.
|
||||
# Copyright (C) 2022 BlueWave Projects and Services <licence@blue-wave.net>
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=mesh11sd
|
||||
PKG_VERSION:=1.2.0
|
||||
PKG_RELEASE:=$(AUTORELEASE)
|
||||
|
||||
PKG_MAINTAINER:=Rob White <rob@blue-wave.net>
|
||||
PKG_LICENSE:=GPL-2.0-or-later
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=https://codeload.github.com/opennds/mesh11sd/tar.gz/v$(PKG_VERSION)?
|
||||
PKG_HASH:=b719eaacf63eb3684d0cd6a026f4357a4f400f2339f5d5a6cf74ba3744fe30d8
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/mesh11sd-$(PKG_VERSION)
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/mesh11sd
|
||||
SUBMENU:=Captive Portals
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
TITLE:=Dynamic 802.11s Mesh Configuration Daemon
|
||||
PKGARCH:=all
|
||||
URL:=https://github.com/opennds/mesh11sd
|
||||
endef
|
||||
|
||||
define Package/mesh11sd/description
|
||||
Mesh11sd is a dynamic parameter configuration daemon for 802.11s mesh networks.
|
||||
It was originally designed to leverage 802.11s mesh networking at Captive Portal venues.
|
||||
This is the open source version and it enables easy and automated mesh network operation with multiple mesh nodes.
|
||||
It allows all mesh parameters supported by the wireless driver to be set in the uci config file.
|
||||
Settings take effect immediately without having to restart the wireless network.
|
||||
Default settings give rapid and reliable layer 2 mesh convergence.
|
||||
Without mesh11sd, many mesh parameters cannot be set in the uci wireless config file as the mesh interface must be up before the parameters can be set.
|
||||
Some of those that are supported, would fail to be implemented when the network is (re)started resulting in errors or dropped nodes.
|
||||
The mesh11sd daemon dynamically checks configured parameters and sets them as required.
|
||||
This version does not require a Captive Portal to be running.
|
||||
endef
|
||||
|
||||
define Package/mesh11sd/install
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/mesh11sd $(1)/usr/sbin
|
||||
$(INSTALL_CONF) $(PKG_BUILD_DIR)/linux_openwrt/mesh11sd/files/etc/config/mesh11sd $(1)/etc/config/
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/linux_openwrt/mesh11sd/files/etc/init.d/mesh11sd $(1)/etc/init.d/
|
||||
endef
|
||||
|
||||
define Package/mesh11sd/conffiles
|
||||
/etc/config/mesh11sd
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,mesh11sd))
|
42
rooter-extra/speedtestpp/Makefile
Normal file
42
rooter-extra/speedtestpp/Makefile
Normal file
@ -0,0 +1,42 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=speedtestpp
|
||||
PKG_VERSION:=1.14
|
||||
PKG_RELEASE:=$(AUTORELEASE)
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL:=https://github.com/taganaka/SpeedTest.git
|
||||
PKG_SOURCE_DATE:=2021-12-06
|
||||
PKG_SOURCE_VERSION:=0f63cfbf7ce8d64ea803bf143b957eae76323405
|
||||
PKG_MIRROR_HASH:=4221584dc3e1e31f2560ef347298a2bcca3ac2331049970b7bd7d742e4e1825f
|
||||
|
||||
PKG_MAINTAINER:=Oskari Rauta <oskari.rauta@gmail.com>
|
||||
PKG_LICENSE:=MIT
|
||||
|
||||
CMAKE_INSTALL:=1
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
include $(INCLUDE_DIR)/nls.mk
|
||||
include $(INCLUDE_DIR)/cmake.mk
|
||||
|
||||
CMAKE_OPTIONS += -DCMAKE_BUILD_TYPE=Release .
|
||||
|
||||
define Package/speedtestpp
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
TITLE:=speedtest++
|
||||
DEPENDS:=+libcurl +libxml2 +libopenssl +libstdcpp $(ICONV_DEPENDS)
|
||||
CONFLICTS:=python3-speedtest-cli
|
||||
URL:=https://github.com/taganaka/SpeedTest
|
||||
endef
|
||||
|
||||
define Package/speedtestpp/description
|
||||
Yet another unofficial speedtest.net client cli interface
|
||||
endef
|
||||
|
||||
define Package/speedtestpp/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(CP) $(PKG_INSTALL_DIR)/usr/bin/SpeedTest $(1)/usr/bin/speedtest
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,speedtestpp))
|
@ -24,7 +24,7 @@ if [ $PARM = "1" ]; then
|
||||
let "TH = $HOUR * 4"
|
||||
let "TMP1 = $SDHOUR - $TH"
|
||||
let "MIN = $TMP1 * 15"
|
||||
echo "$MIN $HOUR * * * sleep 70 && touch /etc/banner && reboot -f" > /etc/cronbase
|
||||
echo "$MIN $HOUR * * * sleep 70 && touch /etc/banner && /usr/lib/rooter/luci/rebootmodem.sh" > /etc/cronbase
|
||||
else
|
||||
rm -f /etc/cronbase
|
||||
fi
|
||||
|
@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
log() {
|
||||
logger -t "sdcard" "$@"
|
||||
modlog "sdcard" "$@"
|
||||
}
|
||||
|
||||
h721() {
|
||||
@ -16,62 +16,45 @@ h721() {
|
||||
fi
|
||||
}
|
||||
|
||||
wg1608() {
|
||||
ws1208() {
|
||||
if [ $1 = "add" ]; then
|
||||
echo timer > /sys/class/leds/zbt-wg3526:green:signal/trigger
|
||||
echo 1000 > /sys/class/leds/zbt-wg3526:green:signal/delay_on
|
||||
echo 0 > /sys/class/leds/zbt-wg3526:green:signal/delay_off
|
||||
echo none > /sys/class/leds/usb/trigger
|
||||
echo 1 > /sys/class/leds/usb/brightness
|
||||
else
|
||||
echo timer > /sys/class/leds/zbt-wg3526:green:signal/trigger
|
||||
echo 0 > /sys/class/leds/zbt-wg3526:green:signal/delay_on
|
||||
echo 1000 > /sys/class/leds/zbt-wg3526:green:signal/delay_off
|
||||
fi
|
||||
}
|
||||
|
||||
ws7915() {
|
||||
if [ $1 = "add" ]; then
|
||||
echo timer > /sys/class/leds/sys/trigger
|
||||
echo 1000 > /sys/class/leds/sys/delay_on
|
||||
echo 0 > /sys/class/leds/sys/delay_off
|
||||
else
|
||||
echo timer > /sys/class/leds/sys/trigger
|
||||
echo 0 > /sys/class/leds/sys/delay_on
|
||||
echo 1000 > /sys/class/leds/sys/delay_off
|
||||
echo none > /sys/class/leds/usb/trigger
|
||||
echo 0 > /sys/class/leds/usb/brightness
|
||||
fi
|
||||
}
|
||||
|
||||
ws1688() {
|
||||
if [ $1 = "add" ]; then
|
||||
echo timer > /sys/class/leds/usb/trigger
|
||||
echo 1000 > /sys/class/leds/usb/delay_on
|
||||
echo 0 > /sys/class/leds/usb/delay_off
|
||||
echo none > /sys/class/leds/usb/trigger
|
||||
echo 1 > /sys/class/leds/usb/brightness
|
||||
else
|
||||
echo timer > /sys/class/leds/usb/trigger
|
||||
echo 0 > /sys/class/leds/usb/delay_on
|
||||
echo 1000 > /sys/class/leds/usb/delay_off
|
||||
echo none > /sys/class/leds/usb/trigger
|
||||
echo 0 > /sys/class/leds/usb/brightness
|
||||
fi
|
||||
}
|
||||
|
||||
ACTION=$1
|
||||
model=$(cat /tmp/sysinfo/model)
|
||||
|
||||
case $ACTION in
|
||||
"add"|"remove" )
|
||||
mod=$(echo $model | grep "H721")
|
||||
if [ $mod ]; then
|
||||
if [ ! -z "$mod" ]; then
|
||||
h721 $ACTION
|
||||
fi
|
||||
mod=$(echo $model | grep "WG1608")
|
||||
if [ $mod ]; then
|
||||
wg1608 $ACTION
|
||||
mod=$(echo $model | grep "WS1208V2")
|
||||
if [ ! -z "$mod" ]; then
|
||||
ws1208 $ACTION
|
||||
fi
|
||||
mod=$(echo $model | grep "WS7915")
|
||||
if [ $mod ]; then
|
||||
ws7915 $ACTION
|
||||
mod=$(echo $model | grep "WS1218")
|
||||
if [ ! -z "$mod" ]; then
|
||||
ws1208 $ACTION
|
||||
fi
|
||||
|
||||
mod=$(echo $model | grep "WS1688")
|
||||
if [ $mod ]; then
|
||||
if [ ! -z "$mod" ]; then
|
||||
ws1688 $ACTION
|
||||
fi
|
||||
;;
|
||||
|
@ -5,14 +5,14 @@ translate = I18N.translate
|
||||
|
||||
function index()
|
||||
local fs = require "nixio.fs"
|
||||
|
||||
|
||||
|
||||
local multilock = luci.model.uci.cursor():get("custom", "multiuser", "multi") or "0"
|
||||
local rootlock = luci.model.uci.cursor():get("custom", "multiuser", "root") or "0"
|
||||
if (multilock == "0") or (multilock == "1" and rootlock == "1") then
|
||||
if not fs.stat("/etc/nosms") then
|
||||
local page
|
||||
page = entry({"admin", "modem", "sms"}, template("rooter/sms"), translate("短信功能"), 35)
|
||||
page = entry({"admin", "modem", "sms"}, template("rooter/sms"), translate("SMS Messaging"), 35)
|
||||
page.dependent = true
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
entry({"admin", "modem", "check_read"}, call("action_check_read"))
|
||||
@ -21,6 +21,7 @@ function index()
|
||||
entry({"admin", "modem", "change_sms"}, call("action_change_sms"))
|
||||
entry({"admin", "modem", "change_smsdn"}, call("action_change_smsdn"))
|
||||
entry({"admin", "modem", "change_smsflag"}, call("action_change_smsflag"))
|
||||
entry({"admin", "modem", "delall_sms"}, call("action_delall_sms"))
|
||||
end
|
||||
|
||||
function trim(s)
|
||||
@ -71,10 +72,14 @@ function action_send_sms()
|
||||
luci.http.write_json(rv)
|
||||
end
|
||||
|
||||
function action_delall_sms()
|
||||
smsnum = luci.model.uci.cursor():get("modem", "general", "smsnum")
|
||||
os.execute("/usr/lib/sms/delall.sh " .. smsnum)
|
||||
end
|
||||
|
||||
function action_del_sms()
|
||||
local set = tonumber(luci.http.formvalue("set"))
|
||||
if set ~= nil and set > 0 then
|
||||
set = set - 1;
|
||||
local set = luci.http.formvalue("set")
|
||||
if set ~= nil then
|
||||
smsnum = luci.model.uci.cursor():get("modem", "general", "smsnum")
|
||||
os.execute("/usr/lib/sms/delsms.sh " .. smsnum .. " " .. set)
|
||||
os.execute("touch /tmp/smswakeup" .. smsnum)
|
||||
@ -122,7 +127,7 @@ function action_check_read()
|
||||
line = file:read("*line")
|
||||
full = full .. line
|
||||
if k < i then
|
||||
full = full .. '<br />'
|
||||
full = full .. '\n'
|
||||
end
|
||||
end
|
||||
else
|
||||
@ -157,4 +162,3 @@ function action_change_smsflag()
|
||||
local set = tonumber(luci.http.formvalue("set"))
|
||||
os.execute("/usr/lib/sms/toggle.sh " .. set)
|
||||
end
|
||||
|
||||
|
@ -22,30 +22,30 @@
|
||||
if ( ss == "0" )
|
||||
{
|
||||
clearListBox("smsList");
|
||||
document.getElementById('message').innerHTML="";
|
||||
document.getElementById('message').value="";
|
||||
document.getElementById('total').innerHTML="";
|
||||
document.getElementById('used').innerHTML="";
|
||||
document.getElementById('mslots').innerHTML="";
|
||||
document.getElementById('menb').checked=false;
|
||||
document.getElementById('supported').innerHTML="<%:模块未适配短信支持/未连接到模块%>";
|
||||
document.getElementById('supported').innerHTML="<%:SMS Not Supported/No Modem%>";
|
||||
}
|
||||
if ( ss == "1" )
|
||||
{
|
||||
clearListBox("smsList");
|
||||
document.getElementById('message').innerHTML="";
|
||||
document.getElementById('message').value="";
|
||||
document.getElementById('total').innerHTML="";
|
||||
document.getElementById('used').innerHTML="";
|
||||
document.getElementById('mslots').innerHTML="";
|
||||
document.getElementById('menb').checked=false;
|
||||
document.getElementById('supported').innerHTML="<%:您有未读的短信,请前往查看%>";
|
||||
document.getElementById('supported').innerHTML="<%:Waiting to Read Messages%>";
|
||||
}
|
||||
if ( ss == "3" )
|
||||
{
|
||||
document.getElementById('supported').innerHTML="<%:消息读取有问题%>";
|
||||
document.getElementById('supported').innerHTML="<%:Message Read Problem%>";
|
||||
}
|
||||
if ( ss == "2" )
|
||||
{
|
||||
document.getElementById('supported').innerHTML="<%:存在的短信%>";
|
||||
document.getElementById('supported').innerHTML="<%:Messages Present%>";
|
||||
clearListBox("smsList");
|
||||
document.getElementById('total').innerHTML=rv.max;
|
||||
document.getElementById('used').innerHTML=rv.used;
|
||||
@ -75,7 +75,7 @@
|
||||
}
|
||||
if (rv.used == "0")
|
||||
{
|
||||
document.getElementById('supported').innerHTML="<%:SIM卡上没有短信%>";
|
||||
document.getElementById('supported').innerHTML="<%:No Messages Present on SIM%>";
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -86,7 +86,7 @@
|
||||
var i;
|
||||
for(i=0;i<len;i++)
|
||||
{
|
||||
index[indx] = parseInt(arr[i]);
|
||||
index[indx] = arr[i];
|
||||
number[indx] = arr[i+1];
|
||||
ttext[indx] = arr[i+2];
|
||||
var txtline = arr[i+3];
|
||||
@ -102,7 +102,7 @@
|
||||
if ( selectline == -1 )
|
||||
{
|
||||
select.value = 0;
|
||||
document.getElementById('message').innerHTML=ttext[0];
|
||||
document.getElementById('message').value=ttext[0];
|
||||
selectline = 0;
|
||||
}
|
||||
else
|
||||
@ -112,7 +112,7 @@
|
||||
selectline = indx -1 ;
|
||||
}
|
||||
select.value = selectline;
|
||||
document.getElementById('message').innerHTML=ttext[selectline];
|
||||
document.getElementById('message').value=ttext[selectline];
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -120,7 +120,7 @@
|
||||
}
|
||||
);
|
||||
|
||||
document.getElementById('message').innerHTML=" ";
|
||||
document.getElementById('message').value=" ";
|
||||
document.getElementById('total').innerHTML="0";
|
||||
document.getElementById('used').innerHTML="0";
|
||||
document.getElementById('mslots').innerHTML="0";
|
||||
@ -167,7 +167,7 @@
|
||||
{
|
||||
var s = document.getElementById("smsList").value;
|
||||
selectline = s;
|
||||
document.getElementById('message').innerHTML=ttext[s];
|
||||
document.getElementById('message').value=ttext[s];
|
||||
}
|
||||
|
||||
function sendsms()
|
||||
@ -180,13 +180,13 @@
|
||||
//document.getElementById('rding').innerHTML=s.length;
|
||||
if ( s.length == 0 )
|
||||
{
|
||||
alert("<%:请输入电话号码!!%>");
|
||||
alert("<%:You must enter a phone number!!%>");
|
||||
return false;
|
||||
}
|
||||
s = s.trim();
|
||||
if ( isNaN(s) == true )
|
||||
{
|
||||
alert("<%:错误的电话号码!!%>");
|
||||
alert("<%:Invalid phone number!!%>");
|
||||
return false;
|
||||
}
|
||||
var num = s.concat(" ");
|
||||
@ -203,7 +203,7 @@
|
||||
}
|
||||
num = num.concat(t);
|
||||
alert("<%:SMS will be queued for processing.\nA status update will follow.%>");
|
||||
document.getElementById("sstat").innerHTML="<%:状态 :消息正在发送%>";
|
||||
document.getElementById("sstat").innerHTML="<%:Sending Message. Please Wait%>";
|
||||
XHR.get('<%=luci.dispatcher.build_url("admin", "modem", "send_sms")%>',
|
||||
{ set: num },
|
||||
function(x, rv)
|
||||
@ -215,26 +215,7 @@
|
||||
);
|
||||
}
|
||||
|
||||
function delsms()
|
||||
{
|
||||
if ( selectline == -1 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var r=confirm("<%:确认删除选中消息 ?%>");
|
||||
if (r==false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var s = document.getElementById("smsList").value;
|
||||
var dx = index[s];
|
||||
dx = dx + 1;
|
||||
clearListBox("smsList");
|
||||
document.getElementById('message').style.color = "red";
|
||||
document.getElementById('message').innerHTML="<%:短信将被删除,同步到列表可能会很久(反复提交删除申请一样很久)%>";
|
||||
XHR.get('<%=luci.dispatcher.build_url("admin", "modem", "del_sms")%>',
|
||||
{ set: dx },
|
||||
function()
|
||||
function readcheck()
|
||||
{
|
||||
XHR.get('<%=luci.dispatcher.build_url("admin", "modem", "check_read")%>', null,
|
||||
function(x, rv)
|
||||
@ -245,18 +226,18 @@
|
||||
if ( ss == "1" )
|
||||
{
|
||||
clearListBox("smsList");
|
||||
document.getElementById('message').innerHTML="";
|
||||
document.getElementById('message').value="";
|
||||
document.getElementById('total').innerHTML="";
|
||||
document.getElementById('used').innerHTML="";
|
||||
document.getElementById('supported').innerHTML="<%:您有未读的短信,请前往查看%>";
|
||||
document.getElementById('supported').innerHTML="<%:Waiting to Read Messages%>";
|
||||
}
|
||||
if ( ss == "3" )
|
||||
{
|
||||
document.getElementById('supported').innerHTML="<%:消息读取有问题%>";
|
||||
document.getElementById('supported').innerHTML="<%:Message Read Problem%>";
|
||||
}
|
||||
if ( ss == "2" )
|
||||
{
|
||||
document.getElementById('supported').innerHTML="<%:存在短信%>";
|
||||
document.getElementById('supported').innerHTML="<%:Messages Present%>";
|
||||
clearListBox("smsList");
|
||||
document.getElementById('total').innerHTML=rv.max;
|
||||
document.getElementById('used').innerHTML=rv.used;
|
||||
@ -283,7 +264,7 @@
|
||||
if ( selectline == -1 )
|
||||
{
|
||||
select.value = 0;
|
||||
document.getElementById('message').innerHTML=ttext[0];
|
||||
document.getElementById('message').value=ttext[0];
|
||||
selectline = 0;
|
||||
}
|
||||
else
|
||||
@ -293,13 +274,55 @@
|
||||
selectline = indx -1 ;
|
||||
}
|
||||
select.value = selectline;
|
||||
document.getElementById('message').innerHTML=ttext[selectline];
|
||||
document.getElementById('message').value=ttext[selectline];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function delallsms()
|
||||
{
|
||||
var r=confirm("<%:Do you really want to delete all SMS?%>");
|
||||
if (r==false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
clearListBox("smsList");
|
||||
document.getElementById('message').style.color = "red";
|
||||
document.getElementById('message').value="<%:All Messages will be deleted. It may take some time before the list is updated.%>";
|
||||
XHR.get('<%=luci.dispatcher.build_url("admin", "modem", "delall_sms")%>',
|
||||
null,
|
||||
function()
|
||||
{
|
||||
readcheck();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function delsms()
|
||||
{
|
||||
if ( selectline == -1 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var r=confirm("<%:Delete the selected message?%>");
|
||||
if (r==false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var s = document.getElementById("smsList").value;
|
||||
var dx = index[s];
|
||||
clearListBox("smsList");
|
||||
document.getElementById('message').style.color = "red";
|
||||
document.getElementById('message').value="<%:Message will be deleted. It may take some time before the list is updated.%>";
|
||||
XHR.get('<%=luci.dispatcher.build_url("admin", "modem", "del_sms")%>',
|
||||
{ set: dx },
|
||||
function()
|
||||
{
|
||||
readcheck();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@ -350,7 +373,7 @@
|
||||
function(x, rv)
|
||||
{
|
||||
btn.disabled = false;
|
||||
btn.value = '<%:下一个模块%>';
|
||||
btn.value = '<%:Next Modem%>';
|
||||
}
|
||||
);
|
||||
|
||||
@ -393,28 +416,28 @@
|
||||
|
||||
<form method="post" action="<%=REQUEST_URI%>">
|
||||
<div class="cbi-map" id="cbi-sms">
|
||||
<h2><a id="content" name="content"><%:短信收发页面%></a></h2>
|
||||
<div class="cbi-map-descr"><%:通过模块发送和接收文本消息%></div>
|
||||
<h2><a id="content" name="content"><%:SMS Messaging%></a></h2>
|
||||
<div class="cbi-map-descr"><%:Send and Receive Text Messages Through Your Modem%></div>
|
||||
<fieldset class="cbi-section" id="cbi-read">
|
||||
<legend><%:通信模块信息%></legend>
|
||||
<legend><%:Modem Information%></legend>
|
||||
<table width="550" border="0">
|
||||
<tr>
|
||||
<td width="40%"><ul id="supported"></ul></td>
|
||||
<td width="17%"><strong id="conntype"></strong></td>
|
||||
<td width="12%">
|
||||
<input type="button" class="cbi-button cbi-button-apply" value="<%:上一个模块%>" onclick="return modemtoggledn(this)" />
|
||||
<input type="button" class="cbi-button cbi-button-apply" value="<%:Prev Modem%>" onclick="return modemtoggledn(this)" />
|
||||
</td>
|
||||
<td width="31%">
|
||||
<input type="button" class="cbi-button cbi-button-apply" value="<%:下一个模块%>" onclick="return modemtoggle(this)" />
|
||||
<input type="button" class="cbi-button cbi-button-apply" value="<%:Next Modem%>" onclick="return modemtoggle(this)" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<legend><%:收到的短信%></legend>
|
||||
<legend><%:Received Messages%></legend>
|
||||
|
||||
<table width="550" border="0">
|
||||
<tr>
|
||||
<td width="18%"><div align="center"><strong><%:SIM可存放的短信空间 (条)%></strong></div></td>
|
||||
<td width="18%"><div align="center"><strong><%:已使用的SIM短信空间 (条)%></strong></div></td>
|
||||
<td width="18%"><div align="center"><strong><u><%:Total SIM Message Slots%></u></strong></div></td>
|
||||
<td width="18%"><div align="center"><strong><u><%:Used SIM Message Slots%></u></strong></div></td>
|
||||
<td width="34%"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
@ -427,11 +450,11 @@
|
||||
<table width="550" border="0">
|
||||
<tr>
|
||||
<td width="3%"> </td>
|
||||
<td width="20%"><div align="left"><%:启用模块到SIM卡的短信传输%></div></td>
|
||||
<td width="20%"><div align="left"><%:Enable SMS transfer from modem to SIM%></div></td>
|
||||
<td width="8%">
|
||||
<input type="checkbox" id="menb" onclick="memenable(this)" />
|
||||
</td>
|
||||
<td width="16%"><div align="left"><strong><u><%:模块上的未读信息数量%></u></strong></div></td>
|
||||
<td width="16%"><div align="left"><strong><u><%:Unread SMS count on modem%></u></strong></div></td>
|
||||
<td width="34%"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
@ -445,12 +468,19 @@
|
||||
|
||||
<table width="700" border="0">
|
||||
<tr>
|
||||
<td width="4%"><div align="center"><strong><u><%:已读状态%></u></strong></div></td>
|
||||
<td width="18%"><div align="left"><strong><u><%:发件人%></u></strong></div></td>
|
||||
<td width="8%"><div align="left"><strong><u><%:Date%></u></strong></div></td>
|
||||
<td width="11%"><div align="left"><strong><u><%:时间%></u></strong></div></td>
|
||||
<td width="35%"><div align="left"><strong><u><%:短信%></u></strong></div></td>
|
||||
<td width="3%"> </td>
|
||||
<td width="17%"><input type="button" id="delallbtn" class="cbi-button cbi-button-remove" value="<%:Delete All Messages%>" onclick="return delallsms()" /></td>
|
||||
<td width="80%"> </td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table width="700" border="0">
|
||||
<tr>
|
||||
<td width="4%"><div align="center"><strong><u><%:Read%></u></strong></div></td>
|
||||
<td width="18%"><div align="left"><strong><u><%:Sender%></u></strong></div></td>
|
||||
<td width="8%"><div align="left"><strong><u><%:Date%></u></strong></div></td>
|
||||
<td width="11%"><div align="left"><strong><u><%:Time%></u></strong></div></td>
|
||||
<td width="35%"><div align="left"><strong><u><%:Message%></u></strong></div></td>
|
||||
<td width="24%"><div align="left"> </div></td>
|
||||
|
||||
</tr>
|
||||
@ -467,26 +497,29 @@
|
||||
|
||||
<table width="550" border="0">
|
||||
<tr>
|
||||
<td width="15%"><div align="left"><strong><%:短信内容 :%></strong></div></td>
|
||||
<td width="70%"><ul id="message"></ul></td>
|
||||
<td width="15%"> </td>
|
||||
<td width="7%"><div align="left"><strong><%:Message :%></strong></div></td>
|
||||
<!-- <td width="70%"><ul id="message"></ul></td> -->
|
||||
<td width="80%">
|
||||
<textarea readonly="readonly" name="message" id="message" rows="6" style="font-size : 20px;width: 600px;" maxlength="160"></textarea>
|
||||
</td>
|
||||
<td width="13%"> </td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table width="550" border="0">
|
||||
<tr>
|
||||
<td width="17%"><input type="button" id="delbtn" class="cbi-button cbi-button-apply" value="<%:删除短信%>" onclick="return delsms()" /></td>
|
||||
<td width="17%"><input type="button" id="replybtn" class="cbi-button cbi-button-apply" value="<%:回复短信%>" onclick="return replysms()" /></td>
|
||||
<td width="17%"><input type="button" id="newbtn" class="cbi-button cbi-button-apply" value="<%:新建短信%>" onclick="return newsms()" /></td>
|
||||
<td width="17%"><input type="button" id="delbtn" class="cbi-button cbi-button-remove" value="<%:Delete Message%>" onclick="return delsms()" /></td>
|
||||
<td width="17%"><input type="button" id="replybtn" class="cbi-button cbi-button-apply" value="<%:Reply to Message%>" onclick="return replysms()" /></td>
|
||||
<td width="17%"><input type="button" id="newbtn" class="cbi-button cbi-button-apply" value="<%:New Message%>" onclick="return newsms()" /></td>
|
||||
<td width="49%"> </td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<legend id="sendtitle" style="display:block;"><%:短信会话%></legend>
|
||||
<legend id="sendtitle" style="display:block;"><%:Send Messages%></legend>
|
||||
|
||||
<table id="sendmsg" width="600" border="0" style="display:table;">
|
||||
<tr>
|
||||
<td width="15%"><div align="left"><strong><%:收件人 :%></strong></div></td>
|
||||
<td width="15%"><div align="left"><strong><%:Send To :%></strong></div></td>
|
||||
<td width="70%"><input name="sendto" id="sendto" maxlength="20"></input></td>
|
||||
<td width="15%"> </td>
|
||||
</tr>
|
||||
@ -494,7 +527,6 @@
|
||||
|
||||
<table id="sendtxt" width="700" border="0" style="display:table;">
|
||||
<tr>
|
||||
|
||||
<td width="100%">
|
||||
<textarea name="txtmessage" id="txtmessage" rows="6" style="width: 600px;" maxlength="160"></textarea>
|
||||
</td>
|
||||
@ -511,7 +543,7 @@
|
||||
|
||||
<table width="550" border="0">
|
||||
<tr>
|
||||
<td width="15%"><div align="left"><strong><%:短信发送状态 :%></strong></div></td>
|
||||
<td width="15%"><div align="left"><strong><%:Sending Status :%></strong></div></td>
|
||||
<td width="70%"><ul style="color:red" id="sstat"></ul></td>
|
||||
<td width="15%"> </td>
|
||||
</tr>
|
||||
@ -522,4 +554,3 @@
|
||||
</div>
|
||||
</form>
|
||||
<%+footer%>
|
||||
|
||||
|
35
rooter/0basicsupport/ext-sms/files/usr/lib/sms/delall.sh
Normal file
35
rooter/0basicsupport/ext-sms/files/usr/lib/sms/delall.sh
Normal file
@ -0,0 +1,35 @@
|
||||
#!/bin/sh
|
||||
|
||||
ROOTER=/usr/lib/rooter
|
||||
|
||||
log() {
|
||||
modlog "Delete SMS" "$@"
|
||||
}
|
||||
|
||||
CURRMODEM=$1
|
||||
COMMPORT="/dev/ttyUSB"$(uci get modem.modem$CURRMODEM.commport)
|
||||
SMSLOC=$(uci -q get modem.modem$CURRMODEM.smsloc)
|
||||
|
||||
LOCKDIR="/tmp/smslock$CURRMODEM"
|
||||
PIDFILE="${LOCKDIR}/PID"
|
||||
|
||||
while [ 1 -lt 6 ]; do
|
||||
if mkdir "${LOCKDIR}" &>/dev/null; then
|
||||
echo "$$" > "${PIDFILE}"
|
||||
ATCMDD="AT+CPMS=\"$SMSLOC\";+CMGD=1,4"
|
||||
OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD")
|
||||
log "$OX"
|
||||
uci set modem.modem$CURRMODEM.smsnum=999
|
||||
uci commit modem
|
||||
break
|
||||
else
|
||||
OTHERPID="$(cat "${PIDFILE}")"
|
||||
if [ $? = 0 ]; then
|
||||
if ! kill -0 $OTHERPID &>/dev/null; then
|
||||
rm -rf "${LOCKDIR}"
|
||||
fi
|
||||
fi
|
||||
sleep 1
|
||||
fi
|
||||
done
|
||||
rm -rf "${LOCKDIR}"
|
@ -3,12 +3,13 @@
|
||||
ROOTER=/usr/lib/rooter
|
||||
|
||||
log() {
|
||||
logger -t "Delete SMS" "$@"
|
||||
modlog "Delete SMS" "$@"
|
||||
}
|
||||
|
||||
CURRMODEM=$1
|
||||
shift 1
|
||||
SLOTS="$@"
|
||||
log "$SLOTS"
|
||||
|
||||
COMMPORT="/dev/ttyUSB"$(uci get modem.modem$CURRMODEM.commport)
|
||||
|
||||
@ -17,13 +18,14 @@ SMSLOC=$(uci -q get modem.modem$CURRMODEM.smsloc)
|
||||
LOCKDIR="/tmp/smslock$CURRMODEM"
|
||||
PIDFILE="${LOCKDIR}/PID"
|
||||
|
||||
while [ 1 -lt 6 ]; do
|
||||
while [ true ]; do
|
||||
if mkdir "${LOCKDIR}" &>/dev/null; then
|
||||
echo "$$" > "${PIDFILE}"
|
||||
for SLOT in $SLOTS
|
||||
do
|
||||
ATCMDD="AT+CPMS=\"$SMSLOC\";+CMGD=$SLOT"
|
||||
OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD")
|
||||
log "$OX"
|
||||
done
|
||||
uci set modem.modem$CURRMODEM.smsnum=999
|
||||
uci commit modem
|
||||
|
190
rooter/0basicsupport/ext-sms/files/usr/lib/sms/merge.lua
Normal file
190
rooter/0basicsupport/ext-sms/files/usr/lib/sms/merge.lua
Normal file
@ -0,0 +1,190 @@
|
||||
#!/usr/bin/lua
|
||||
|
||||
function ltrim(s)
|
||||
return s:match'^%s*(.*)'
|
||||
end
|
||||
|
||||
file=arg[1]
|
||||
filet=arg[1]
|
||||
|
||||
overall = {}
|
||||
|
||||
cntr = 1
|
||||
filein = io.open(file, "r")
|
||||
maxslot = -1
|
||||
repeat
|
||||
message = {}
|
||||
local line = filein:read("*line")
|
||||
if line == nil then
|
||||
break
|
||||
end
|
||||
if cntr < 2 then
|
||||
maxused = line
|
||||
line = filein:read("*line")
|
||||
maxslots = line
|
||||
cntr=2
|
||||
else
|
||||
message['slot'] = line
|
||||
message['phone'] = filein:read("*line")
|
||||
nline = filein:read("*line")
|
||||
message['nline'] = nline
|
||||
nline = tonumber(nline)
|
||||
nc = nline
|
||||
ncntr = 1
|
||||
msg=""
|
||||
message['msgnum'] = "xxx"
|
||||
message['msgord'] = "xxx"
|
||||
message['msgmax'] = "xxx"
|
||||
lines = filein:read("*line")
|
||||
if lines == nil then
|
||||
s = nil
|
||||
else
|
||||
s, msgnum, msgord, msgmax = lines:match("(Msg# (%d+),(%d+)/(%d+))")
|
||||
end
|
||||
if s == nil then
|
||||
nc = nc + 1
|
||||
else
|
||||
message['msgnum'] = msgnum
|
||||
message['msgord'] = msgord
|
||||
message['msgmax'] = msgmax
|
||||
lines = filein:read("*line")
|
||||
end
|
||||
msg = lines
|
||||
if nc > 2 then
|
||||
for i=1,nc-2,1
|
||||
do
|
||||
lines = filein:read("*line")
|
||||
if lines == "" then
|
||||
msg = msg .. "\n"
|
||||
else
|
||||
msg = msg .. "\n" .. lines
|
||||
end
|
||||
end
|
||||
--print(nln, msg)
|
||||
--msg = msg .. "\n"
|
||||
end
|
||||
message['msg'] = msg
|
||||
message['numlines'] = nc - 1
|
||||
sht = filein:read("*line")
|
||||
s, sht1, sht2 = sht:match("((.*)Msg# %d+,%d+/%d%s*(.*))")
|
||||
if s ~= nil then
|
||||
sht = sht1 .. sht2
|
||||
end
|
||||
message['short'] = sht
|
||||
overall[message['slot']] = message
|
||||
if maxslot < tonumber(message['slot']) then
|
||||
maxslot = tonumber(message['slot'])
|
||||
end
|
||||
end
|
||||
until 1==0
|
||||
filein:close()
|
||||
|
||||
fileout = io.open(filet, "w")
|
||||
fileout:write(maxused, "\n")
|
||||
fileout:write(maxslots, "\n")
|
||||
|
||||
for i=0,maxslot,1
|
||||
do
|
||||
msgbuild = {}
|
||||
shortmsg = {}
|
||||
if overall[tostring(i)] ~= nil then
|
||||
--print(i, overall[tostring(i)]['msgnum'])
|
||||
if overall[tostring(i)]['msgnum'] == "xxx" then
|
||||
fileout:write(overall[tostring(i)]['slot'], "\n")
|
||||
fileout:write(overall[tostring(i)]['phone'], "\n")
|
||||
fileout:write(overall[tostring(i)]['nline'], "\n")
|
||||
fileout:write(overall[tostring(i)]['msg'], "\n")
|
||||
fileout:write(overall[tostring(i)]['short'], "\n")
|
||||
else
|
||||
msgnum = overall[tostring(i)]['msgnum']
|
||||
msgtmp = overall[tostring(i)]['slot']
|
||||
msgord = overall[tostring(i)]['msgord']
|
||||
msgmax = tonumber(overall[tostring(i)]['msgmax'])
|
||||
msg = overall[tostring(i)]['msg']
|
||||
numlines = overall[tostring(i)]['numlines']
|
||||
--print(numlines)
|
||||
msgbuild[overall[tostring(i)]['msgord']] = overall[tostring(i)]['msg']
|
||||
shortmsg[overall[tostring(i)]['msgord']] = overall[tostring(i)]['short']
|
||||
for j=i+1,maxslot,1
|
||||
do
|
||||
if overall[tostring(j)] ~= nil then
|
||||
if overall[tostring(j)]['msgnum'] == msgnum then
|
||||
numlines = numlines + (overall[tostring(j)]['numlines'])
|
||||
--print(overall[tostring(j)]['numlines'])
|
||||
msgtmp = msgtmp .. " " .. overall[tostring(j)]['slot']
|
||||
msgbuild[overall[tostring(j)]['msgord']] = overall[tostring(j)]['msg']
|
||||
shortmsg[overall[tostring(j)]['msgord']] = overall[tostring(j)]['short']
|
||||
overall[tostring(j)] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
msg=""
|
||||
mflg = 0
|
||||
short = nil
|
||||
for j=1,msgmax,1
|
||||
do
|
||||
if msgbuild[tostring(j)] ~= nil then
|
||||
msg = msg .. msgbuild[tostring(j)]
|
||||
if short == nil then
|
||||
short = shortmsg[tostring(j)]
|
||||
end
|
||||
else
|
||||
mflg = 1
|
||||
end
|
||||
end
|
||||
fileout:write(msgtmp, "\n")
|
||||
fileout:write(overall[tostring(i)]['phone'], "\n")
|
||||
if mflg == 0 then
|
||||
s, preshort = short:match("((.* %d+%-%d+%-%d+ %d+:%d+:%d+%s+[+-]%d+h ))")
|
||||
if preshort ~= nil then
|
||||
stxt = ''
|
||||
j = 0
|
||||
k = 1
|
||||
ch = ''
|
||||
while j < 20 do
|
||||
ch = string.byte(msg:sub(k, k))
|
||||
if ch == nil then
|
||||
j = 20
|
||||
elseif ch == 10 or ch == 13 then
|
||||
stxt = stxt .. ' '
|
||||
k = k + 1
|
||||
elseif ch < 127 then
|
||||
stxt = stxt .. string.char(ch)
|
||||
k = k + 1
|
||||
elseif ch < 0xE0 then
|
||||
stxt = stxt .. msg:sub(k, k + 1)
|
||||
k = k + 2
|
||||
elseif ch < 0xF0 then
|
||||
stxt = stxt .. msg:sub(k, k + 2)
|
||||
k = k + 3
|
||||
else
|
||||
stxt = stxt .. msg:sub(k, k + 3)
|
||||
k = k + 4
|
||||
end
|
||||
j = j + 1
|
||||
end
|
||||
if preshort:sub(1, 1) == ' ' then
|
||||
jj = 49
|
||||
else
|
||||
jj = 51
|
||||
end
|
||||
short = (preshort .. ' '):sub(1, jj) .. stxt .. " ..."
|
||||
end
|
||||
else
|
||||
msg = "Partial Message : " .. msg
|
||||
t = short:gsub("%s+", " ")
|
||||
short = "Partial Message " .. t
|
||||
end
|
||||
endc = string.sub(msg, -2)
|
||||
if endc == "\n\n" then
|
||||
mlen = msg:len() - 2
|
||||
msg = string.sub(msg,1,mlen)
|
||||
end
|
||||
local _,n = msg:gsub("\n","")
|
||||
fileout:write(tostring(n+1), "\n")
|
||||
fileout:write(msg, "\n")
|
||||
fileout:write(short, "\n")
|
||||
end
|
||||
end
|
||||
end
|
||||
fileout:close()
|
@ -72,6 +72,11 @@ while true; do
|
||||
SX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD")
|
||||
USED=$(echo "$SX" | cut -d, -f1 | grep -o "[0-9]\{1,3\}")
|
||||
MESCc="$USED"
|
||||
if [ -n "$MESCc" -a "$MESCc" != "$MESC" ]; then
|
||||
MESC=$MESCc
|
||||
uci set modem.sms.slots=$MESC
|
||||
uci commit modem
|
||||
fi
|
||||
MAXED=$(echo "$SX" | cut -d, -f2 | grep -o "[0-9]\{1,3\}")
|
||||
fi
|
||||
if [ $SMSLOC == "SM" ]; then
|
||||
@ -79,11 +84,6 @@ while true; do
|
||||
SX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD")
|
||||
USED=$(echo "$SX" | cut -d, -f1 | grep -o "[0-9]\{1,3\}")
|
||||
MAXED=$(echo "$SX" | cut -d, -f2 | grep -o "[0-9]\{1,3\}")
|
||||
if [ -n "$MESCc" -a "$MESCc" != "$MESC" ]; then
|
||||
MESC=$MESCc
|
||||
uci set modem.sms.slots=$MESC
|
||||
uci commit modem
|
||||
fi
|
||||
if [ $USED == $MAXED -a $MEM3 == "SM" ]; then
|
||||
ATCMDD="AT+CPMS=\"SM\",\"SM\",\"ME\""
|
||||
OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD")
|
||||
@ -101,8 +101,12 @@ while true; do
|
||||
fi
|
||||
if [ $USED -eq $(uci get modem.modem$CURRMODEM.smsnum) ] && [ $HH -eq $(date +%H) ]; then
|
||||
if [ $MEM3 == "SM" -a $USED -lt $MAXED -a $MESC -gt 0 -a $(uci -q get modem.sms.menable) == 1 ]; then
|
||||
ATCMDD="AT+CPMS=\"ME\";+CMGR=$MESLOT;+CPMS=\"SM\""
|
||||
ATCMDD="AT+CPMS=\"ME\""
|
||||
OX=$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD")
|
||||
ATCMDD="AT+CMGR=$MESLOT"
|
||||
OX=$OX$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD")
|
||||
ATCMDD="AT+CPMS=\"SM\""
|
||||
OX=$OX$($ROOTER/gcom/gcom-locked "$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD")
|
||||
Rstat=$(echo "$OX" | grep -o "+CMGR:[^,]\+" | grep -o "[0-3]")
|
||||
PDU=$(echo "$OX" | grep -o "[0-9A-F]\{30,\}")
|
||||
PDUL=$(echo "$OX" | grep -o "+CMGR:.*" | grep -o ",[0-9]\{1,\}" | grep -o "[0-9]\{1,3\}")
|
||||
|
@ -507,6 +507,9 @@ function parseDeliver()
|
||||
if timezone:sub(-2, -1) == '.0' then
|
||||
timezone = timezone:sub(1, -3)
|
||||
end
|
||||
if #timezone == 2 then
|
||||
timezone = ' ' .. timezone
|
||||
end
|
||||
m_time = str_buf .. ' ' .. timezone .. 'h'
|
||||
m_pdu_ptr = m_pdu_ptr:sub(7)
|
||||
if octet2bin_check(m_pdu_ptr) < 0 then
|
||||
@ -855,6 +858,7 @@ else
|
||||
end
|
||||
tfile:close()
|
||||
end
|
||||
os.execute("/usr/lib/sms/merge.lua " .. tfname)
|
||||
os.execute("mv " .. tfname .. " /tmp/smstext" .. modemn)
|
||||
|
||||
if #delslots > 0 then
|
||||
|
@ -328,14 +328,22 @@ _proto_mbim_setup() {
|
||||
log "Failed to connect to network"
|
||||
return 1
|
||||
fi
|
||||
log "Save Connect Data"
|
||||
uci set modem.modem$CURRMODEM.mdevice=$device
|
||||
uci set modem.modem$CURRMODEM.mapn=$apn
|
||||
uci set modem.modem$CURRMODEM.mipt=$itp
|
||||
uci set modem.modem$CURRMODEM.mauth=$auth
|
||||
uci set modem.modem$CURRMODEM.musername=$username
|
||||
uci set modem.modem$CURRMODEM.mpassword=$password
|
||||
uci commit modem
|
||||
|
||||
tid=$((tid + 1))
|
||||
|
||||
log "Get IP config"
|
||||
CONFIG=$(umbim $DBG -n -t $tid -d $device config) || {
|
||||
log "config failed"
|
||||
return 1
|
||||
}
|
||||
log "IP config $CONFIG"
|
||||
|
||||
IP=$(echo -e "$CONFIG"|grep "ipv4address"|grep -E -o "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)")
|
||||
GATE=$(echo -e "$CONFIG"|grep "ipv4gateway"|grep -E -o "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)")
|
||||
@ -467,6 +475,10 @@ _proto_mbim_setup() {
|
||||
# SIGNAL=$(umbim $DBG -n -t $tid -d $device signal)
|
||||
# CSQ=$(echo "$SIGNAL" | awk '/rssi:/ {print $2}')
|
||||
|
||||
if [ -e $ROOTER/modem-led.sh ]; then
|
||||
$ROOTER/modem-led.sh $CURRMODEM 3
|
||||
fi
|
||||
|
||||
$ROOTER/log/logger "Modem #$CURRMODEM Connected"
|
||||
log "Modem $CURRMODEM Connected"
|
||||
|
||||
@ -540,7 +552,8 @@ _proto_mbim_setup() {
|
||||
$ROOTER/timezone.sh &
|
||||
fi
|
||||
fi
|
||||
CLB=$(uci -q get modem.modeminfo$CURRMODEM.lb)
|
||||
#CLB=$(uci -q get modem.modeminfo$CURRMODEM.lb)
|
||||
CLB=1
|
||||
if [ -e /etc/config/mwan3 ]; then
|
||||
INTER=$(uci get modem.modeminfo$CURRMODEM.inter)
|
||||
if [ -z $INTER ]; then
|
||||
@ -577,6 +590,8 @@ proto_mbim_setup() {
|
||||
CPORT=$(uci get modem.modem$CURRMODEM.commport)
|
||||
ATCMDD="AT+COPS=0"
|
||||
OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD")
|
||||
#log "Restart Modem"
|
||||
#/usr/lib/rooter/luci/restart.sh $CURRMODEM
|
||||
sleep 5
|
||||
}
|
||||
|
||||
|
@ -5,9 +5,9 @@ PKG_RELEASE:=$(AUTORELEASE)
|
||||
|
||||
PKG_SOURCE_PROTO:=git
|
||||
PKG_SOURCE_URL=$(PROJECT_GIT)/project/uqmi.git
|
||||
PKG_SOURCE_DATE:=2022-05-04
|
||||
PKG_SOURCE_VERSION:=56cb2d4056fef132ccf78dfb6f3074ae5d109992
|
||||
PKG_MIRROR_HASH:=cc832b5318805df8c8387a3650f250dee72d5f1dbda4e4866b5503e186b2210c
|
||||
PKG_SOURCE_DATE:=2021-11-06
|
||||
PKG_SOURCE_VERSION:=6f956265167945267d676c99f123a8c822f0a77b
|
||||
PKG_MIRROR_HASH:=1dbe14a28ec59b364dbde5dea9e10ed1c5c3eda274b6c7690c793a06643acf3e
|
||||
PKG_MAINTAINER:=Matti Laakso <malaakso@elisanet.fi>
|
||||
|
||||
PKG_LICENSE:=GPL-2.0
|
||||
@ -22,7 +22,7 @@ define Package/rqmi
|
||||
SECTION:=net
|
||||
CATEGORY:=ROOter
|
||||
SUBMENU:=Drivers
|
||||
DEPENDS:=+libubox +libblobmsg-json +kmod-usb-net +kmod-usb-net-qmi-wwan +wwan
|
||||
DEPENDS:=+libubox +libblobmsg-json +kmod-usb-net +kmod-usb-net-qmi-wwan +wwan +luci-proto-qmi
|
||||
TITLE:=Control utility for mobile broadband modems
|
||||
endef
|
||||
|
||||
@ -32,11 +32,7 @@ define Package/rqmi/description
|
||||
endef
|
||||
|
||||
TARGET_CFLAGS += \
|
||||
-I$(STAGING_DIR)/usr/include \
|
||||
-ffunction-sections \
|
||||
-fdata-sections \
|
||||
-Wno-error=dangling-pointer \
|
||||
-Wno-error=maybe-uninitialized
|
||||
-I$(STAGING_DIR)/usr/include -ffunction-sections -fdata-sections
|
||||
|
||||
TARGET_LDFLAGS += -Wl,--gc-sections
|
||||
|
||||
|
596
rooter/0drivers/rqmi/files/lib/netifd/proto/qmi.sh
Normal file
596
rooter/0drivers/rqmi/files/lib/netifd/proto/qmi.sh
Normal file
@ -0,0 +1,596 @@
|
||||
#!/bin/sh
|
||||
|
||||
[ -n "$INCLUDE_ONLY" ] || {
|
||||
. /lib/functions.sh
|
||||
. ../netifd-proto.sh
|
||||
init_proto "$@"
|
||||
}
|
||||
|
||||
ROOTER=/usr/lib/rooter
|
||||
ROOTER_LINK="/tmp/links"
|
||||
|
||||
log() {
|
||||
modlog "QMI Connect $CURRMODEM" "$@"
|
||||
}
|
||||
|
||||
log "Starting QMI"
|
||||
|
||||
proto_qmi_init_config() {
|
||||
available=1
|
||||
no_device=1
|
||||
proto_config_add_string "device:device"
|
||||
proto_config_add_string apn
|
||||
proto_config_add_string auth
|
||||
proto_config_add_string username
|
||||
proto_config_add_string password
|
||||
proto_config_add_string pincode
|
||||
proto_config_add_int delay
|
||||
proto_config_add_string modes
|
||||
proto_config_add_string pdptype
|
||||
proto_config_add_int profile
|
||||
proto_config_add_boolean dhcp
|
||||
proto_config_add_boolean dhcpv6
|
||||
proto_config_add_boolean autoconnect
|
||||
proto_config_add_int plmn
|
||||
proto_config_add_int timeout
|
||||
proto_config_add_int mtu
|
||||
proto_config_add_defaults
|
||||
}
|
||||
|
||||
proto_qmi_setup() {
|
||||
local interface="$1"
|
||||
local dataformat connstat plmn_mode mcc mnc
|
||||
local device apn auth username password pincode delay modes pdptype
|
||||
local profile dhcp dhcpv6 autoconnect plmn timeout mtu $PROTO_DEFAULT_OPTIONS
|
||||
local ip4table ip6table
|
||||
local cid_4 pdh_4 cid_6 pdh_6
|
||||
local ip_6 ip_prefix_length gateway_6 dns1_6 dns2_6
|
||||
|
||||
if [ ! -f /tmp/bootend.file ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
CURRMODEM=$(uci -q get network.$interface.currmodem)
|
||||
uci set modem.modem$CURRMODEM.connected=0
|
||||
uci commit modem
|
||||
rm -f $ROOTER_LINK/reconnect$CURRMODEM
|
||||
jkillall getsignal$CURRMODEM
|
||||
rm -f $ROOTER_LINK/getsignal$CURRMODEM
|
||||
jkillall con_monitor$CURRMODEM
|
||||
rm -f $ROOTER_LINK/con_monitor$CURRMODEM
|
||||
jkillall mbim_monitor$CURRMODEM
|
||||
rm -f $ROOTER_LINK/mbim_monitor$CURRMODEM
|
||||
|
||||
json_get_vars device apn auth username password pincode delay modes
|
||||
json_get_vars pdptype profile dhcp dhcpv6 autoconnect plmn ip4table
|
||||
json_get_vars ip6table timeout mtu $PROTO_DEFAULT_OPTIONS
|
||||
|
||||
case $auth in
|
||||
"0" )
|
||||
auth=
|
||||
;;
|
||||
"1" )
|
||||
auth="pap"
|
||||
;;
|
||||
"2" )
|
||||
auth="chap"
|
||||
;;
|
||||
"*" )
|
||||
auth=
|
||||
;;
|
||||
esac
|
||||
|
||||
[ "$timeout" = "" ] && timeout="10"
|
||||
|
||||
[ "$metric" = "" ] && metric="0"
|
||||
|
||||
[ -n "$ctl_device" ] && device=$ctl_device
|
||||
|
||||
[ -n "$device" ] || {
|
||||
log "No control device specified"
|
||||
proto_notify_error "$interface" NO_DEVICE
|
||||
proto_set_available "$interface" 0
|
||||
return 1
|
||||
}
|
||||
|
||||
[ -n "$delay" ] && sleep "$delay"
|
||||
|
||||
device="$(readlink -f $device)"
|
||||
[ -c "$device" ] || {
|
||||
log "The specified control device does not exist"
|
||||
proto_notify_error "$interface" NO_DEVICE
|
||||
proto_set_available "$interface" 0
|
||||
return 1
|
||||
}
|
||||
|
||||
devname="$(basename "$device")"
|
||||
devpath="$(readlink -f /sys/class/usbmisc/$devname/device/)"
|
||||
ifname="$( ls "$devpath"/net )"
|
||||
[ -n "$ifname" ] || {
|
||||
log "The interface could not be found."
|
||||
proto_notify_error "$interface" NO_IFACE
|
||||
proto_set_available "$interface" 0
|
||||
return 1
|
||||
}
|
||||
|
||||
[ -n "$mtu" ] && {
|
||||
log "Setting MTU to $mtu"
|
||||
/sbin/ip link set dev $ifname mtu $mtu
|
||||
}
|
||||
|
||||
timeout=1
|
||||
|
||||
# Cleanup current state if any
|
||||
uqmi -s -d "$device" --stop-network 0xffffffff --autoconnect > /dev/null 2>&1
|
||||
|
||||
# Go online
|
||||
uqmi -s -d "$device" --set-device-operating-mode online > /dev/null 2>&1
|
||||
|
||||
# Set IP format
|
||||
uqmi -s -d "$device" --set-data-format 802.3 > /dev/null 2>&1
|
||||
uqmi -s -d "$device" --wda-set-data-format 802.3 > /dev/null 2>&1
|
||||
if [ $RAW -eq 1 ]; then
|
||||
dataformat='"raw-ip"'
|
||||
else
|
||||
if [ $idV = 1199 -a $idP = 9055 ]; then
|
||||
$ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "reset.gcom" "$CURRMODEM"
|
||||
dataformat='"802.3"'
|
||||
uqmi -s -d "$device" --set-data-format 802.3
|
||||
uqmi -s -d "$device" --wda-set-data-format 802.3
|
||||
else
|
||||
dataformat=$(uqmi -s -d "$device" --wda-get-data-format)
|
||||
fi
|
||||
fi
|
||||
log "WDA-GET-DATA-FORMAT is $dataformat"
|
||||
|
||||
if [ "$dataformat" = '"raw-ip"' ]; then
|
||||
|
||||
[ -f /sys/class/net/$ifname/qmi/raw_ip ] || {
|
||||
log "Device only supports raw-ip mode but is missing this required driver attribute: /sys/class/net/$ifname/qmi/raw_ip"
|
||||
return 1
|
||||
}
|
||||
|
||||
log "Device does not support 802.3 mode. Informing driver of raw-ip only for $ifname .."
|
||||
echo "Y" > /sys/class/net/$ifname/qmi/raw_ip
|
||||
fi
|
||||
|
||||
uqmi -s -d "$device" --sync > /dev/null 2>&1
|
||||
|
||||
uqmi -s -d "$device" --network-register > /dev/null 2>&1
|
||||
|
||||
log "Waiting for network registration"
|
||||
sleep 1
|
||||
local registration_timeout=0
|
||||
local registration_state=""
|
||||
while true; do
|
||||
registration_state=$(uqmi -s -d "$device" --get-serving-system 2>/dev/null | jsonfilter -e "@.registration" 2>/dev/null)
|
||||
log "Registration State : $registration_state"
|
||||
[ "$registration_state" = "registered" ] && break
|
||||
|
||||
if [ "$registration_state" = "searching" ] || [ "$registration_state" = "not_registered" ]; then
|
||||
if [ "$registration_timeout" -lt "$timeout" ] || [ "$timeout" = "0" ]; then
|
||||
[ "$registration_state" = "searching" ] || {
|
||||
log "Device stopped network registration. Restart network registration"
|
||||
uqmi -s -d "$device" --network-register > /dev/null 2>&1
|
||||
}
|
||||
let registration_timeout++
|
||||
sleep 1
|
||||
continue
|
||||
fi
|
||||
log "Network registration failed, registration timeout reached"
|
||||
else
|
||||
# registration_state is 'registration_denied' or 'unknown' or ''
|
||||
log "Network registration failed (reason: '$registration_state')"
|
||||
fi
|
||||
|
||||
proto_notify_error "$interface" NETWORK_REGISTRATION_FAILED
|
||||
proto_block_restart "$interface"
|
||||
return 1
|
||||
done
|
||||
|
||||
[ -n "$modes" ] && uqmi -s -d "$device" --set-network-modes "$modes" > /dev/null 2>&1
|
||||
|
||||
pdptype="ipv4v6"
|
||||
IPVAR=$(uci -q get modem.modem$CURRMODEM.pdptype)
|
||||
case "$IPVAR" in
|
||||
"IP" )
|
||||
pdptype="ipv4"
|
||||
;;
|
||||
"IPV6" )
|
||||
pdptype="ipv6"
|
||||
;;
|
||||
"IPV4V6" )
|
||||
pdptype="ipv4v6"
|
||||
;;
|
||||
esac
|
||||
|
||||
pdptype=$(echo "$pdptype" | awk '{print tolower($0)}')
|
||||
[ "$pdptype" = "ip" -o "$pdptype" = "ipv6" -o "$pdptype" = "ipv4v6" ] || pdptype="ip"
|
||||
if [ "$pdptype" = "ip" ]; then
|
||||
[ -z "$autoconnect" ] && autoconnect=1
|
||||
[ "$autoconnect" = 0 ] && autoconnect=""
|
||||
else
|
||||
[ "$autoconnect" = 1 ] || autoconnect=""
|
||||
fi
|
||||
|
||||
isplist=$(uci -q get modem.modeminfo$CURRMODEM.isplist)
|
||||
apn2=$(uci -q get modem.modeminfo$CURRMODEM.apn2)
|
||||
for isp in $isplist
|
||||
do
|
||||
NAPN=$(echo $isp | cut -d, -f2)
|
||||
NPASS=$(echo $isp | cut -d, -f4)
|
||||
CID=$(echo $isp | cut -d, -f5)
|
||||
NUSER=$(echo $isp | cut -d, -f6)
|
||||
NAUTH=$(echo $isp | cut -d, -f7)
|
||||
if [ "$NPASS" = "nil" ]; then
|
||||
NPASS="NIL"
|
||||
fi
|
||||
if [ "$NUSER" = "nil" ]; then
|
||||
NUSER="NIL"
|
||||
fi
|
||||
if [ "$NAUTH" = "nil" ]; then
|
||||
NAUTH="0"
|
||||
fi
|
||||
apn=$NAPN
|
||||
username="$NUSER"
|
||||
password="$NPASS"
|
||||
auth=$NAUTH
|
||||
case $auth in
|
||||
"0" )
|
||||
auth="none"
|
||||
;;
|
||||
"1" )
|
||||
auth="pap"
|
||||
;;
|
||||
"2" )
|
||||
auth="chap"
|
||||
;;
|
||||
"*" )
|
||||
auth="none"
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
if [ ! -e /etc/config/isp ]; then
|
||||
log "Connect to network using $NAPN"
|
||||
else
|
||||
log "Connect to network"
|
||||
fi
|
||||
|
||||
if [ ! -e /etc/config/isp ]; then
|
||||
log "Connection Parameters : $NAPN $auth $username $password"
|
||||
fi
|
||||
conn=0
|
||||
|
||||
[ "$pdptype" = "ip" -o "$pdptype" = "ipv4v6" ] && {
|
||||
cid_4=$(uqmi -s -d "$device" --get-client-id wds)
|
||||
if ! [ "$cid_4" -eq "$cid_4" ] 2> /dev/null; then
|
||||
log "Unable to obtain client ID"
|
||||
fi
|
||||
}
|
||||
uqmi -s -d "$device" --set-client-id wds,"$cid_4" --set-ip-family ipv4 > /dev/null 2>&1
|
||||
v4s=0
|
||||
pdh_4=$(uqmi -s -d "$device" --set-client-id wds,"$cid_4" \
|
||||
--start-network \
|
||||
${apn:+--apn $apn} \
|
||||
${auth:+--auth-type $auth} \
|
||||
${username:+--username $username} \
|
||||
${password:+--password $password} \
|
||||
${autoconnect:+--autoconnect})
|
||||
log "IPv4 Connection returned : $pdh_4"
|
||||
CONN4=$(uqmi -s -d "$device" --set-client-id wds,"$cid_4" --get-current-settings)
|
||||
log "GET-CURRENT-SETTINGS is $CONN4"
|
||||
# pdh_4 is a numeric value on success
|
||||
if ! [ "$pdh_4" -eq "$pdh_4" ] 2> /dev/null; then
|
||||
log "Unable to connect IPv4"
|
||||
v4s=0
|
||||
else
|
||||
# Check data connection state
|
||||
v4s=1
|
||||
conn=1
|
||||
fi
|
||||
|
||||
[ "$pdptype" = "ipv6" -o "$pdptype" = "ipv4v6" ] && {
|
||||
cid_6=$(uqmi -s -d "$device" --get-client-id wds)
|
||||
if ! [ "$cid_6" -eq "$cid_6" ] 2> /dev/null; then
|
||||
log "Unable to obtain client ID"
|
||||
#proto_notify_error "$interface" NO_CID
|
||||
fi
|
||||
}
|
||||
|
||||
uqmi -s -d "$device" --set-client-id wds,"$cid_6" --set-ip-family ipv6 > /dev/null 2>&1
|
||||
v6s=0
|
||||
pdh_6=$(uqmi -s -d "$device" --set-client-id wds,"$cid_6" \
|
||||
--start-network \
|
||||
${apn:+--apn $apn} \
|
||||
${auth:+--auth-type $auth} \
|
||||
${username:+--username $username} \
|
||||
${password:+--password $password} \
|
||||
${autoconnect:+--autoconnect})
|
||||
log "IPv6 Connection returned : $pdh_6"
|
||||
|
||||
# pdh_6 is a numeric value on success
|
||||
if ! [ "$pdh_6" -eq "$pdh_6" ] 2> /dev/null; then
|
||||
log "Unable to connect IPv6"
|
||||
v6s=0
|
||||
else
|
||||
# Check data connection state
|
||||
CONN6=$(uqmi -s -d "$device" --set-client-id wds,"$cid_6" --get-current-settings)
|
||||
log "GET-CURRENT-SETTINGS is $CONN6"
|
||||
v6s=1
|
||||
conn=1
|
||||
fi
|
||||
if [ $conn -eq 1 ]; then
|
||||
break;
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $conn -eq 0 ]; then
|
||||
proto_notify_error "$interface" CALL_FAILED
|
||||
return 1
|
||||
else
|
||||
log "Setting up $ifname"
|
||||
proto_init_update "$ifname" 1
|
||||
proto_set_keep 1
|
||||
proto_add_data
|
||||
[ -n "$pdh_4" ] && {
|
||||
json_add_string "cid_4" "$cid_4"
|
||||
json_add_string "pdh_4" "$pdh_4"
|
||||
}
|
||||
[ -n "$pdh_6" ] && {
|
||||
json_add_string "cid_6" "$cid_6"
|
||||
json_add_string "pdh_6" "$pdh_6"
|
||||
}
|
||||
proto_close_data
|
||||
proto_send_update "$interface"
|
||||
|
||||
zone="$(fw3 -q network "$interface" 2>/dev/null)"
|
||||
dhcp=0
|
||||
dhcpv6=0
|
||||
|
||||
[ "$v6s" -eq 1 ] && {
|
||||
if [ -z "$dhcpv6" -o "$dhcpv6" = 0 ]; then
|
||||
json_load "$(uqmi -s -d $device --set-client-id wds,$cid_6 --get-current-settings)"
|
||||
json_select ipv6
|
||||
json_get_var ip_6 ip
|
||||
json_get_var gateway_6 gateway
|
||||
json_get_var dns1_6 dns1
|
||||
json_get_var dns2_6 dns2
|
||||
json_get_var ip_prefix_length ip-prefix-length
|
||||
|
||||
proto_init_update "$ifname" 1
|
||||
proto_set_keep 1
|
||||
proto_add_ipv6_address "$ip_6" "128"
|
||||
proto_add_ipv6_prefix "${ip_6}/${ip_prefix_length}"
|
||||
proto_add_ipv6_route "$gateway_6" "128"
|
||||
[ "$defaultroute" = 0 ] || proto_add_ipv6_route "::0" 0 "$gateway_6" "" "" "${ip_6}/${ip_prefix_length}"
|
||||
[ "$peerdns" = 0 ] || {
|
||||
proto_add_dns_server "$dns1_6"
|
||||
proto_add_dns_server "$dns2_6"
|
||||
}
|
||||
[ -n "$zone" ] && {
|
||||
proto_add_data
|
||||
json_add_string zone "$zone"
|
||||
proto_close_data
|
||||
}
|
||||
proto_send_update "$interface"
|
||||
v6dns="$dns1_6 $dns2_6"
|
||||
log "IPv6 address : $ip_6"
|
||||
log "IPv6 DNS : $v6dns"
|
||||
else
|
||||
json_init
|
||||
json_add_string name "${interface}_6"
|
||||
json_add_string ifname "@$interface"
|
||||
json_add_string proto "dhcpv6"
|
||||
[ -n "$ip6table" ] && json_add_string ip6table "$ip6table"
|
||||
proto_add_dynamic_defaults
|
||||
# RFC 7278: Extend an IPv6 /64 Prefix to LAN
|
||||
json_add_string extendprefix 1
|
||||
[ -n "$zone" ] && json_add_string zone "$zone"
|
||||
json_close_object
|
||||
ubus call network add_dynamic "$(json_dump)"
|
||||
fi
|
||||
}
|
||||
|
||||
[ "$v4s" -eq 1 ] && {
|
||||
if [ "$dhcp" = 0 ]; then
|
||||
json_load "$(uqmi -s -d $device --set-client-id wds,$cid_4 --get-current-settings)"
|
||||
json_select ipv4
|
||||
json_get_var ip_4 ip
|
||||
json_get_var gateway_4 gateway
|
||||
json_get_var dns1_4 dns1
|
||||
json_get_var dns2_4 dns2
|
||||
json_get_var subnet_4 subnet
|
||||
|
||||
proto_init_update "$ifname" 1
|
||||
proto_set_keep 1
|
||||
proto_add_ipv4_address "$ip_4" "$subnet_4"
|
||||
proto_add_ipv4_route "$gateway_4" "128"
|
||||
[ "$defaultroute" = 0 ] || proto_add_ipv4_route "0.0.0.0" 0 "$gateway_4"
|
||||
[ "$peerdns" = 0 ] || {
|
||||
proto_add_dns_server "$dns1_4"
|
||||
proto_add_dns_server "$dns2_4"
|
||||
}
|
||||
[ -n "$zone" ] && {
|
||||
proto_add_data
|
||||
json_add_string zone "$zone"
|
||||
proto_close_data
|
||||
}
|
||||
proto_send_update "$interface"
|
||||
log "IPv4 address : $ip_4"
|
||||
log "IPv4 DNS : $dns1_4 $dns2_4"
|
||||
else
|
||||
json_init
|
||||
json_add_string name "${interface}_4"
|
||||
json_add_string ifname "@$interface"
|
||||
json_add_string proto "dhcp"
|
||||
[ -n "$ip4table" ] && json_add_string ip4table "$ip4table"
|
||||
proto_add_dynamic_defaults
|
||||
[ -n "$zone" ] && json_add_string zone "$zone"
|
||||
json_close_object
|
||||
ubus call network add_dynamic "$(json_dump)"
|
||||
fi
|
||||
}
|
||||
|
||||
if [ -n "$ip_6" -a -z "$ip_4" ]; then
|
||||
log "Running IPv6-only mode"
|
||||
nat46=1
|
||||
fi
|
||||
if [[ $(echo "$ip_6" | grep -o "^[23]") ]]; then
|
||||
# Global unicast IP acquired
|
||||
v6cap=1
|
||||
elif
|
||||
[[ $(echo "$ip_6" | grep -o "^[0-9a-fA-F]\{1,4\}:") ]]; then
|
||||
# non-routable address
|
||||
v6cap=2
|
||||
else
|
||||
v6cap=0
|
||||
fi
|
||||
if [ $v4s -eq 0 -a $v6s -eq 1 ]; then
|
||||
INTER=$(uci get modem.modem$CURRMODEM.inter)
|
||||
if [ "$v6cap" -gt 0 ]; then
|
||||
zone="$(fw3 -q network "$interface" 2>/dev/null)"
|
||||
fi
|
||||
if [ "$v6cap" = 2 ]; then
|
||||
log "Adding IPv6 dynamic interface"
|
||||
json_init
|
||||
json_add_string name "${interface}_6"
|
||||
json_add_string ${ifname1} "@$interface"
|
||||
json_add_string proto "dhcpv6"
|
||||
json_add_string extendprefix 1
|
||||
[ -n "$zone" ] && json_add_string zone "$zone"
|
||||
[ "$nat46" = 1 ] || json_add_string iface_464xlat 0
|
||||
json_add_boolean peerdns 0
|
||||
json_add_array dns
|
||||
for DNSV in $(echo "$v6dns"); do
|
||||
json_add_string "" "$DNSV"
|
||||
done
|
||||
json_close_array
|
||||
proto_add_dynamic_defaults
|
||||
json_close_object
|
||||
ubus call network add_dynamic "$(json_dump)"
|
||||
elif
|
||||
[ "$v6cap" = 1 -a "$nat46" = 1 ]; then
|
||||
log "Adding 464XLAT (CLAT) dynamic interface"
|
||||
json_init
|
||||
json_add_string name "CLAT$INTER"
|
||||
json_add_string proto "464xlat"
|
||||
json_add_string tunlink "${interface}"
|
||||
[ -n "$zone" ] && json_add_string zone "$zone"
|
||||
proto_add_dynamic_defaults
|
||||
json_close_object
|
||||
ubus call network add_dynamic "$(json_dump)"
|
||||
fi
|
||||
fi
|
||||
if [ -e $ROOTER/modem-led.sh ]; then
|
||||
$ROOTER/modem-led.sh $CURRMODEM 3
|
||||
fi
|
||||
|
||||
log "Modem $CURRMODEM Connected"
|
||||
COMMPORT=$(uci get modem.modem$CURRMODEM.commport)
|
||||
if [ ! -z $COMMPORT ]; then
|
||||
$ROOTER/sms/check_sms.sh $CURRMODEM &
|
||||
ln -s $ROOTER/signal/modemsignal.sh $ROOTER_LINK/getsignal$CURRMODEM
|
||||
# send custom AT startup command
|
||||
if [ $(uci -q get modem.modeminfo$CURRMODEM.at) -eq "1" ]; then
|
||||
ATCMDD=$(uci -q get modem.modeminfo$CURRMODEM.atc)
|
||||
if [ ! -z "${ATCMDD}" ]; then
|
||||
OX=$($ROOTER/gcom/gcom-locked "/dev/ttyUSB$COMMPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD")
|
||||
OX=$($ROOTER/common/processat.sh "$OX")
|
||||
ERROR="ERROR"
|
||||
if `echo ${OX} | grep "${ERROR}" 1>/dev/null 2>&1`
|
||||
then
|
||||
log "Error sending custom AT command: $ATCMDD with result: $OX"
|
||||
else
|
||||
log "Sent custom AT command: $ATCMDD with result: $OX"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
ln -s $ROOTER/connect/reconnect.sh $ROOTER_LINK/reconnect$CURRMODEM
|
||||
$ROOTER_LINK/getsignal$CURRMODEM $CURRMODEM $PROT &
|
||||
ln -s $ROOTER/connect/conmon.sh $ROOTER_LINK/con_monitor$CURRMODEM
|
||||
$ROOTER_LINK/con_monitor$CURRMODEM $CURRMODEM &
|
||||
uci set modem.modem$CURRMODEM.connected=1
|
||||
uci commit modem
|
||||
|
||||
if [ -e $ROOTER/connect/postconnect.sh ]; then
|
||||
$ROOTER/connect/postconnect.sh $CURRMODEM
|
||||
fi
|
||||
|
||||
if [ -e $ROOTER/timezone.sh ]; then
|
||||
TZ=$(uci -q get modem.modeminfo$CURRMODEM.tzone)
|
||||
if [ "$TZ" = "1" ]; then
|
||||
$ROOTER/timezone.sh &
|
||||
fi
|
||||
fi
|
||||
CLB=1
|
||||
if [ -e /etc/config/mwan3 ]; then
|
||||
INTER=$(uci get modem.modeminfo$CURRMODEM.inter)
|
||||
if [ -z $INTER ]; then
|
||||
INTER=0
|
||||
else
|
||||
if [ $INTER = 0 ]; then
|
||||
INTER=$CURRMODEM
|
||||
fi
|
||||
fi
|
||||
ENB=$(uci -q get mwan3.wan$CURRMODEM.enabled)
|
||||
if [ ! -z $ENB ]; then
|
||||
if [ $CLB = "1" ]; then
|
||||
uci set mwan3.wan$INTER.enabled=1
|
||||
else
|
||||
uci set mwan3.wan$INTER.enabled=0
|
||||
fi
|
||||
uci commit mwan3
|
||||
/usr/sbin/mwan3 restart
|
||||
fi
|
||||
fi
|
||||
rm -f /tmp/usbwait
|
||||
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
qmi_wds_stop() {
|
||||
local cid="$1"
|
||||
local pdh="$2"
|
||||
|
||||
[ -n "$cid" ] || return
|
||||
|
||||
uqmi -s -d "$device" --set-client-id wds,"$cid" \
|
||||
--stop-network 0xffffffff \
|
||||
--autoconnect > /dev/null 2>&1
|
||||
|
||||
[ -n "$pdh" ] && {
|
||||
uqmi -s -d "$device" --set-client-id wds,"$cid" \
|
||||
--stop-network "$pdh" > /dev/null 2>&1
|
||||
}
|
||||
|
||||
uqmi -s -d "$device" --set-client-id wds,"$cid" \
|
||||
--release-client-id wds > /dev/null 2>&1
|
||||
}
|
||||
|
||||
proto_qmi_teardown() {
|
||||
local interface="$1"
|
||||
|
||||
local device cid_4 pdh_4 cid_6 pdh_6
|
||||
json_get_vars device
|
||||
|
||||
[ -n "$ctl_device" ] && device=$ctl_device
|
||||
|
||||
log "Stopping network $interface"
|
||||
|
||||
json_load "$(ubus call network.interface.$interface status)"
|
||||
json_select data
|
||||
json_get_vars cid_4 pdh_4 cid_6 pdh_6
|
||||
|
||||
qmi_wds_stop "$cid_4" "$pdh_4"
|
||||
qmi_wds_stop "$cid_6" "$pdh_6"
|
||||
|
||||
proto_init_update "*" 0
|
||||
proto_send_update "$interface"
|
||||
}
|
||||
|
||||
[ -n "$INCLUDE_ONLY" ] || {
|
||||
add_protocol qmi
|
||||
}
|
@ -1,293 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
ROOTER=/usr/lib/rooter
|
||||
|
||||
log() {
|
||||
modlog "QMI Connect $CURRMODEM" "$@"
|
||||
}
|
||||
|
||||
. /lib/functions.sh
|
||||
. /lib/netifd/netifd-proto.sh
|
||||
|
||||
CURRMODEM=$1
|
||||
devname=$2
|
||||
device=/dev/$2
|
||||
auth=$3
|
||||
NAPN=$4
|
||||
username=$5
|
||||
password=$6
|
||||
RAW=$7
|
||||
DHCP=$8
|
||||
pincode=$9
|
||||
|
||||
enb=$(uci -q get custom.connect.ipv6)
|
||||
if [ -z $enb ]; then
|
||||
enb="1"
|
||||
fi
|
||||
|
||||
ifname1="ifname"
|
||||
if [ -e /etc/newstyle ]; then
|
||||
ifname1="device"
|
||||
fi
|
||||
|
||||
INTER=$(uci -q get modem.modem$CURRMODEM.inter)
|
||||
interface="wan"$INTER
|
||||
|
||||
case $auth in
|
||||
"0" )
|
||||
auth="none"
|
||||
;;
|
||||
"1" )
|
||||
auth="pap"
|
||||
;;
|
||||
"2" )
|
||||
auth="chap"
|
||||
;;
|
||||
*)
|
||||
auth="none"
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ $username = NIL ]; then
|
||||
username=
|
||||
fi
|
||||
if [ $password = NIL ]; then
|
||||
password=
|
||||
fi
|
||||
|
||||
ifname="$(ls /sys/class/usbmisc/$devname/device/net/)"
|
||||
|
||||
#while uqmi -s -d "$device" --get-pin-status | grep '"UIM uninitialized"' > /dev/null; do
|
||||
# sleep 1;
|
||||
#done
|
||||
|
||||
[ -n "$pincode" ] && {
|
||||
uqmi -s -d "$device" --verify-pin1 "$pincode" || {
|
||||
log "Unable to verify PIN"
|
||||
ret=1
|
||||
}
|
||||
}
|
||||
|
||||
uqmi -s -d "$device" --stop-network 0xffffffff --autoconnect > /dev/null & sleep 5 ; kill -9 $!
|
||||
uqmi -s -d "$device" --set-device-operating-mode online > /dev/null 2>&1 & sleep 5 ; kill -9 $!
|
||||
|
||||
if [ $RAW -eq 1 ]; then
|
||||
DATAFORM='"raw-ip"'
|
||||
else
|
||||
if [ $idV = 1199 -a $idP = 9055 ]; then
|
||||
$ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "reset.gcom" "$CURRMODEM"
|
||||
DATAFORM='"802.3"'
|
||||
uqmi -s -d "$device" --set-data-format 802.3
|
||||
uqmi -s -d "$device" --wda-set-data-format 802.3
|
||||
else
|
||||
log "getting data format"
|
||||
DATAFORM=$(uqmi -s -d "$device" --wda-get-data-format)
|
||||
fi
|
||||
fi
|
||||
|
||||
log "WDA-GET-DATA-FORMAT is $DATAFORM"
|
||||
if [ "$DATAFORM" = '"raw-ip"' ]; then
|
||||
[ -f /sys/class/net/$ifname/qmi/raw_ip ] || {
|
||||
log "Device only supports raw-ip mode but is missing this required driver attribute: /sys/class/net/$ifname/qmi/raw_ip"
|
||||
ret=1
|
||||
}
|
||||
echo "Y" > /sys/class/net/$ifname/qmi/raw_ip
|
||||
fi
|
||||
|
||||
log "Query radio state"
|
||||
uqmi -s -d "$device" --get-signal-info | grep -q "Information unavailable" & sleep 5 ; kill -9 $!
|
||||
STATUS=$?
|
||||
|
||||
[ "$STATUS" -ne 0 ] || {
|
||||
sleep 1
|
||||
log "Setting FCC Auth"
|
||||
uqmi -s -d "$device" --fcc-auth & sleep 5 ; kill -9 $!
|
||||
sleep 1
|
||||
}
|
||||
|
||||
uqmi -s -d "$device" --sync > /dev/null 2>&1 & sleep 5 ; kill -9 $!
|
||||
|
||||
#uqmi -s -d "$device" --network-register > /dev/null 2>&1
|
||||
|
||||
log "Waiting for network registration"
|
||||
td=0
|
||||
while uqmi -s -d "$device" --get-serving-system | grep '"searching"' > /dev/null; do
|
||||
sleep 5;
|
||||
tid=$((tid + 1))
|
||||
if [ $tid -gt 2 ]; then
|
||||
uqmi -s -d "$device" --stop-network 0xffffffff --autoconnect > /dev/null & sleep 10 ; kill -9 $!
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
cid=`uqmi -s -d "$device" --get-client-id wds`
|
||||
[ $? -ne 0 ] && {
|
||||
log "Unable to obtain client ID"
|
||||
ret=1
|
||||
}
|
||||
|
||||
uqmi -s -d "$device" --set-client-id wds,"$cid" --set-ip-family ipv4 > /dev/null
|
||||
|
||||
isplist=$(uci -q get modem.modeminfo$CURRMODEM.isplist)
|
||||
apn2=$(uci -q get modem.modeminfo$CURRMODEM.apn2)
|
||||
for isp in $isplist
|
||||
do
|
||||
NAPN=$(echo $isp | cut -d, -f2)
|
||||
NPASS=$(echo $isp | cut -d, -f4)
|
||||
CID=$(echo $isp | cut -d, -f5)
|
||||
NUSER=$(echo $isp | cut -d, -f6)
|
||||
NAUTH=$(echo $isp | cut -d, -f7)
|
||||
if [ "$NPASS" = "nil" ]; then
|
||||
NPASS="NIL"
|
||||
fi
|
||||
if [ "$NUSER" = "nil" ]; then
|
||||
NUSER="NIL"
|
||||
fi
|
||||
if [ "$NAUTH" = "nil" ]; then
|
||||
NAUTH="0"
|
||||
fi
|
||||
username="$NUSER"
|
||||
password="$NPASS"
|
||||
auth=$NAUTH
|
||||
case $auth in
|
||||
"0" )
|
||||
auth="none"
|
||||
;;
|
||||
"1" )
|
||||
auth="pap"
|
||||
;;
|
||||
"2" )
|
||||
auth="chap"
|
||||
;;
|
||||
"*" )
|
||||
auth="none"
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ ! -e /etc/config/isp ]; then
|
||||
log "Connect to network using $NAPN"
|
||||
else
|
||||
log "Connect to network"
|
||||
fi
|
||||
|
||||
if [ ! -e /etc/config/isp ]; then
|
||||
log "$NAPN $auth $username $password"
|
||||
fi
|
||||
|
||||
conn=0
|
||||
tidd=0
|
||||
tcnt=4
|
||||
while true; do
|
||||
ST=$(uqmi -s -d "$device" --set-client-id wds,"$cid" --start-network ${NAPN:+--apn $NAPN} ${auth:+--auth-type $auth} \
|
||||
${username:+--username $username} ${password:+--password $password})
|
||||
log "Connection returned : $ST"
|
||||
CONN=$(uqmi -s -d "$device" --get-data-status)
|
||||
log "Status is $CONN"
|
||||
if [[ $(echo "$CONN" | grep -o "disconnected") ]]; then
|
||||
sleep 1
|
||||
tidd=$((tidd + 1))
|
||||
if [ $tidd -gt $tcnt ]; then
|
||||
break
|
||||
fi
|
||||
else
|
||||
conn=1
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ $conn -eq 1 ]; then
|
||||
break;
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ -z $(echo "$CONN" | grep -o "disconnected") ]]; then
|
||||
ret=0
|
||||
|
||||
CONN4=$(uqmi -s -d "$device" --set-client-id wds,"$cid" --get-current-settings)
|
||||
log "GET-CURRENT-SETTINGS is $CONN4"
|
||||
|
||||
if [ $enb = "1" ]; then
|
||||
cid6=`uqmi -s -d "$device" --get-client-id wds`
|
||||
[ $? -ne 0 ] && {
|
||||
log "Unable to obtain client ID"
|
||||
ret=1
|
||||
}
|
||||
|
||||
uqmi -s -d "$device" --set-client-id wds,"$cid6" --set-ip-family ipv6 > /dev/null
|
||||
ST6=$(uqmi -s -d "$device" --set-client-id wds,"$cid6" --start-network ${NAPN:+--apn $NAPN} ${auth:+--auth-type $auth} \
|
||||
${username:+--username $username} ${password:+--password $password})
|
||||
log "IPv6 Connection returned : $ST6"
|
||||
CONN6=$(uqmi -s -d "$device" --set-client-id wds,"$cid6" --get-current-settings)
|
||||
CONF6=$(jsonfilter -s $CONN6 -e '@.ipv6')
|
||||
if [ -n "$CONF6" ];then
|
||||
log "IPv6 settings are $CONF6"
|
||||
touch /tmp/ipv6supp$INTER
|
||||
else
|
||||
rm -f /tmp/ipv6supp$INTER
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $DATAFORM = '"raw-ip"' ]; then
|
||||
log "Handle raw-ip"
|
||||
json_load "$CONN4"
|
||||
json_select ipv4
|
||||
json_get_vars ip subnet gateway dns1 dns2
|
||||
if [ $enb = "1" ]; then
|
||||
if [ -n "$CONF6" ]; then
|
||||
json_load "$CONN6"
|
||||
json_select ipv6
|
||||
json_get_var ip_6 ip
|
||||
json_get_var gateway_6 gateway
|
||||
json_get_var dns1_6 dns1
|
||||
json_get_var dns2_6 dns2
|
||||
json_get_var ip_prefix_length ip-prefix-length
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -s /tmp/v4dns$INTER -o -s /tmp/v6dns$INTER ]; then
|
||||
pdns=1
|
||||
if [ -s /tmp/v4dns$INTER ]; then
|
||||
v4dns=$(cat /tmp/v4dns$INTER 2>/dev/null)
|
||||
fi
|
||||
if [ $enb = "1" ]; then
|
||||
if [ -s /tmp/v6dns$INTER ]; then
|
||||
v6dns=$(cat /tmp/v6dns$INTER 2>/dev/null)
|
||||
fi
|
||||
fi
|
||||
else
|
||||
v4dns="$dns1 $dns2"
|
||||
if [ $enb = "1" ]; then
|
||||
v6dns="$dns1_6 $dns2_6"
|
||||
echo "$v6dns" > /tmp/v6dns$INTER
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $DHCP -eq 0 ]; then
|
||||
log Applying IP settings to wan$INTER
|
||||
uci delete network.wan$INTER
|
||||
uci set network.wan$INTER=interface
|
||||
uci set network.wan$INTER.proto=static
|
||||
uci set network.wan$INTER.${ifname1}=$ifname
|
||||
uci set network.wan$INTER.metric=$INTER"0"
|
||||
uci set network.wan$INTER.ipaddr=$ip/$subnet
|
||||
uci set network.wan$INTER.gateway='0.0.0.0'
|
||||
uci set network.wan$INTER.dns="$v4dns"
|
||||
uci commit network
|
||||
uci set modem.modem$CURRMODEM.interface=$ifname
|
||||
uci commit modem
|
||||
else
|
||||
proto_init_update "$ifname" 1
|
||||
proto_set_keep 1
|
||||
proto_add_ipv4_address "$ip" "$subnet"
|
||||
proto_add_ipv4_route "0.0.0.0" 0
|
||||
for DNSV in $(echo "$v4dns"); do
|
||||
proto_add_dns_server "$DNSV"
|
||||
done
|
||||
proto_send_update "$interface"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
uqmi -s -d "$device" --stop-network 0xffffffff --autoconnect > /dev/null & sleep 10 ; kill -9 $!
|
||||
ret=1
|
||||
fi
|
||||
|
||||
exit $ret
|
@ -238,7 +238,7 @@ btn.inputtitle = translate("Send Test of Text or Email")
|
||||
btn.inputstyle = "apply"
|
||||
btn:depends("text", "1")
|
||||
function btn.write()
|
||||
luci.sys.call("/usr/lib/bwmon/dotext.sh")
|
||||
luci.sys.call("/usr/lib/bwmon/dotext.sh &")
|
||||
end
|
||||
|
||||
b4 = s:option(DummyValue, "blank", " ");
|
||||
|
@ -4,6 +4,17 @@ config general 'general'
|
||||
option backup '30'
|
||||
option enabled '1'
|
||||
|
||||
|
||||
config bwwan 'bwwan'
|
||||
option wan '0'
|
||||
option wan '1'
|
||||
|
||||
config backup 'backup'
|
||||
option dailytotal '0'
|
||||
option dailyrx '0'
|
||||
option dailytx '0'
|
||||
option montotal '0'
|
||||
option monrx '0'
|
||||
option montx '0'
|
||||
option days '1'
|
||||
option year '0'
|
||||
option month '0'
|
||||
option day '0'
|
@ -6,13 +6,23 @@ START=60
|
||||
start() {
|
||||
WX=$(uci -q get custom.bwallocate.lock)
|
||||
if [ "$WX" = "1" ]; then
|
||||
uci set bwmon.general.enabled=$enable
|
||||
uci set bwmon.general.enabled=1
|
||||
uci commit bwmon
|
||||
fi
|
||||
/usr/lib/bwmon/wrtbwmon.sh &
|
||||
/usr/lib/bwmon/create.sh &
|
||||
}
|
||||
|
||||
stop() {
|
||||
rmdir -f /tmp/WRTbmon
|
||||
WX=$(uci -q get bwmon.backup)
|
||||
if [ -z "$WX" ]; then
|
||||
uci set bwmon.backup='backup'
|
||||
uci set bwmon.backup.dailytotal='0'
|
||||
uci set bwmon.backup.dailyrx='0'
|
||||
uci set bwmon.backup.dailytx='0'
|
||||
uci set bwmon.backup.montotal='0'
|
||||
uci set bwmon.backup.monrx='0'
|
||||
uci set bwmon.backup.montx='0'
|
||||
uci set bwmon.backup.days='1'
|
||||
uci set bwmon.backup.year='0'
|
||||
uci set bwmon.backup.month='0'
|
||||
uci set bwmon.backup.day='0'
|
||||
uci commit bwmon
|
||||
fi
|
||||
/usr/lib/bwmon/bwmon.sh &
|
||||
}
|
@ -12,10 +12,10 @@ if [ $amount != "0" ]; then
|
||||
else
|
||||
sleep 3
|
||||
fi
|
||||
result=`ps | grep -i "create_data.lua" | grep -v "grep" | wc -l`
|
||||
result=`ps | grep -i "createdata.lua" | grep -v "grep" | wc -l`
|
||||
while [ $result -ge 1 ]; do
|
||||
sleep 2
|
||||
result=`ps | grep -i "create_data.lua" | grep -v "grep" | wc -l`
|
||||
result=`ps | grep -i "createdata.lua" | grep -v "grep" | wc -l`
|
||||
done
|
||||
|
||||
lua /usr/lib/bwmon/create_data.lua
|
||||
lua /usr/lib/bwmon/createdata.lua
|
||||
|
@ -5,15 +5,15 @@ function ltrim(s)
|
||||
end
|
||||
|
||||
function calc(total)
|
||||
if total < 1000 then
|
||||
tstr = string.format("%.2f", total)
|
||||
if total < 1000000 then
|
||||
tstr = string.format("%.2f", total/1000)
|
||||
tfm = " K"
|
||||
else
|
||||
if total < 1000000 then
|
||||
tstr = string.format("%.2f", total/1000)
|
||||
tstr = string.format("%.2f", total/1000000)
|
||||
tfm = " MB"
|
||||
else
|
||||
tstr = string.format("%.2f", total/1000000)
|
||||
tstr = string.format("%.2f", total/1000000000)
|
||||
tfm = " GB"
|
||||
end
|
||||
end
|
||||
@ -21,10 +21,16 @@ function calc(total)
|
||||
return ltrim(str)
|
||||
end
|
||||
|
||||
aamt = arg[1]
|
||||
uamt = arg[2]
|
||||
amt = aamt - uamt
|
||||
aamt = tonumber(arg[1])
|
||||
uamt = tonumber(arg[2])
|
||||
if uamt > aamt then
|
||||
amt = uamt - aamt
|
||||
amts = calc(amt)
|
||||
amts = "-" .. amts
|
||||
else
|
||||
amt = aamt - uamt
|
||||
amts = calc(math.abs(amt))
|
||||
end
|
||||
tfile = io.open("/tmp/amtleft", "w")
|
||||
tfile:write(amts, "\n")
|
||||
tfile:close()
|
@ -1,61 +0,0 @@
|
||||
#!/usr/bin/lua
|
||||
|
||||
dailyUsageDB = arg[1]
|
||||
|
||||
bw = {}
|
||||
maclist = {}
|
||||
|
||||
file = io.open(dailyUsageDB, "r")
|
||||
i = 0
|
||||
repeat
|
||||
line = file:read("*line")
|
||||
if line == nil then
|
||||
break
|
||||
end
|
||||
s, e = line:find("\"mac\":\"")
|
||||
bs, be = line:find("\"", e+1)
|
||||
mac = line:sub(e+1, bs-1)
|
||||
if bw[mac] == nil then
|
||||
maclist[i] = mac
|
||||
i = i + 1
|
||||
bw[mac] = {}
|
||||
bw[mac]['down'] = 0
|
||||
bw[mac]['offdown'] = 0
|
||||
bw[mac]['up'] = 0
|
||||
bw[mac]['offup'] = 0
|
||||
end
|
||||
s, e = line:find("\"down\":\"")
|
||||
bs, be = line:find("\"", e+1)
|
||||
down = tonumber(line:sub(e+1, bs-1))
|
||||
bw[mac]['down'] = bw[mac]['down'] + down
|
||||
s, e = line:find("\"up\":\"")
|
||||
bs, be = line:find("\"", e+1)
|
||||
up = tonumber(line:sub(e+1, bs-1))
|
||||
bw[mac]['up'] = bw[mac]['up'] + up
|
||||
s, e = line:find("\"offdown\":\"")
|
||||
bs, be = line:find("\"", e+1)
|
||||
offdown = tonumber(line:sub(e+1, bs-1))
|
||||
bw[mac]['offdown'] = bw[mac]['offdown'] + offdown
|
||||
s, e = line:find("\"offup\":\"")
|
||||
bs, be = line:find("\"", e+1)
|
||||
offup = tonumber(line:sub(e+1, bs-1))
|
||||
bw[mac]['offup'] = bw[mac]['offup'] + offup
|
||||
s, e = line:find("\"ip\":\"")
|
||||
bs, be = line:find("\"", e+1)
|
||||
bw[mac]['ip'] = line:sub(e+1, bs-1)
|
||||
s, e = line:find("\"name\":\"")
|
||||
bs, be = line:find("\"", e+1)
|
||||
bw[mac]['name'] = line:sub(e+1, bs-1)
|
||||
until 1==0
|
||||
file:close()
|
||||
|
||||
j=0
|
||||
file = io.open(dailyUsageDB .. ".bk", "w")
|
||||
while maclist[j] ~= nil do
|
||||
mac = maclist[j]
|
||||
dline = "\"mac\":\"" .. mac .. "\",\"down\":\"" .. bw[mac]['down'] .. "\",\"up\":\"" .. bw[mac]['up'] .. "\",\"offdown\":\"0\",\"offup\":\"0\",\"ip\":\"" .. bw[mac]['ip'] .. "\",\"name\":\"" .. bw[mac]['name'] .. "\""
|
||||
file:write(dline, "\n")
|
||||
j = j + 1
|
||||
end
|
||||
file:close()
|
||||
|
@ -1,81 +0,0 @@
|
||||
#!/usr/bin/lua
|
||||
|
||||
monthUsageDB = arg[1]
|
||||
|
||||
tfile = io.open(monthUsageDB .. ".bk", "w")
|
||||
tfile:close()
|
||||
|
||||
file = io.open(monthUsageDB, "r")
|
||||
|
||||
repeat
|
||||
line = file:read("*line")
|
||||
if line == nil then
|
||||
break
|
||||
end
|
||||
s, e = line:find("start day")
|
||||
if s ~= nil then
|
||||
maclist = {}
|
||||
bw = {}
|
||||
i = 0
|
||||
startday = line
|
||||
repeat
|
||||
line = file:read("*line")
|
||||
if line == nil then
|
||||
break
|
||||
end
|
||||
s, e = line:find("end day")
|
||||
if s ~= nil then
|
||||
endday = line
|
||||
break
|
||||
end
|
||||
s, e = line:find("\"mac\":\"")
|
||||
bs, be = line:find("\"", e+1)
|
||||
mac = line:sub(e+1, bs-1)
|
||||
if bw[mac] == nil then
|
||||
maclist[i] = mac
|
||||
i = i + 1
|
||||
bw[mac] = {}
|
||||
bw[mac]['down'] = 0
|
||||
bw[mac]['offdown'] = 0
|
||||
bw[mac]['up'] = 0
|
||||
bw[mac]['offup'] = 0
|
||||
end
|
||||
s, e = line:find("\"down\":\"")
|
||||
bs, be = line:find("\"", e+1)
|
||||
down = tonumber(line:sub(e+1, bs-1))
|
||||
bw[mac]['down'] = bw[mac]['down'] + down
|
||||
s, e = line:find("\"up\":\"")
|
||||
bs, be = line:find("\"", e+1)
|
||||
up = tonumber(line:sub(e+1, bs-1))
|
||||
bw[mac]['up'] = bw[mac]['up'] + up
|
||||
s, e = line:find("\"offdown\":\"")
|
||||
bs, be = line:find("\"", e+1)
|
||||
offdown = tonumber(line:sub(e+1, bs-1))
|
||||
bw[mac]['offdown'] = bw[mac]['offdown'] + offdown
|
||||
s, e = line:find("\"offup\":\"")
|
||||
bs, be = line:find("\"", e+1)
|
||||
offup = tonumber(line:sub(e+1, bs-1))
|
||||
bw[mac]['offup'] = bw[mac]['offup'] + offup
|
||||
s, e = line:find("\"ip\":\"")
|
||||
bs, be = line:find("\"", e+1)
|
||||
bw[mac]['ip'] = line:sub(e+1, bs-1)
|
||||
s, e = line:find("\"name\":\"")
|
||||
bs, be = line:find("\"", e+1)
|
||||
bw[mac]['name'] = line:sub(e+1, bs-1)
|
||||
until 1==0
|
||||
-- day data
|
||||
j=0
|
||||
tfile = io.open(monthUsageDB .. ".bk", "a")
|
||||
tfile:write(startday, "\n")
|
||||
while maclist[j] ~= nil do
|
||||
mac = maclist[j]
|
||||
dline = "\"mac\":\"" .. mac .. "\",\"down\":\"" .. bw[mac]['down'] .. "\",\"up\":\"" .. bw[mac]['up'] .. "\",\"offdown\":\"0\",\"offup\":\"0\",\"ip\":\"" .. bw[mac]['ip'] .. "\",\"name\":\"" .. bw[mac]['name'] .. "\""
|
||||
tfile:write(dline, "\n")
|
||||
j = j + 1
|
||||
end
|
||||
tfile:write(endday, "\n")
|
||||
tfile:close()
|
||||
end
|
||||
|
||||
until 1==0
|
||||
file:close()
|
@ -1,51 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
log() {
|
||||
logger -t "wrtbwmon" "$@"
|
||||
}
|
||||
|
||||
# parameters
|
||||
#
|
||||
btype=$1
|
||||
cDay=$2
|
||||
monthlyUsageDB=$3
|
||||
dailyUsageDB=$4
|
||||
monthlyUsageBack=$5
|
||||
dailyUsageBack=$6
|
||||
pDay=$7
|
||||
|
||||
/usr/lib/bwmon/backup-daily.lua $dailyUsageDB
|
||||
/usr/lib/bwmon/backup-mon.lua $monthlyUsageDB
|
||||
cp -f $monthlyUsageDB".bk" $monthlyUsageDB
|
||||
cp -f $dailyUsageDB".bk" $dailyUsageDB
|
||||
|
||||
echo "start day $cDay" >> $monthlyUsageDB".bk"
|
||||
cat $dailyUsageDB".bk" >> $monthlyUsageDB".bk"
|
||||
echo "end day $cDay" >> $monthlyUsageDB".bk"
|
||||
|
||||
enb=$(uci -q get bwmon.general.enabled)
|
||||
|
||||
if [ $btype = "backup" ]; then
|
||||
if [ "$enb" = "1" ]; then
|
||||
cp -f $monthlyUsageDB".bk" $monthlyUsageBack
|
||||
cp -f $dailyUsageDB".bk" $dailyUsageBack
|
||||
fi
|
||||
else
|
||||
if [ $btype = "daily" ]; then
|
||||
cp -f $monthlyUsageDB".bk" $monthlyUsageDB
|
||||
if [ "$enb" = "1" ]; then
|
||||
cp -f $monthlyUsageDB".bk" $monthlyUsageBack
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
rm -f $dailyUsageDB".bk"
|
||||
|
||||
bwday=$(uci -q get modem.modeminfo1.bwday)
|
||||
if [ ! -z "$bwday" ]; then
|
||||
if [ $bwday = $pDay -a $bwday != "0" ]; then
|
||||
if [ -e /usr/lib/bwmon/sendsms ]; then
|
||||
/usr/lib/bwmon/sendsms.sh
|
||||
fi
|
||||
fi
|
||||
fi
|
378
rooter/0optionalapps/bwmon/files/usr/lib/bwmon/bwmon.sh
Normal file
378
rooter/0optionalapps/bwmon/files/usr/lib/bwmon/bwmon.sh
Normal file
@ -0,0 +1,378 @@
|
||||
#!/bin/sh
|
||||
. /usr/share/libubox/jshn.sh
|
||||
. /lib/functions.sh
|
||||
|
||||
log() {
|
||||
modlog "wrtbwmon" "$@"
|
||||
}
|
||||
|
||||
ifname1="ifname"
|
||||
if [ -e /etc/newstyle ]; then
|
||||
ifname1="device"
|
||||
fi
|
||||
|
||||
networkFuncs=/lib/functions/network.sh
|
||||
uci=`which uci 2>/dev/null`
|
||||
nslookup=`which nslookup 2>/dev/null`
|
||||
nvram=`which nvram 2>/dev/null`
|
||||
binDir=/usr/sbin
|
||||
|
||||
setbackup() {
|
||||
extn=$(uci -q get bwmon.general.external)
|
||||
if [ "$extn" = "0" ]; then
|
||||
backPath=/usr/lib/bwmon/bwdata/
|
||||
else
|
||||
if [ -e "$extn""/" ]; then
|
||||
backPath=$extn"/data/"
|
||||
else
|
||||
backPath=/usr/lib/bwmon/bwdata/
|
||||
uci set bwmon.general.external="0"
|
||||
uci commit bwmon
|
||||
fi
|
||||
fi
|
||||
if [ ! -e "$backpath" ]; then
|
||||
mkdir -p $backPath
|
||||
fi
|
||||
}
|
||||
|
||||
detectIF()
|
||||
{
|
||||
if [ -f "$networkFuncs" ]; then
|
||||
IF=`. $networkFuncs; network_get_device netdev $1; echo $netdev`
|
||||
[ -n "$IF" ] && echo $IF && return
|
||||
fi
|
||||
|
||||
if [ -n "$uci" -a -x "$uci" ]; then
|
||||
IF=`$uci get network.${1}.$ifname 2>/dev/null`
|
||||
[ $? -eq 0 -a -n "$IF" ] && echo $IF && return
|
||||
fi
|
||||
|
||||
if [ -n "$nvram" -a -x "$nvram" ]; then
|
||||
IF=`$nvram get ${1}_$ifname 2>/dev/null`
|
||||
[ $? -eq 0 -a -n "$IF" ] && echo $IF && return
|
||||
fi
|
||||
}
|
||||
|
||||
detectWAN()
|
||||
{
|
||||
[ -n "$WAN_IF" ] && echo $WAN_IF && return
|
||||
wan=$(detectIF wan)
|
||||
[ -n "$wan" ] && echo $wan && return
|
||||
wan=$(ip route show 2>/dev/null | grep default | sed -re '/^default/ s/default.*dev +([^ ]+).*/\1/')
|
||||
[ -n "$wan" ] && echo $wan && return
|
||||
[ -f "$networkFuncs" ] && wan=$(. $networkFuncs; network_find_wan wan; echo $wan)
|
||||
[ -n "$wan" ] && echo $wan && return
|
||||
}
|
||||
|
||||
device_get_stats() {
|
||||
iface=$1
|
||||
st=$(ubus -v call network.interface.$iface status)
|
||||
json_init
|
||||
json_load "$st"
|
||||
json_get_var iface l3_device
|
||||
json_get_var status up
|
||||
if [ $status = "1" ]; then
|
||||
js="{ \"name\": \"$iface\" }"
|
||||
st=$(ubus -v call network.device status "$js")
|
||||
json_init
|
||||
json_load "$st"
|
||||
json_select statistics &>/dev/null
|
||||
json_get_var val $2
|
||||
else
|
||||
val="0"
|
||||
fi
|
||||
echo $val
|
||||
}
|
||||
|
||||
update() {
|
||||
interfaces=""
|
||||
wan=$(detectWAN)
|
||||
C1=$(uci -q get modem.modem1.connected)
|
||||
C2=$(uci -q get modem.modem2.connected)
|
||||
if [ "$C1" = "1" ]; then
|
||||
interfaces="wan1"
|
||||
fi
|
||||
if [ "$C2" = "1" ]; then
|
||||
interfaces="interfaces wan2"
|
||||
fi
|
||||
WW=$(uci -q get bwmon.bwwan.wan)
|
||||
if [ "$WW" -eq 1 ]; then
|
||||
interfaces="$interfaces wan wwan2 wwan5"
|
||||
fi
|
||||
|
||||
val="0"
|
||||
rxval="0"
|
||||
txval="0"
|
||||
for interface in $interfaces; do
|
||||
rval=$(device_get_stats $interface "rx_bytes")
|
||||
let rxval=$rxval+$rval
|
||||
tval=$(device_get_stats $interface "tx_bytes")
|
||||
let txval=$txval+$tval
|
||||
done
|
||||
|
||||
#log "Offset $offsetotal $offsetrx $offsettx"
|
||||
orxval=$rxval
|
||||
otxval=$txval
|
||||
let xval=$rxval+$txval
|
||||
otot=$xval
|
||||
let val=$val+$xval
|
||||
#log "Update $val $rxval $txval"
|
||||
let rxval=$rxval-$offsetrx
|
||||
let txval=$txval-$offsettx
|
||||
let val=$val-$offsetotal
|
||||
rtxval=$val
|
||||
# backup daily values
|
||||
let ttotal=$basedailytotal+$val
|
||||
let trx=$basedailyrx+$rxval
|
||||
let ttx=$basedailytx+$txval
|
||||
echo "$ttotal" > $dataPath"daily.js"
|
||||
echo "$trx" >> $dataPath"daily.js"
|
||||
echo "$ttx" >> $dataPath"daily.js"
|
||||
cd=$cDay
|
||||
if [ $cd -lt 10 ]; then
|
||||
ct="0"$cd
|
||||
fi
|
||||
dt="$cYear-$cMonth-$cd"
|
||||
echo "$dt" >> $dataPath"daily.js"
|
||||
# backup monthly values
|
||||
let mtotal=$basemontotal+$val
|
||||
let mrx=$basemonrx+$rxval
|
||||
let mtx=$basemontx+$txval
|
||||
alloc=$(uci -q get custom.bwallocate.allocate)
|
||||
if [ -z "$alloc" ]; then
|
||||
alloc=1000000000
|
||||
else
|
||||
alloc=$alloc"000000000"
|
||||
fi
|
||||
/usr/lib/bwmon/excede.sh $mtotal $alloc
|
||||
if [ -e /usr/lib/bwmon/period.sh ]; then
|
||||
/usr/lib/bwmon/period.sh "$mtotal"
|
||||
fi
|
||||
}
|
||||
|
||||
createAmt()
|
||||
{
|
||||
while [ true ]; do
|
||||
valid=$(cat /var/state/dnsmasqsec)
|
||||
st=$(echo "$valid" | grep "ntpd says time is valid")
|
||||
if [ ! -z "$st" ]; then
|
||||
break
|
||||
fi
|
||||
sleep 10
|
||||
done
|
||||
cYear=$(uci -q get bwmon.backup.year)
|
||||
if [ "$cYear" = '0' ]; then
|
||||
cYear=$(date +%Y)
|
||||
cDay=$(date +%d)
|
||||
cMonth=$(date +%m)
|
||||
uci set bwmon.backup.year=$cYear
|
||||
uci set bwmon.backup.month=$cMonth
|
||||
uci set bwmon.backup.day=$cDay
|
||||
uci commit bwmon
|
||||
else
|
||||
cYear=$(uci -q get bwmon.backup.year)
|
||||
cMonth=$(uci -q get bwmon.backup.month)
|
||||
cDay=$(uci -q get bwmon.backup.day)
|
||||
fi
|
||||
basedailytotal=$(uci -q get bwmon.backup.dailytotal)
|
||||
basedailyrx=$(uci -q get bwmon.backup.dailyrx)
|
||||
basedailytx=$(uci -q get bwmon.backup.dailytx)
|
||||
basemontotal=$(uci -q get bwmon.backup.montotal)
|
||||
basemonrx=$(uci -q get bwmon.backup.monrx)
|
||||
basemontx=$(uci -q get bwmon.backup.montx)
|
||||
if [ -z "$1" ]; then
|
||||
offsetotal='0'
|
||||
offsetrx='0'
|
||||
offsettx='0'
|
||||
else
|
||||
offsetotal=$otot
|
||||
offsetrx=$orxval
|
||||
offsettx=$otxval
|
||||
fi
|
||||
}
|
||||
|
||||
checkTime()
|
||||
{
|
||||
pDay=$(date +%d)
|
||||
pYear=$(date +%Y)
|
||||
pMonth=$(date +%m)
|
||||
#pDay=$(uci -q get bwmon.backup.tday)
|
||||
if [ "$cDay" -ne "$pDay" ]; then
|
||||
#log "Day Changed"
|
||||
# save to periodic
|
||||
/usr/lib/bwmon/createdata.lua
|
||||
bt=$(uci -q get custom.bwday)
|
||||
if [ -z "$bt" ]; then
|
||||
uci set custom.bwday='bwday'
|
||||
fi
|
||||
uci set custom.bwday.bwday=$(convert_bytes $mtotal)
|
||||
uci commit custom
|
||||
bwday=$(uci -q get modem.modeminfo1.bwday)
|
||||
if [ ! -z "$bwday" ]; then
|
||||
if [ $bwday = $pDay -a $bwday != "0" ]; then
|
||||
if [ -e /usr/lib/bwmon/sendsms ]; then
|
||||
/usr/lib/bwmon/sendsms.sh &
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
# backup month
|
||||
offsetotal=$rtxval
|
||||
offsetrx=$rxval
|
||||
offsettx=$txval
|
||||
#log "Offset $offsetotal $offsetrx $offsettx"
|
||||
uci set bwmon.backup.montotal=$mtotal
|
||||
uci set bwmon.backup.monrx=$mrx
|
||||
uci set bwmon.backup.montx=$mtx
|
||||
# clear daily
|
||||
basedailytotal='0'
|
||||
uci set bwmon.backup.dailytotal='0'
|
||||
basedailyrx='0'
|
||||
uci set bwmon.backup.dailyrx='0'
|
||||
basedailytx='0'
|
||||
uci set bwmon.backup.dailytx='0'
|
||||
# increase days
|
||||
days=$(uci -q get bwmon.backup.days)
|
||||
let days=$days+1
|
||||
uci set bwmon.backup.days=$days
|
||||
# day and date
|
||||
uci set bwmon.backup.year=$pYear
|
||||
uci set bwmon.backup.month=$pMonth
|
||||
uci set bwmon.backup.day=$pDay
|
||||
uci commit bwmon
|
||||
basemontotal=$(uci -q get bwmon.backup.montotal)
|
||||
basemonrx=$(uci -q get bwmon.backup.monrx)
|
||||
basemontx=$(uci -q get bwmon.backup.montx)
|
||||
cDay=$pDay
|
||||
cMonth=$pMonth
|
||||
cYear=$pYear
|
||||
roll=$(uci -q get custom.bwallocate.rollover)
|
||||
[ -z $roll ] && roll=1
|
||||
if [ "$roll" -eq "$pDay" ]; then
|
||||
#log "Month Change"
|
||||
# clear monthly
|
||||
basemontotal='0'
|
||||
mtotal='0'
|
||||
uci set bwmon.backup.montotal='0'
|
||||
basemonrx='0'
|
||||
mrx='0'
|
||||
uci set bwmon.backup.monrx='0'
|
||||
basemontx='0'
|
||||
mtx='0'
|
||||
uci -q get bwmon.backup.montx='0'
|
||||
# reset days
|
||||
uci set bwmon.backup.days='1'
|
||||
uci commit bwmon
|
||||
uci set custom.texting.used='0'
|
||||
uci commit custom
|
||||
if [ -e /usr/lib/bwmon/periodreset.sh ]; then
|
||||
/usr/lib/bwmon/periodreset.sh
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
checkBackup()
|
||||
{
|
||||
CURRTIME=$(date +%s)
|
||||
let ELAPSE=CURRTIME-STARTIMEZ
|
||||
bs=$(uci -q get bwmon.general.backup)
|
||||
#bs="1"
|
||||
let "bs=$bs*60"
|
||||
backup_time=$bs
|
||||
en=$(uci -q get bwmon.general.enabled)
|
||||
if [ "$en" = '1' ]; then
|
||||
if [ $ELAPSE -gt $backup_time ]; then
|
||||
STARTIMEZ=$CURRTIME
|
||||
# save monthly
|
||||
uci set bwmon.backup.montotal=$mtotal
|
||||
uci set bwmon.backup.monrx=$mrx
|
||||
uci set bwmon.backup.montx=$mtx
|
||||
# save daily
|
||||
uci set bwmon.backup.dailytotal=$ttotal
|
||||
uci set bwmon.backup.dailyrx=$trx
|
||||
uci set bwmon.backup.dailytx=$ttx
|
||||
# save day and date
|
||||
uci set bwmon.backup.year=$cYear
|
||||
uci set bwmon.backup.month=$cMonth
|
||||
uci set bwmon.backup.day=$cDay
|
||||
# total days
|
||||
uci commit bwmon
|
||||
#log "Backup $mtotal $val"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
convert_bytes() {
|
||||
local val=$1
|
||||
rm -f /tmp/bytes
|
||||
/usr/lib/bwmon/convertbytes.lua $val
|
||||
source /tmp/bytes
|
||||
echo "$BYTES"
|
||||
}
|
||||
|
||||
createGUI()
|
||||
{
|
||||
days=$(uci -q get bwmon.backup.days)
|
||||
echo "$days" > /tmp/bwdata
|
||||
tb=$(convert_bytes $mtotal)
|
||||
echo "$mtotal" >> /tmp/bwdata
|
||||
echo "$tb" >> /tmp/bwdata
|
||||
tb=$(convert_bytes $mrx)
|
||||
echo "$mrx" >> /tmp/bwdata
|
||||
echo "$tb" >> /tmp/bwdata
|
||||
tb=$(convert_bytes $mtx)
|
||||
echo "$mtx" >> /tmp/bwdata
|
||||
echo "$tb" >> /tmp/bwdata
|
||||
let ptotal=$mtotal/$days
|
||||
let ptotal=$ptotal*30
|
||||
tb=$(convert_bytes $ptotal)
|
||||
echo "$ptotal" >> /tmp/bwdata
|
||||
echo "$tb" >> /tmp/bwdata
|
||||
alloc=$(uci -q get custom.bwallocate.allocate)
|
||||
pass=$(uci -q get custom.bwallocate.password)
|
||||
if [ -z "$alloc" ]; then
|
||||
alloc=1000000000
|
||||
pass="password"
|
||||
else
|
||||
alloc=$alloc"000000000"
|
||||
fi
|
||||
tb=$(convert_bytes $alloc)
|
||||
echo "$alloc" >> /tmp/bwdata
|
||||
echo "$tb" >> /tmp/bwdata
|
||||
echo "$pass" >> /tmp/bwdata
|
||||
echo "0" >> /tmp/bwdata
|
||||
}
|
||||
|
||||
basePath="/tmp/bwmon/"
|
||||
mkdir -p $basePath"bwdata"
|
||||
dataPath=$basePath"bwdata/"
|
||||
setbackup
|
||||
STARTIMEX=$(date +%s)
|
||||
STARTIMEY=$(date +%s)
|
||||
STARTIMEZ=$(date +%s)
|
||||
update_time=20
|
||||
|
||||
createAmt
|
||||
while [ true ] ; do
|
||||
update
|
||||
if [ -e /tmp/bwchange ]; then
|
||||
newamt=$(cat /tmp/bwchange)
|
||||
rm -f /tmp/bwchange
|
||||
uci set bwmon.backup.dailytotal=$newamt
|
||||
uci set bwmon.backup.dailyrx=$newamt
|
||||
uci set bwmon.backup.dailytx=0
|
||||
uci set bwmon.backup.montotal=$newamt
|
||||
uci set bwmon.backup.monrx=$newamt
|
||||
uci set bwmon.backup.montx=0
|
||||
uci commit bwmon
|
||||
createAmt 1
|
||||
mtotal=0
|
||||
mrx=0
|
||||
mtx=0
|
||||
createGUI
|
||||
fi
|
||||
checkTime
|
||||
checkBackup
|
||||
createGUI
|
||||
#log "$(convert_bytes $mtotal) $(convert_bytes $mrx) $(convert_bytes $mtx) $(convert_bytes $val) $(convert_bytes $rxval) $(convert_bytes $txval)"
|
||||
sleep $update_time
|
||||
done
|
@ -1,32 +0,0 @@
|
||||
#!/usr/bin/lua
|
||||
|
||||
filepost = "-mac_data.js"
|
||||
dirname = '/usr/lib/bwmon/data'
|
||||
|
||||
function clean()
|
||||
nummon = 0
|
||||
months = {}
|
||||
f = io.popen('/bin/ls ' .. dirname)
|
||||
for name in f:lines() do
|
||||
s, e = name:find(filepost)
|
||||
if s ~= nil then
|
||||
nummon = nummon + 1
|
||||
months[nummon] = dirname .. "/" .. name
|
||||
end
|
||||
end
|
||||
f:close()
|
||||
|
||||
count = 1
|
||||
if nummon > 0 then
|
||||
for i=nummon,1,-1 do
|
||||
if count > 3 then
|
||||
os.execute("rm -f " .. months[i])
|
||||
end
|
||||
count = count + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
clean()
|
||||
dirname = '/tmp/bwmon/data'
|
||||
clean()
|
@ -0,0 +1,30 @@
|
||||
#!/usr/bin/lua
|
||||
|
||||
bytes=arg[1]
|
||||
|
||||
function ltrim(s)
|
||||
return s:match'^%s*(.*)'
|
||||
end
|
||||
|
||||
function calc(total)
|
||||
if total < 1000000 then
|
||||
tstr = string.format("%.2f", total)
|
||||
tstr = string.format("%.2f", total/1000)
|
||||
tfm = " K"
|
||||
else
|
||||
if total < 1000000000 then
|
||||
tstr = string.format("%.2f", total/1000000)
|
||||
tfm = " MB"
|
||||
else
|
||||
tstr = string.format("%.2f", total/1000000000)
|
||||
tfm = " GB"
|
||||
end
|
||||
end
|
||||
str = tstr .. tfm
|
||||
return ltrim(str)
|
||||
end
|
||||
|
||||
conbytes = "BYTES='" .. calc(tonumber(bytes)) .. "'"
|
||||
tfile = io.open("/tmp/bytes", "w")
|
||||
tfile:write(conbytes, "\n")
|
||||
tfile:close()
|
@ -1,16 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
log() {
|
||||
logger -t "createdata" "$@"
|
||||
}
|
||||
|
||||
lua /usr/lib/bwmon/create_data.lua
|
||||
sleep 60
|
||||
while [ true ]
|
||||
do
|
||||
result=`ps | grep -i "create_data.lua" | grep -v "grep" | wc -l`
|
||||
if [ $result -lt 1 ]; then
|
||||
lua /usr/lib/bwmon/create_data.lua
|
||||
fi
|
||||
sleep 60
|
||||
done
|
@ -1,193 +0,0 @@
|
||||
#!/usr/bin/lua
|
||||
|
||||
dirname = '/tmp/bwmon/data'
|
||||
filepost = "-mac_data.js.bk"
|
||||
bw = {}
|
||||
maclist = {}
|
||||
devices = {}
|
||||
totaldevices = 0
|
||||
totaldown = 0
|
||||
totalup = 0
|
||||
total = 0
|
||||
|
||||
printf = function(s,...)
|
||||
local ss = s:format(...)
|
||||
os.execute("/usr/lib/rooter/logprint.sh " .. ss)
|
||||
end
|
||||
|
||||
function ltrim(s)
|
||||
return s:match'^%s*(.*)'
|
||||
end
|
||||
|
||||
function calc(total)
|
||||
if total < 1000 then
|
||||
tstr = string.format("%.2f", total)
|
||||
tfm = " K"
|
||||
else
|
||||
if total < 1000000 then
|
||||
tstr = string.format("%.2f", total/1000)
|
||||
tfm = " MB"
|
||||
else
|
||||
tstr = string.format("%.2f", total/1000000)
|
||||
tfm = " GB"
|
||||
end
|
||||
end
|
||||
str = tstr .. tfm
|
||||
return ltrim(str)
|
||||
end
|
||||
|
||||
function monthly(datafile)
|
||||
file = io.open(datafile, "r")
|
||||
i = 0
|
||||
dayx = 0
|
||||
repeat
|
||||
line = file:read("*line")
|
||||
if line == nil then
|
||||
break
|
||||
end
|
||||
s, e = line:find("start day")
|
||||
if s ~= nil then
|
||||
dayx = dayx + 1
|
||||
repeat
|
||||
line = file:read("*line")
|
||||
s, e = line:find("end day")
|
||||
if s ~= nil then
|
||||
break
|
||||
end
|
||||
s, e = line:find("\"mac\":\"")
|
||||
bs, be = line:find("\"", e+1)
|
||||
mac = line:sub(e+1, bs-1)
|
||||
if bw[mac] == nil then
|
||||
maclist[i] = mac
|
||||
i = i + 1
|
||||
bw[mac] = {}
|
||||
bw[mac]['down'] = 0
|
||||
bw[mac]['offdown'] = 0
|
||||
bw[mac]['up'] = 0
|
||||
bw[mac]['offup'] = 0
|
||||
end
|
||||
s, e = line:find("\"down\":\"")
|
||||
bs, be = line:find("\"", e+1)
|
||||
down = tonumber(line:sub(e+1, bs-1))
|
||||
bw[mac]['down'] = bw[mac]['down'] + down
|
||||
s, e = line:find("\"up\":\"")
|
||||
bs, be = line:find("\"", e+1)
|
||||
up = tonumber(line:sub(e+1, bs-1))
|
||||
bw[mac]['up'] = bw[mac]['up'] + up
|
||||
s, e = line:find("\"offdown\":\"")
|
||||
bs, be = line:find("\"", e+1)
|
||||
offdown = tonumber(line:sub(e+1, bs-1))
|
||||
bw[mac]['offdown'] = bw[mac]['offdown'] + offdown
|
||||
s, e = line:find("\"offup\":\"")
|
||||
bs, be = line:find("\"", e+1)
|
||||
offup = tonumber(line:sub(e+1, bs-1))
|
||||
bw[mac]['offup'] = bw[mac]['offup'] + offup
|
||||
s, e = line:find("\"ip\":\"")
|
||||
bs, be = line:find("\"", e+1)
|
||||
bw[mac]['ip'] = line:sub(e+1, bs-1)
|
||||
s, e = line:find("\"name\":\"")
|
||||
bs, be = line:find("\"", e+1)
|
||||
bw[mac]['name'] = line:sub(e+1, bs-1)
|
||||
until 1==0
|
||||
end
|
||||
until 1==0
|
||||
file:close()
|
||||
return dayx
|
||||
end
|
||||
|
||||
function totals(bw, maclist, dayz)
|
||||
totaldown = 0
|
||||
totalup = 0
|
||||
utotaldown = 0
|
||||
utotalup = 0
|
||||
j=0
|
||||
while maclist[j] ~= nil do
|
||||
totaldown = totaldown + bw[maclist[j]]['down']
|
||||
totalup = totalup + bw[maclist[j]]['up']
|
||||
utotaldown = utotaldown + bw[maclist[j]]['offdown']
|
||||
utotalup = utotalup + bw[maclist[j]]['offup']
|
||||
j = j + 1
|
||||
end
|
||||
total = totalup + totaldown
|
||||
ptotal = (total / dayz) * 30
|
||||
end
|
||||
|
||||
function showdevices(bw, maclist)
|
||||
k = 0
|
||||
while maclist[k] ~= nil do
|
||||
k = k + 1
|
||||
end
|
||||
if k > 0 then
|
||||
j = 0
|
||||
while maclist[j] ~= nil do
|
||||
dtot = bw[maclist[j]]['down'] + bw[maclist[j]]['up']
|
||||
devices[j] = bw[maclist[j]]['ip'] .."|" .. maclist[j]
|
||||
devices[j] = devices[j] .. "|" .. calc(bw[maclist[j]]['down']) .. "|" .. calc(bw[maclist[j]]['up'])
|
||||
devices[j] = devices[j] .. "|" .. calc(dtot) .. "|" .. bw[maclist[j]]['name']
|
||||
j = j + 1
|
||||
end
|
||||
end
|
||||
totaldevices = j
|
||||
end
|
||||
|
||||
os.execute("echo 0 > /tmp/lockbw")
|
||||
dataname = nil
|
||||
f = io.popen('/bin/ls ' .. dirname)
|
||||
for name in f:lines() do
|
||||
s, e = name:find(filepost)
|
||||
if s ~= nil then
|
||||
dataname = dirname .. "/" .. name
|
||||
end
|
||||
end
|
||||
f:close()
|
||||
|
||||
if dataname ~= nil then
|
||||
days = monthly(dataname)
|
||||
totals(bw, maclist, days)
|
||||
tfile = io.open("/tmp/bwdata", "w")
|
||||
tfile:write(days, "\n")
|
||||
tfile:write(tostring(total), "\n")
|
||||
tfile:write(calc(total), "\n")
|
||||
tfile:write(tostring(totaldown), "\n")
|
||||
tfile:write(calc(totaldown), "\n")
|
||||
tfile:write(tostring(totalup), "\n")
|
||||
tfile:write(calc(totalup), "\n")
|
||||
tfile:write(tostring(ptotal), "\n")
|
||||
tfile:write(calc(ptotal), "\n")
|
||||
--
|
||||
-- allocated bandwidth in K
|
||||
--
|
||||
bwallo='rm -f /tmp/bwallo; x=$(uci -q get custom.bwallocate.allocate); echo $x >> /tmp/bwallo; x=$(uci -q get custom.bwallocate.password); echo $x >> /tmp/bwallo'
|
||||
os.execute(bwallo)
|
||||
file = io.open("/tmp/bwallo", "r")
|
||||
if file == nil then
|
||||
allo = 1000000000
|
||||
passw = "password"
|
||||
else
|
||||
allos = file:read("*line")
|
||||
allo = tonumber(allos) * 1000000
|
||||
passw = file:read("*line")
|
||||
file:close()
|
||||
end
|
||||
tfile:write(tostring(allo), "\n")
|
||||
tfile:write(calc(allo), "\n")
|
||||
tfile:write(passw, "\n")
|
||||
|
||||
showdevices(bw, maclist)
|
||||
tfile:write(tostring(totaldevices), "\n")
|
||||
if totaldevices > 0 then
|
||||
for i=0, totaldevices-1 do
|
||||
tfile:write(devices[i], "\n")
|
||||
end
|
||||
end
|
||||
tfile:close()
|
||||
else
|
||||
tfile = io.open("/tmp/bwdata", "w")
|
||||
tfile:write("0\n")
|
||||
tfile:write("0\n")
|
||||
tfile:close()
|
||||
end
|
||||
os.execute("rm -f /tmp/lockbw")
|
||||
os.execute("/usr/lib/bwmon/excede.sh " .. tostring(total) .. " " .. tostring(allo) .. " " .. tostring(ptotal))
|
||||
os.execute("/usr/lib/bwmon/savetot.sh \"" .. calc(total) .. "\"")
|
||||
os.execute("/usr/lib/bwmon/perday.lua")
|
127
rooter/0optionalapps/bwmon/files/usr/lib/bwmon/createdata.lua
Normal file
127
rooter/0optionalapps/bwmon/files/usr/lib/bwmon/createdata.lua
Normal file
@ -0,0 +1,127 @@
|
||||
#!/usr/bin/lua
|
||||
|
||||
monthly = '/usr/lib/bwmon/data/monthly.data'
|
||||
datafile='/tmp/bwmon/bwdata/daily.js'
|
||||
monline = {}
|
||||
monlist = {}
|
||||
|
||||
function ltrim(s)
|
||||
return s:match'^%s*(.*)'
|
||||
end
|
||||
|
||||
function calc(total)
|
||||
if total < 1000000 then
|
||||
tstr = string.format("%.2f", total)
|
||||
tstr = string.format("%.2f", total/1000)
|
||||
tfm = " K"
|
||||
else
|
||||
if total < 1000000000 then
|
||||
tstr = string.format("%.2f", total/1000000)
|
||||
tfm = " MB"
|
||||
else
|
||||
tstr = string.format("%.2f", total/1000000000)
|
||||
tfm = " GB"
|
||||
end
|
||||
end
|
||||
str = tstr .. tfm
|
||||
return ltrim(str)
|
||||
end
|
||||
|
||||
local function bubblesort(a)
|
||||
repeat
|
||||
local swapped = false
|
||||
for i = 1, table.getn(a) do
|
||||
if a[i - 1] < a[i] then
|
||||
a[i], a[i - 1] = a[i - 1], a[i]
|
||||
swapped = true
|
||||
end -- if
|
||||
end -- for
|
||||
until swapped == false
|
||||
end
|
||||
|
||||
function ConBytes(line)
|
||||
local s, e, bs, be
|
||||
s, e = line:find(" ")
|
||||
bs, be = line:find("K", e+1)
|
||||
if bs == nil then
|
||||
bs, be = line:find("MB", e+1)
|
||||
if bs == nil then
|
||||
val = tonumber(line:sub(1, e-1)) * 1000000000
|
||||
else
|
||||
val = tonumber(line:sub(1, e-1)) * 1000000
|
||||
end
|
||||
else
|
||||
val = tonumber(line:sub(1, e-1)) * 1000
|
||||
end
|
||||
return val
|
||||
end
|
||||
|
||||
kdwn = 0
|
||||
kup = 0
|
||||
ktotal = 0
|
||||
file = io.open(datafile, "r")
|
||||
if file ~= nil then
|
||||
total = file:read("*line")
|
||||
dwn = file:read("*line")
|
||||
up = file:read("*line")
|
||||
lin = file:read("*line")
|
||||
file:close()
|
||||
kdwn = tonumber(dwn)
|
||||
kup = tonumber(up)
|
||||
ktotal = tonumber(total)
|
||||
dwn = calc(tonumber(dwn))
|
||||
up = calc(tonumber(up))
|
||||
total = calc(tonumber(total))
|
||||
print(ktotal, kdwn, kup)
|
||||
dataline = lin .. "|" .. dwn .. "|" .. up .. "|" .. total
|
||||
print(dataline)
|
||||
monline[lin] = dataline
|
||||
monlist[0] = lin
|
||||
ksize = 1
|
||||
end
|
||||
k = 1
|
||||
tfile = io.open(monthly, "r")
|
||||
if tfile ~= nil then
|
||||
ksize = tfile:read("*line")
|
||||
ksize = tostring(tonumber(ksize) + 1)
|
||||
kdwn1 = tfile:read("*line")
|
||||
kdwn1=ConBytes(kdwn1)
|
||||
kdwn = (kdwn1 + kdwn)
|
||||
kup1 = tfile:read("*line")
|
||||
kup1=ConBytes(kup1)
|
||||
kup = (kup1 + kup)
|
||||
ktotal1 = tfile:read("*line")
|
||||
ktotal1=ConBytes(ktotal1)
|
||||
ktotal = (ktotal1 + ktotal)
|
||||
repeat
|
||||
line = tfile:read("*line")
|
||||
if line == nil then
|
||||
break
|
||||
end
|
||||
s, e = line:find("|")
|
||||
ymd = line:sub(1, s-1)
|
||||
monline[ymd] = line
|
||||
monlist[k] = ymd
|
||||
k = k + 1
|
||||
until 1==0
|
||||
tfile:close()
|
||||
bubblesort(monlist)
|
||||
end
|
||||
if k > 30 then
|
||||
k = 30
|
||||
end
|
||||
|
||||
tfile = io.open(monthly, "w")
|
||||
tfile:write(tostring(k), "\n")
|
||||
tfile:write(calc(kdwn), "\n")
|
||||
tfile:write(calc(kup), "\n")
|
||||
tfile:write(calc(ktotal), "\n")
|
||||
for j = 0,k-1
|
||||
do
|
||||
lin = monlist[j]
|
||||
dataline = monline[lin]
|
||||
print(dataline)
|
||||
tfile:write(dataline, "\n")
|
||||
end
|
||||
tfile:close()
|
||||
--os.execute("uci set custom.bwday.bwday=" .. calc(ktotal) .. ";uci commit custom")
|
@ -4,7 +4,7 @@ prev = arg[1] -- previous increment in GB
|
||||
incr = arg[2] -- fixed increment in GB
|
||||
used = arg[3] -- amt used in Kb
|
||||
|
||||
used = used / 1000000 -- used in GB
|
||||
used = used / 1000000000 -- used in GB
|
||||
current = prev + incr
|
||||
running = "0"
|
||||
if used >= current then
|
||||
|
@ -4,10 +4,11 @@ alloc = arg[1] -- allocate increment in GB
|
||||
per = arg[2] -- fixed percentage in GB
|
||||
used = arg[3] -- amt used in Kb
|
||||
|
||||
used = used / 10000 -- used in GB
|
||||
percent = used / alloc
|
||||
--used = used / 10000 -- used in GB
|
||||
percent = (used / alloc) * 100
|
||||
|
||||
running = "0"
|
||||
if percent >= per then
|
||||
if percent >= tonumber(per) then
|
||||
running = "1"
|
||||
end
|
||||
|
||||
|
@ -6,7 +6,7 @@ log() {
|
||||
}
|
||||
|
||||
getbw() {
|
||||
alloc=$(uci -q get custom.bwallocate.allocate)"000000"
|
||||
alloc=$(uci -q get custom.bwallocate.allocate)"000000000"
|
||||
if [ -e /tmp/bwdata ]; then
|
||||
while IFS= read -r line; do
|
||||
days=$line
|
||||
|
@ -22,6 +22,8 @@ do_throttle() {
|
||||
fi
|
||||
}
|
||||
|
||||
bb="$(uci -q get custom.bwallocate.manual)"
|
||||
if [ "$bb" != "1" ]; then
|
||||
lock=$(uci -q get custom.bwallocate.lock)
|
||||
if [ $lock = "1" ]; then
|
||||
enb=$(uci -q get custom.bwallocate.enabled)
|
||||
@ -36,6 +38,8 @@ if [ $lock = "1" ]; then
|
||||
if [ ! -e /usr/lib/throttle/throttle.sh ]; then
|
||||
action=0
|
||||
fi
|
||||
uci set custom.bwallocate.status='0'
|
||||
uci commit custom
|
||||
if [ $action != "2" ]; then
|
||||
if [ $total -gt $allocate ]; then
|
||||
if [ $action = "0" ]; then
|
||||
@ -44,6 +48,8 @@ if [ $lock = "1" ]; then
|
||||
else
|
||||
/usr/lib/bwmon/block 1
|
||||
fi
|
||||
uci set custom.bwallocate.status='1'
|
||||
uci commit custom
|
||||
else
|
||||
down=$(uci -q get custom.bwallocate.down)
|
||||
if [ -z $down ]; then
|
||||
@ -54,6 +60,8 @@ if [ $lock = "1" ]; then
|
||||
up=2
|
||||
fi
|
||||
/usr/lib/throttle/throttle.sh start $down $up
|
||||
uci set custom.bwallocate.status='2'
|
||||
uci commit custom
|
||||
fi
|
||||
else
|
||||
if [ -e /usr/lib/throttle/throttle.sh ]; then
|
||||
@ -83,6 +91,8 @@ if [ $lock = "1" ]; then
|
||||
source /tmp/float
|
||||
/usr/lib/throttle/throttle.sh start $SPEED $SPEED 1
|
||||
log "Throttled to $speed Mbps"
|
||||
uci set custom.bwallocate.status='2'
|
||||
uci commit custom
|
||||
else
|
||||
if [ -e /usr/lib/throttle/throttle.sh ]; then
|
||||
/usr/lib/throttle/throttle.sh stop
|
||||
@ -92,3 +102,4 @@ if [ $lock = "1" ]; then
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
@ -13,12 +13,9 @@ if [ "$ext" = "$external" ]; then
|
||||
else
|
||||
uci set bwmon.general.external=$external
|
||||
uci commit bwmon
|
||||
PID=$(ps |grep "wrtbwmon.sh" | grep -v grep |head -n 1 | awk '{print $1}')
|
||||
PID1=$(ps |grep "create.sh" | grep -v grep |head -n 1 | awk '{print $1}')
|
||||
PID=$(ps |grep "bwmon.sh" | grep -v grep |head -n 1 | awk '{print $1}')
|
||||
if [ ! -z "$PID" ]; then
|
||||
kill -9 $PID
|
||||
kill -9 $PID1
|
||||
fi
|
||||
/usr/lib/bwmon/wrtbwmon.sh &
|
||||
/usr/lib/bwmon/create.sh &
|
||||
/usr/lib/bwmon/bwmon.sh &
|
||||
fi
|
64
rooter/0optionalapps/bwmon/files/usr/lib/bwmon/genline.sh
Normal file
64
rooter/0optionalapps/bwmon/files/usr/lib/bwmon/genline.sh
Normal file
@ -0,0 +1,64 @@
|
||||
#!/bin/sh
|
||||
. /usr/share/libubox/jshn.sh
|
||||
. /lib/functions.sh
|
||||
|
||||
genline() {
|
||||
MONLIST=$MONLIST"<tr>"
|
||||
t1="<td width=\"160px\"><div align=\"center\"><strong> $START</strong></div></td>"
|
||||
t2="<td width=\"200px\"><div align=\"center\"><strong> $updata</strong></div></td>"
|
||||
t3="<td width=\"150px\"><div align=\"center\"><strong> $downdata</strong></div></td>"
|
||||
t4="<td width=\"150px\"><div align=\"center\"><strong> $totaldata</strong></div></td>"
|
||||
t5="<td width=\"340\" ></td>"
|
||||
MONLIST=$MONLIST$t1$t2$t3$t4$t5"</tr>"
|
||||
}
|
||||
|
||||
bwdata() {
|
||||
START="-"
|
||||
END="-"
|
||||
header=0
|
||||
while IFS= read -r line; do
|
||||
if [ $header -eq 0 ]; then
|
||||
days=$line
|
||||
read -r line
|
||||
DOWN=$line
|
||||
read -r line
|
||||
UP=$line
|
||||
read -r line
|
||||
TOTAL=$line
|
||||
read -r line
|
||||
line=$(echo $line" " | tr "|" ",")
|
||||
END=$(echo $line | cut -d, -f1)
|
||||
START=$END
|
||||
updata=$(echo $line | cut -d, -f2)
|
||||
downdata=$(echo $line | cut -d, -f3)
|
||||
totaldata=$(echo $line | cut -d, -f4)
|
||||
genline
|
||||
read -r line
|
||||
header=1
|
||||
if [ -z "$line" ]; then
|
||||
break
|
||||
fi
|
||||
fi
|
||||
line=$(echo $line" " | tr "|" ",")
|
||||
START=$(echo $line | cut -d, -f1)
|
||||
updata=$(echo $line | cut -d, -f2)
|
||||
downdata=$(echo $line | cut -d, -f3)
|
||||
totaldata=$(echo $line | cut -d, -f4)
|
||||
genline
|
||||
|
||||
done < /usr/lib/bwmon/data/monthly.data
|
||||
}
|
||||
|
||||
MONLIST=""
|
||||
rm -f /tmp/monlist
|
||||
rm -f /tmp/montot
|
||||
if [ -e /usr/lib/bwmon/data/monthly.data ]; then
|
||||
bwdata
|
||||
echo $MONLIST > /tmp/monlist
|
||||
echo $days > /tmp/montot
|
||||
echo $DOWN >> /tmp/montot
|
||||
echo $UP >> /tmp/montot
|
||||
echo $TOTAL >> /tmp/montot
|
||||
|
||||
fi
|
||||
|
@ -1,204 +0,0 @@
|
||||
#!/usr/bin/lua
|
||||
|
||||
function ltrim(s)
|
||||
return s:match'^%s*(.*)'
|
||||
end
|
||||
|
||||
function calc(total)
|
||||
if total < 1000 then
|
||||
tstr = string.format("%.2f", total)
|
||||
tfm = " K"
|
||||
else
|
||||
if total < 1000000 then
|
||||
tstr = string.format("%.2f", total/1000)
|
||||
tfm = " MB"
|
||||
else
|
||||
tstr = string.format("%.2f", total/1000000)
|
||||
tfm = " GB"
|
||||
end
|
||||
end
|
||||
str = tstr .. tfm
|
||||
return ltrim(str)
|
||||
end
|
||||
|
||||
local function bubblesort(a)
|
||||
repeat
|
||||
local swapped = false
|
||||
for i = 1, table.getn(a) do
|
||||
if a[i - 1] < a[i] then
|
||||
a[i], a[i - 1] = a[i - 1], a[i]
|
||||
swapped = true
|
||||
end -- if
|
||||
end -- for
|
||||
until swapped == false
|
||||
end
|
||||
|
||||
function ConBytes(line)
|
||||
local s, e, bs, be
|
||||
s, e = line:find(" ")
|
||||
bs, be = line:find("K", e+1)
|
||||
if bs == nil then
|
||||
bs, be = line:find("MB", e+1)
|
||||
if bs == nil then
|
||||
val = tonumber(line:sub(1, e-1)) * 1000000
|
||||
else
|
||||
val = tonumber(line:sub(1, e-1)) * 1000
|
||||
end
|
||||
else
|
||||
val = tonumber(line:sub(1, e-1))
|
||||
end
|
||||
return val
|
||||
end
|
||||
|
||||
dirname = '/usr/lib/bwmon/data'
|
||||
filepost = "-mac_data.js"
|
||||
monthly = dirname .. "/monthly.data"
|
||||
daylist = {}
|
||||
dayline = {}
|
||||
monlist = {}
|
||||
monline = {}
|
||||
|
||||
dataname = nil
|
||||
f = io.popen('/bin/ls ' .. dirname)
|
||||
for name in f:lines() do
|
||||
s, e = name:find(filepost)
|
||||
if s ~= nil then
|
||||
dataname = name
|
||||
end
|
||||
end
|
||||
f:close()
|
||||
|
||||
if dataname ~= nil then
|
||||
yearmon = dataname:sub(1, 7)
|
||||
datafile = dirname .. "/" .. dataname
|
||||
file = io.open(datafile, "r")
|
||||
i = 0
|
||||
repeat
|
||||
line = file:read("*line")
|
||||
if line == nil then
|
||||
break
|
||||
end
|
||||
s, e = line:find("start day")
|
||||
if s ~= nil then
|
||||
day = line:sub(e+1)
|
||||
nday = tonumber(day)
|
||||
day= tostring(nday)
|
||||
if nday < 10 then
|
||||
day = "0" .. day
|
||||
end
|
||||
yearmonday = yearmon .. "-" .. day
|
||||
|
||||
daydwn = 0
|
||||
dayup = 0
|
||||
repeat
|
||||
line = file:read("*line")
|
||||
s, e = line:find("end day")
|
||||
if s ~= nil then
|
||||
dayt = dayup + daydwn
|
||||
if dayt > 0 then
|
||||
daylist[i] = yearmonday
|
||||
i = i + 1
|
||||
dayline[yearmonday] = {}
|
||||
dayline[yearmonday]['down'] = daydwn
|
||||
dayline[yearmonday]['up'] = dayup
|
||||
dayline[yearmonday]['total'] = dayup + daydwn
|
||||
end
|
||||
break
|
||||
end
|
||||
s, e = line:find("\"down\":\"")
|
||||
bs, be = line:find("\"", e+1)
|
||||
daydwn = daydwn + tonumber(line:sub(e+1, bs-1))
|
||||
s, e = line:find("\"up\":\"")
|
||||
bs, be = line:find("\"", e+1)
|
||||
dayup = dayup + tonumber(line:sub(e+1, bs-1))
|
||||
until 1==0
|
||||
end
|
||||
until 1==0
|
||||
|
||||
if i > 0 then
|
||||
tfile = io.open(monthly, "r")
|
||||
if tfile == nil then
|
||||
for j = 0,i-1
|
||||
do
|
||||
lin = daylist[j]
|
||||
monlist[j] = lin
|
||||
monline[lin] = {}
|
||||
dwn = calc(dayline[lin]['down'])
|
||||
up = calc(dayline[lin]['up'])
|
||||
total = calc(dayline[lin]['total'])
|
||||
dataline = lin .. "|" .. dwn .. "|" .. up .. "|" .. total
|
||||
monline[lin]['data'] = dataline
|
||||
end
|
||||
k = i
|
||||
else
|
||||
k = 0
|
||||
ksize = tfile:read("*line")
|
||||
kdwn = tfile:read("*line")
|
||||
kup = tfile:read("*line")
|
||||
ktotal = tfile:read("*line")
|
||||
repeat
|
||||
line = tfile:read("*line")
|
||||
if line == nil then
|
||||
break
|
||||
end
|
||||
ymd = line:sub(1,10)
|
||||
monlist[k] = ymd
|
||||
k = k + 1
|
||||
monline[ymd] = {}
|
||||
monline[ymd]['data'] = line
|
||||
until 1==0
|
||||
tfile:close()
|
||||
|
||||
for j = 0,i-1
|
||||
do
|
||||
lin = daylist[j]
|
||||
if monline[lin] == nil then
|
||||
monlist[k] = lin
|
||||
k = k + 1
|
||||
monline[lin] = {}
|
||||
end
|
||||
dwn = calc(dayline[lin]['down'])
|
||||
up = calc(dayline[lin]['up'])
|
||||
total = calc(dayline[lin]['total'])
|
||||
dataline = lin .. "|" .. dwn .. "|" .. up .. "|" .. total
|
||||
monline[lin]['data'] = dataline
|
||||
end
|
||||
end
|
||||
|
||||
bubblesort(monlist)
|
||||
|
||||
tfile = io.open(monthly, "w")
|
||||
if k > 30 then
|
||||
k = 30
|
||||
end
|
||||
tfile:write(tostring(k), "\n")
|
||||
fdown = 0
|
||||
fup = 0
|
||||
ftotal = 0
|
||||
for j = 0,k-1
|
||||
do
|
||||
lin = monlist[j]
|
||||
dataline = monline[lin]['data']
|
||||
s, e = dataline:find("|")
|
||||
if s ~= nil then
|
||||
bs, be = dataline:find("|", e+1)
|
||||
fdown = ConBytes(dataline:sub(e+1, be-1)) + fdown
|
||||
s, e = dataline:find("|", be+1)
|
||||
fup = ConBytes(dataline:sub(be+1, e-1)) + fup
|
||||
ftotal = ConBytes(dataline:sub(e+1)) + ftotal
|
||||
end
|
||||
end
|
||||
tfile:write(calc(fdown), "\n")
|
||||
tfile:write(calc(fup), "\n")
|
||||
tfile:write(calc(ftotal), "\n")
|
||||
for j = 0,k-1
|
||||
do
|
||||
lin = monlist[j]
|
||||
dataline = monline[lin]['data']
|
||||
tfile:write(dataline, "\n")
|
||||
end
|
||||
tfile:close()
|
||||
end
|
||||
|
||||
file:close()
|
||||
end
|
@ -3,18 +3,3 @@
|
||||
log() {
|
||||
logger -t "BWmon Process" "$@"
|
||||
}
|
||||
|
||||
running=0
|
||||
if [ -e "/tmp/WRTbmon" ]; then
|
||||
running=1
|
||||
fi
|
||||
|
||||
sleep 5
|
||||
|
||||
if [ $running = 0 ]; then
|
||||
log "Enable BandWidthMonitor"
|
||||
/usr/lib/bwmon/wrtbwmon.sh &
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
@ -1,10 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
log() {
|
||||
logger -t "save total" "$@"
|
||||
}
|
||||
|
||||
total=$1
|
||||
|
||||
uci set custom.bwday.bwday="$total"
|
||||
uci commit custom
|
@ -2,7 +2,7 @@
|
||||
. /lib/functions.sh
|
||||
|
||||
log() {
|
||||
logger -t "TEXTING" "$@"
|
||||
modlog "TEXTING" "$@"
|
||||
}
|
||||
|
||||
checktime() {
|
||||
@ -60,7 +60,7 @@ checktime() {
|
||||
}
|
||||
|
||||
getbw() {
|
||||
alloc=$(uci -q get custom.bwallocate.allocate)"000000"
|
||||
alloc=$(uci -q get custom.bwallocate.allocate)"000000000"
|
||||
if [ -e /tmp/bwdata ]; then
|
||||
while IFS= read -r line; do
|
||||
days=$line
|
||||
@ -96,7 +96,7 @@ checkper() {
|
||||
istime=$(checktime)
|
||||
if [ $istime = '1' ]; then
|
||||
prev=$(uci -q get custom.texting.used)
|
||||
per=$(uci -q get custom.bwallocate.percent)
|
||||
per=$(uci -q get custom.texting.percent)
|
||||
persent=$(uci -q get custom.bwallocate.persent)
|
||||
if [ "$persent" != "1" ]; then
|
||||
getbw
|
||||
@ -141,7 +141,7 @@ do
|
||||
if [ $running = "1" ]; then
|
||||
EN=$(uci -q get custom.texting.text)
|
||||
if [ $EN = "1" ]; then
|
||||
/usr/lib/bwmon/dotext.sh
|
||||
/usr/lib/bwmon/dotext.sh &
|
||||
sleep $delay
|
||||
fi
|
||||
else
|
||||
|
@ -1,508 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
setbackup() {
|
||||
extn=$(uci -q get bwmon.general.external)
|
||||
if [ "$extn" = "0" ]; then
|
||||
backPath=/usr/lib/bwmon/data/
|
||||
else
|
||||
if [ -e "$extn""/" ]; then
|
||||
backPath=$extn"/data/"
|
||||
else
|
||||
backPath=/usr/lib/bwmon/data/
|
||||
uci set bwmon.general.external="0"
|
||||
uci commit bwmon
|
||||
fi
|
||||
fi
|
||||
if [ ! -e "$backpath" ]; then
|
||||
mkdir -p $backPath
|
||||
fi
|
||||
}
|
||||
|
||||
LAN_TYPE=$(uci get network.lan.ipaddr | awk -F. ' { print $1"."$2 }')
|
||||
LEASES_FILE=/tmp/dhcp.leases
|
||||
lockDir=/tmp/WRTbmon
|
||||
|
||||
ifname="ifname"
|
||||
source /etc/openwrt_release
|
||||
twone=$(echo "$DISTRIB_RELEASE" | grep "21.02")
|
||||
if [ ! -z "$twone" ]; then
|
||||
ifname="device"
|
||||
fi
|
||||
|
||||
|
||||
[ ! -d "$lockDir" ] && mkdir "$lockDir"
|
||||
basePath="/tmp/bwmon/"
|
||||
mkdir -p $basePath"data"
|
||||
dataPath=$basePath"data/"
|
||||
setbackup
|
||||
lockDir1=/tmp/wrtbwmon1.lock
|
||||
lockDir=/tmp/wrtbwmon.lock
|
||||
mkdir -p "$lockDir"
|
||||
pidFile=$lockDir/pid
|
||||
STARTIMEX=$(date +%s)
|
||||
STARTIMEY=$(date +%s)
|
||||
STARTIMEZ=$(date +%s)
|
||||
cYear=$(date +%Y)
|
||||
cDay=$(date +%d)
|
||||
cMonth=$(date +%m)
|
||||
setup_time=60
|
||||
update_time=60
|
||||
bs=$(uci -q get bwmon.general.backup)
|
||||
let "bs=$bs*60"
|
||||
backup_time=$bs
|
||||
pause=30
|
||||
unlimited="peak"
|
||||
|
||||
networkFuncs=/lib/functions/network.sh
|
||||
uci=`which uci 2>/dev/null`
|
||||
nslookup=`which nslookup 2>/dev/null`
|
||||
nvram=`which nvram 2>/dev/null`
|
||||
binDir=/usr/sbin
|
||||
chains='INPUT OUTPUT FORWARD'
|
||||
DEBUG=
|
||||
interfaces='eth0' # in addition to detected WAN
|
||||
DB="/tmp/usage.db"
|
||||
mode=
|
||||
|
||||
log() {
|
||||
logger -t "wrtbwmon" "$@"
|
||||
}
|
||||
|
||||
header="#mac,ip,iface,in,out,total,first_date,last_date"
|
||||
|
||||
createDbIfMissing()
|
||||
{
|
||||
[ ! -f "$DB" ] && rm -f $DB;echo $header > "$DB"
|
||||
}
|
||||
|
||||
checkWAN()
|
||||
{
|
||||
[ -z "$wan" ] && return
|
||||
}
|
||||
|
||||
lookup()
|
||||
{
|
||||
MAC=$1
|
||||
IP=$2
|
||||
userDB=$3
|
||||
for USERSFILE in $userDB /tmp/dhcp.leases /tmp/dnsmasq.conf /etc/dnsmasq.conf /etc/hosts; do
|
||||
[ -e "$USERSFILE" ] || continue
|
||||
case $USERSFILE in
|
||||
/tmp/dhcp.leases )
|
||||
USER=$(grep -i "$MAC" $USERSFILE | cut -f4 -s -d' ')
|
||||
;;
|
||||
/etc/hosts )
|
||||
USER=$(grep "^$IP " $USERSFILE | cut -f2 -s -d' ')
|
||||
;;
|
||||
* )
|
||||
USER=$(grep -i "$MAC" "$USERSFILE" | cut -f2 -s -d,)
|
||||
;;
|
||||
esac
|
||||
[ "$USER" = "*" ] && USER=
|
||||
[ -n "$USER" ] && break
|
||||
done
|
||||
if [ -n "$DO_RDNS" -a -z "$USER" -a "$IP" != "NA" -a -n "$nslookup" ]; then
|
||||
USER=`$nslookup $IP $DNS | awk '!/server can/{if($4){print $4; exit}}' | sed -re 's/[.]$//'`
|
||||
fi
|
||||
[ -z "$USER" ] && USER=${MAC}
|
||||
echo $USER
|
||||
}
|
||||
|
||||
detectIF()
|
||||
{
|
||||
if [ -f "$networkFuncs" ]; then
|
||||
IF=`. $networkFuncs; network_get_device netdev $1; echo $netdev`
|
||||
[ -n "$IF" ] && echo $IF && return
|
||||
fi
|
||||
|
||||
if [ -n "$uci" -a -x "$uci" ]; then
|
||||
IF=`$uci get network.${1}.$ifname 2>/dev/null`
|
||||
[ $? -eq 0 -a -n "$IF" ] && echo $IF && return
|
||||
fi
|
||||
|
||||
if [ -n "$nvram" -a -x "$nvram" ]; then
|
||||
IF=`$nvram get ${1}_$ifname 2>/dev/null`
|
||||
[ $? -eq 0 -a -n "$IF" ] && echo $IF && return
|
||||
fi
|
||||
}
|
||||
|
||||
detectLAN()
|
||||
{
|
||||
[ -e /sys/class/net/br-lan ] && echo br-lan && return
|
||||
lan=$(detectIF lan)
|
||||
[ -n "$lan" ] && echo $lan && return
|
||||
}
|
||||
|
||||
detectWAN()
|
||||
{
|
||||
[ -n "$WAN_IF" ] && echo $WAN_IF && return
|
||||
wan=$(detectIF wan)
|
||||
[ -n "$wan" ] && echo $wan && return
|
||||
wan=$(ip route show 2>/dev/null | grep default | sed -re '/^default/ s/default.*dev +([^ ]+).*/\1/')
|
||||
[ -n "$wan" ] && echo $wan && return
|
||||
[ -f "$networkFuncs" ] && wan=$(. $networkFuncs; network_find_wan wan; echo $wan)
|
||||
[ -n "$wan" ] && echo $wan && return
|
||||
}
|
||||
|
||||
lock()
|
||||
{
|
||||
attempts=0
|
||||
while [ $attempts -lt 10 ]; do
|
||||
mkdir $lockDir1 2>/dev/null && break
|
||||
attempts=$((attempts+1))
|
||||
pid=`cat $pidFile 2>/dev/null`
|
||||
if [ -n "$pid" ]; then
|
||||
if [ -d "/proc/$pid" ]; then
|
||||
[ -n "$DEBUG" ] && echo "WARNING: Lockfile detected but process $(cat $pidFile) does not exist !"
|
||||
rm -rf $lockDir1
|
||||
else
|
||||
sleep 1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
mkdir $lockDir1 2>/dev/null
|
||||
echo $$ > $pidFile
|
||||
[ -n "$DEBUG" ] && echo $$ "got lock after $attempts attempts"
|
||||
trap '' INT
|
||||
}
|
||||
|
||||
unlock()
|
||||
{
|
||||
rm -rf $lockDir1
|
||||
[ -n "$DEBUG" ] && echo $$ "released lock"
|
||||
trap "rm -f /tmp/*_$$.tmp; kill $$" INT
|
||||
}
|
||||
|
||||
# chain
|
||||
newChain()
|
||||
{
|
||||
chain=$1
|
||||
# Create the RRDIPT_$chain chain (it doesn't matter if it already exists).
|
||||
iptables -t mangle -N RRDIPT_$chain 2> /dev/null
|
||||
|
||||
# Add the RRDIPT_$chain CHAIN to the $chain chain if not present
|
||||
iptables -t mangle -C $chain -j RRDIPT_$chain 2>/dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
[ -n "$DEBUG" ] && echo "DEBUG: iptables chain misplaced, recreating it..."
|
||||
iptables -t mangle -I $chain -j RRDIPT_$chain
|
||||
fi
|
||||
}
|
||||
|
||||
# chain tun
|
||||
newRuleIF()
|
||||
{
|
||||
chain=$1
|
||||
IF=$2
|
||||
|
||||
#!@todo test
|
||||
if [ "$chain" = "OUTPUT" ]; then
|
||||
cmd="iptables -t mangle -o $IF -j RETURN"
|
||||
eval $cmd " -C RRDIPT_$chain 2>/dev/null" || eval $cmd " -A RRDIPT_$chain"
|
||||
elif [ "$chain" = "INPUT" ]; then
|
||||
cmd="iptables -t mangle -i $IF -j RETURN"
|
||||
eval $cmd " -C RRDIPT_$chain 2>/dev/null" || eval $cmd " -A RRDIPT_$chain"
|
||||
fi
|
||||
}
|
||||
|
||||
accounting(){
|
||||
LAN_IFACE="br-lan"
|
||||
WAN_IFACE=$1
|
||||
LAN_IP=$(uci -q get network.lan.ipaddr)
|
||||
SERVER_IP=$(echo $LAN_IP | cut -d . -f 1,2,3).0
|
||||
INTERNAL_NETMASK="$SERVER_IP/24"
|
||||
|
||||
# create the ACCOUNTING chains
|
||||
iptables -w -N ACCOUNTING_BLOCK 2> /dev/null
|
||||
iptables -w -N ACCOUNTING_IN 2> /dev/null
|
||||
iptables -w -N ACCOUNTING_OUT 2> /dev/null
|
||||
check=0
|
||||
# check if accounting rule for ethernet wan not exist, add it
|
||||
checks=$(iptables -w -L FORWARD -v -n | grep "ACCOUNTING" | grep "$WAN_IFACE")
|
||||
[ -z "$checks" ] && check=1
|
||||
|
||||
# check if jumps to the ACCOUNTING chains are still at the start of the FORWARD chain
|
||||
iptables -w -L FORWARD --line-numbers -n | grep "ACCOUNTING" | grep "^1 "
|
||||
if [ $? -ne 0 -o "$check" = "1" ]; then
|
||||
# remove old jump rules
|
||||
iptables -w -D FORWARD $(iptables -w -L FORWARD --line-numbers | grep ACCOUNTING | grep -m 1 -o "[0-9]*")
|
||||
while [ $? -eq 0 ]; do
|
||||
iptables -w -D FORWARD $(iptables -w -L FORWARD --line-numbers | grep ACCOUNTING | grep -m 1 -o "[0-9]*")
|
||||
done
|
||||
# insert new jump rules at start of FORWARD chain
|
||||
if [ -n "$WAN_IFACE" ]
|
||||
then
|
||||
iptables -w -I FORWARD -i ${WAN_IFACE} -j ACCOUNTING_IN
|
||||
iptables -w -I FORWARD -o ${WAN_IFACE} -j ACCOUNTING_OUT
|
||||
fi
|
||||
iptables -w -I FORWARD -j ACCOUNTING_BLOCK
|
||||
fi
|
||||
|
||||
#For each host in the ARP table
|
||||
grep ${LAN_IFACE} /proc/net/arp | while read IP TYPE FLAGS MAC MASK IFACE
|
||||
do
|
||||
#Add iptables rules (if non existing).
|
||||
iptables -w -nL ACCOUNTING_IN | grep "${IP} " > /dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
iptables -w -I ACCOUNTING_IN -d ${IP} -s ${INTERNAL_NETMASK} -j RETURN
|
||||
iptables -w -I ACCOUNTING_IN -d ${IP} ! -s ${INTERNAL_NETMASK} -j RETURN
|
||||
fi
|
||||
|
||||
iptables -w -nL ACCOUNTING_OUT | grep "${IP} " > /dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
iptables -w -I ACCOUNTING_OUT -s ${IP} -d ${INTERNAL_NETMASK} -j RETURN
|
||||
iptables -w -I ACCOUNTING_OUT -s ${IP} ! -d ${INTERNAL_NETMASK} -j RETURN
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
setup()
|
||||
{
|
||||
for chain in $chains; do
|
||||
newChain $chain
|
||||
done
|
||||
|
||||
wan=$(detectWAN)
|
||||
checkWAN
|
||||
wan1=$(detectIF wan1)
|
||||
wan2=$(detectIF wan2)
|
||||
C1=$(uci -q get modem.modem1.connected)
|
||||
C2=$(uci -q get modem.modem2.connected)$C1
|
||||
if [ ! -z $C2 ]; then
|
||||
interfaces="$wan1 $wan2"
|
||||
WW=$(uci -q get bwmon.bwwan.wan)
|
||||
if [ "$WW" = "1" ]; then
|
||||
interfaces=$interfaces $wan" wwan"
|
||||
fi
|
||||
else
|
||||
WW=$(uci -q get bwmon.bwwan.wan)
|
||||
if [ "$WW" = "1" ]; then
|
||||
interfaces="$wan wwan"
|
||||
else
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
||||
# track local data
|
||||
for chain in INPUT OUTPUT; do
|
||||
for interface in $interfaces; do
|
||||
[ -n "$interface" ] && [ -e "/sys/class/net/$interface" ] && newRuleIF $chain $interface
|
||||
#if [ -e /etc/bwlock ]; then
|
||||
accounting $interface
|
||||
#fi
|
||||
done
|
||||
done
|
||||
|
||||
# this will add rules for hosts in arp table
|
||||
update $dailyUsageDB
|
||||
|
||||
rm -f /tmp/*_$$.tmp
|
||||
}
|
||||
|
||||
update()
|
||||
{
|
||||
createDbIfMissing
|
||||
checkWAN
|
||||
PERTOTAL=0
|
||||
|
||||
> /tmp/iptables_$$.tmp
|
||||
lock
|
||||
# only zero our own chains
|
||||
for chain in $chains; do
|
||||
iptables -nvxL RRDIPT_$chain -t mangle -Z >> /tmp/iptables_$$.tmp
|
||||
done
|
||||
# the iptables and readDB commands have to be separate. Otherwise,
|
||||
# they will fight over iptables locks
|
||||
awk -v mode="$mode" -v interfaces=\""$interfaces"\" -f $binDir/readDB.awk \
|
||||
$DB \
|
||||
/proc/net/arp \
|
||||
/tmp/iptables_$$.tmp
|
||||
|
||||
while read L1
|
||||
do
|
||||
MAC=$(echo ${L1} | cut -f1 -d, )
|
||||
if [ $MAC != "#mac" ]; then
|
||||
MAC=$(echo ${L1} | cut -f1 -d, )
|
||||
IP=$(echo ${L1} | cut -f2 -d, )
|
||||
IN=$(echo ${L1} | cut -f4 -d, )
|
||||
IN=$((${IN}/1000))
|
||||
OUT=$(echo ${L1} | cut -f5 -d, )
|
||||
OUT=$((${OUT}/1000))
|
||||
TOTAL=$(echo ${L1} | cut -f6 -d, )
|
||||
TOTAL=$((${TOTAL}/1000))
|
||||
let PERTOTAL=PERTOTAL+TOTAL
|
||||
if [ $TOTAL -gt 0 -a $IP != "NA" ]; then
|
||||
for USERSFILE in /tmp/dhcp.leases /tmp/dnsmasq.conf /etc/dnsmasq.conf /etc/hosts; do
|
||||
[ -e "$USERSFILE" ] || continue
|
||||
case $USERSFILE in
|
||||
/tmp/dhcp.leases )
|
||||
NAME=$(grep -i "$MAC" $USERSFILE | cut -f4 -s -d' ')
|
||||
;;
|
||||
/etc/hosts )
|
||||
NAME=$(grep "^$IP " $USERSFILE | cut -f2 -s -d' ')
|
||||
;;
|
||||
* )
|
||||
NAME=$(grep -i "$MAC" "$USERSFILE" | cut -f2 -s -d,)
|
||||
;;
|
||||
esac
|
||||
[ "$NAME" = "*" ] && NAME=
|
||||
[ -n "$NAME" ] && break
|
||||
done
|
||||
if [ -z $NAME ]; then
|
||||
NAME="*"
|
||||
fi
|
||||
|
||||
echo "\"mac\":\""${MAC}"\"","\"down\":\""${IN}"\"","\"up\":\""${OUT}"\"","\"offdown\":\""0"\"","\"offup\":\""0"\"","\"ip\":\""${IP}"\"","\"name\":\""${NAME}"\"" >> ${1}
|
||||
fi
|
||||
fi
|
||||
done < $DB
|
||||
if [ -e /usr/lib/bwmon/period.sh ]; then
|
||||
/usr/lib/bwmon/period.sh "$PERTOTAL"
|
||||
fi
|
||||
unlock
|
||||
}
|
||||
|
||||
|
||||
createFiles()
|
||||
{
|
||||
while [ -e /tmp/lockbw ]; do
|
||||
sleep 1
|
||||
done
|
||||
echo "0" > /tmp/lockbw
|
||||
while [ ! -e $backPath*"mac_data.js" ]; do
|
||||
valid=$(cat /var/state/dnsmasqsec)
|
||||
st=$(echo "$valid" | grep "ntpd says time is valid")
|
||||
if [ ! -z "$st" ]; then
|
||||
break
|
||||
fi
|
||||
sleep 10
|
||||
done
|
||||
dailyUsageDB="$dataPath$cYear-$cMonth-$cDay-daily_data.js"
|
||||
dailyUsageBack="$backPath$cYear-$cMonth-$cDay-daily_data.js"
|
||||
if [ ! -f $dailyUsageBack ]; then
|
||||
rm -f $backPath*"daily_data.js"
|
||||
touch $dailyUsageDB
|
||||
touch $dailyUsageBack
|
||||
else
|
||||
cp -f $dailyUsageBack $dailyUsageDB
|
||||
fi
|
||||
monthlyUsageDB="$dataPath$cYear-$cMonth-mac_data.js"
|
||||
monthlyUsageBack="$backPath$cYear-$cMonth-mac_data.js"
|
||||
if [ -f $monthlyUsageBack ]; then
|
||||
cp -f $monthlyUsageBack $monthlyUsageDB".bk"
|
||||
sed "/start day $cDay/,/end day $cDay/d" $monthlyUsageDB".bk" > $monthlyUsageDB
|
||||
cp -f $monthlyUsageBack $monthlyUsageDB".bk"
|
||||
else
|
||||
rm -f $backPath*"mac_data.js"
|
||||
touch $monthlyUsageDB
|
||||
touch $monthlyUsageBack
|
||||
/usr/lib/bwmon/backup.sh "backup" $cDay $monthlyUsageDB $dailyUsageDB $monthlyUsageBack $dailyUsageBack
|
||||
fi
|
||||
rm -f /tmp/lockbw
|
||||
}
|
||||
|
||||
shutDown()
|
||||
{
|
||||
while [ -e /tmplockbw ]; do
|
||||
sleep 1
|
||||
done
|
||||
echo "0" > /tmp/lockbw
|
||||
/usr/lib/bwmon/backup.sh "backup" $cDay $monthlyUsageDB $dailyUsageDB $monthlyUsageBack $dailyUsageBack
|
||||
lua /usr/lib/bwmon/cleanup.lua
|
||||
rm -f /tmp/lockbw
|
||||
}
|
||||
|
||||
checkSetup()
|
||||
{
|
||||
CURRTIME=$(date +%s)
|
||||
let ELAPSE=CURRTIME-STARTIMEX
|
||||
if [ $ELAPSE -gt $setup_time ]; then
|
||||
STARTIMEX=$CURRTIME
|
||||
setup
|
||||
/usr/lib/bwmon/backup.sh "setup" $cDay $monthlyUsageDB $dailyUsageDB $monthlyUsageBack $dailyUsageBack
|
||||
fi
|
||||
}
|
||||
|
||||
checkUpdate()
|
||||
{
|
||||
CURRTIME=$(date +%s)
|
||||
let ELAPSE=CURRTIME-STARTIMEY
|
||||
if [ $ELAPSE -gt $update_time ]; then
|
||||
STARTIMEY=$CURRTIME
|
||||
update $dailyUsageDB $unlimited
|
||||
fi
|
||||
}
|
||||
|
||||
checkBackup()
|
||||
{
|
||||
CURRTIME=$(date +%s)
|
||||
let ELAPSE=CURRTIME-STARTIMEZ
|
||||
bs=$(uci -q get bwmon.general.backup)
|
||||
let "bs=$bs*60"
|
||||
backup_time=$bs
|
||||
if [ $ELAPSE -gt $backup_time ]; then
|
||||
STARTIMEZ=$CURRTIME
|
||||
shutDown
|
||||
fi
|
||||
}
|
||||
|
||||
checkTime()
|
||||
{
|
||||
while [ -e /tmplockbw ]; do
|
||||
sleep 1
|
||||
done
|
||||
echo "0" > /tmp/lockbw
|
||||
pDay=$(date +%d)
|
||||
pYear=$(date +%Y)
|
||||
pMonth=$(date +%m)
|
||||
if [ "$cDay" -ne "$pDay" ]; then
|
||||
/usr/lib/bwmon/backup.sh "daily" $cDay $monthlyUsageDB $dailyUsageDB $monthlyUsageBack $dailyUsageBack
|
||||
|
||||
cDay=$pDay
|
||||
cMonth=$pMonth
|
||||
cYear=$pYear
|
||||
monthlyUsageBack="$backPath$cYear-$cMonth-mac_data.js"
|
||||
if [ ! -e $monthlyUsageBack ]; then
|
||||
rm -f $backPath*"mac_data.js"
|
||||
fi
|
||||
rm -f $dataPath[[:digit:]][[:digit:]][[:digit:]][[:digit:]]"-"[[:digit:]][[:digit:]]"-"[[:digit:]][[:digit:]]-daily_data.js
|
||||
rm -f $backPath[[:digit:]][[:digit:]][[:digit:]][[:digit:]]"-"[[:digit:]][[:digit:]]"-"[[:digit:]][[:digit:]]-daily_data.js
|
||||
roll=$(uci -q get custom.bwallocate.rollover)
|
||||
[ -z $roll ] && roll=1
|
||||
if [ "$roll" -eq "$pDay" ]; then
|
||||
rm -f $monthlyUsageDB
|
||||
rm -f $backPath*"mac_data.js"
|
||||
monthlyUsageDB="$dataPath$cYear-$cMonth-mac_data.js"
|
||||
monthlyUsageBack="$backPath$cYear-$cMonth-mac_data.js"
|
||||
touch $monthlyUsageDB
|
||||
uci set custom.texting.used='0'
|
||||
uci commit custom
|
||||
if [ -e /usr/lib/bwmon/periodreset.sh ]; then
|
||||
/usr/lib/bwmon/periodreset.sh
|
||||
fi
|
||||
fi
|
||||
rm -f $dailyUsageDB
|
||||
rm -f $backPath*"daily_data.js"
|
||||
dailyUsageDB="$dataPath$cYear-$cMonth-$cDay-daily_data.js"
|
||||
touch $dailyUsageDB
|
||||
dailyUsageBack="$backPath$cYear-$cMonth-$cDay-daily_data.js"
|
||||
fi
|
||||
rm -f /tmp/lockbw
|
||||
}
|
||||
|
||||
createFiles
|
||||
setup
|
||||
while [ -d $lockDir ]; do
|
||||
checkSetup
|
||||
checkTime
|
||||
checkBackup
|
||||
n=0
|
||||
while [ true ] ; do
|
||||
n=$(($n + 1))
|
||||
if [ ! -d "$lockDir" ]; then
|
||||
shutDown
|
||||
exit 0
|
||||
fi
|
||||
[ "$n" -gt "$pause" ] && break;
|
||||
sleep 1
|
||||
done
|
||||
done
|
@ -51,6 +51,23 @@ function action_check_bw()
|
||||
end
|
||||
end
|
||||
file:close()
|
||||
os.execute("/usr/lib/bwmon/genline.sh")
|
||||
file = io.open("/tmp/monlist", "r")
|
||||
if file ~= nil then
|
||||
line = file:read("*all")
|
||||
rv["genline"] = line
|
||||
file:close()
|
||||
file = io.open("/tmp/montot", "r")
|
||||
if file ~= nil then
|
||||
rv['gendays'] = file:read("*line")
|
||||
rv['gendwn'] = file:read("*line")
|
||||
rv['genupn'] = file:read("*line")
|
||||
rv['gentotal'] = file:read("*line")
|
||||
file:close()
|
||||
end
|
||||
else
|
||||
rv['gendays'] = '0'
|
||||
end
|
||||
else
|
||||
rv['days'] = 0
|
||||
end
|
||||
|
@ -60,25 +60,10 @@ var backflg = "0";
|
||||
document.getElementById("allocatet").style.display="";
|
||||
document.getElementById("bwenb").disabled=true;
|
||||
document.getElementById("bwinter").disabled=true;
|
||||
document.getElementById("apply2").disabled=true;
|
||||
document.getElementById("bwflag").disabled=true;
|
||||
bwe = true;
|
||||
if ( backflg == "0" )
|
||||
{
|
||||
if ( rv.external == "0" )
|
||||
{
|
||||
bwe = false
|
||||
document.getElementById("exflag").innerHTML="<%:Internal%>";
|
||||
document.getElementById("exflag").style.fontWeight = "bold" ;
|
||||
document.getElementById("exflag").style.fontSize = "large" ;
|
||||
}
|
||||
else
|
||||
{
|
||||
document.getElementById("exflag").innerHTML=rv.external;
|
||||
document.getElementById("exflag").style.fontWeight = "bold" ;
|
||||
document.getElementById("exflag").style.fontSize = "small" ;
|
||||
}
|
||||
//if ( backflg == "0" )
|
||||
//{
|
||||
document.getElementById("bwinter").value = rv.backup;
|
||||
backflg = "1";
|
||||
}
|
||||
@ -113,25 +98,10 @@ var backflg = "0";
|
||||
document.getElementById("allocatet").style.display="none";
|
||||
document.getElementById("bwenb").disabled=false;
|
||||
document.getElementById("bwinter").disabled=false;
|
||||
document.getElementById("apply2").disabled=false;
|
||||
document.getElementById("bwflag").disabled=false;
|
||||
bwe = true;
|
||||
if ( backflg == "0" )
|
||||
{
|
||||
if ( rv.external == "0" )
|
||||
{
|
||||
bwe = false
|
||||
document.getElementById("exflag").innerHTML="<%:Internal%>";
|
||||
document.getElementById("exflag").style.fontWeight = "bold" ;
|
||||
document.getElementById("exflag").style.fontSize = "large" ;
|
||||
}
|
||||
else
|
||||
{
|
||||
document.getElementById("exflag").innerHTML=rv.external;
|
||||
document.getElementById("exflag").style.fontWeight = "bold" ;
|
||||
document.getElementById("exflag").style.fontSize = "small" ;
|
||||
}
|
||||
//if ( backflg == "0" )
|
||||
//{
|
||||
document.getElementById("bwinter").value = rv.backup;
|
||||
backflg = "1";
|
||||
}
|
||||
@ -177,42 +147,6 @@ var backflg = "0";
|
||||
|
||||
document.getElementById("password").value=rv.password;
|
||||
|
||||
var tbl = document.getElementById('datar');
|
||||
while (tbl.rows.length > 1)
|
||||
tbl.deleteRow(1);
|
||||
|
||||
msize = rv.macsize;
|
||||
maclist = rv.maclist;
|
||||
if ( msize !== "0" )
|
||||
{
|
||||
size = parseFloat(msize);
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
partsArray = maclist[i].split('|');
|
||||
tr = tbl.insertRow(-1);
|
||||
row3 = tr.insertCell(-1);
|
||||
row3.innerHTML = '<div align="center"><strong>' + partsArray[0] + '</strong></div>'
|
||||
row3.style.width = '160px' ;
|
||||
row3 = tr.insertCell(-1);
|
||||
row3.innerHTML = '<div align="center"><strong>' + partsArray[5] + '</strong></div>'
|
||||
row3.style.width = '200px' ;
|
||||
row3 = tr.insertCell(-1);
|
||||
row3.innerHTML = '<div align="center"><strong>' + partsArray[1] + '</strong></div>'
|
||||
row3.style.width = '160px' ;
|
||||
row3 = tr.insertCell(-1);
|
||||
row3.innerHTML = '<div align="center"><strong>' + partsArray[2] + '</strong></div>'
|
||||
row3.style.width = '150px' ;
|
||||
row3 = tr.insertCell(-1);
|
||||
row3.innerHTML = '<div align="center"><strong>' + partsArray[3] + '</strong></div>'
|
||||
row3.style.width = '150px' ;
|
||||
row3 = tr.insertCell(-1);
|
||||
row3.innerHTML = '<div align="center"><strong>' + partsArray[4] + '</strong></div>'
|
||||
row3.style.width = '150px' ;
|
||||
}
|
||||
}
|
||||
|
||||
document.getElementById("datar").style.display = "";
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -226,6 +160,23 @@ var backflg = "0";
|
||||
document.getElementById("report").style.visibility="hidden";
|
||||
document.getElementById("report").style.display="none";
|
||||
}
|
||||
|
||||
|
||||
gendays = rv.gendays;
|
||||
if ( gendays != '0' )
|
||||
{
|
||||
genline = rv.genline;
|
||||
gendwn = rv.gendwn;
|
||||
genup = rv.genupn
|
||||
gentotal = rv.gentotal
|
||||
document.getElementById("datar2").innerHTML=genline;
|
||||
document.getElementById("stdate").innerHTML="<strong>" + gendays + "</strong>";
|
||||
document.getElementById("bdwn").innerHTML="<strong>" + gentotal + "</strong>";
|
||||
}
|
||||
else
|
||||
{
|
||||
document.getElementById("stdate").innerHTML="<strong>" + "No Data" + "</strong>";
|
||||
}
|
||||
}
|
||||
|
||||
XHR.get('<%=luci.dispatcher.build_url("admin", "nlbw", "check_bw")%>',
|
||||
@ -245,51 +196,9 @@ var backflg = "0";
|
||||
|
||||
);
|
||||
|
||||
function done() {
|
||||
document.getElementById("popup").style.display = "none";
|
||||
document.getElementById("apply2").disabled=true;
|
||||
var r = document.getElementById("pass").value;
|
||||
if ( r == "" )
|
||||
{
|
||||
document.getElementById("exflag").innerHTML="<%:Internal%>";
|
||||
document.getElementById("exflag").style.fontWeight = "bold" ;
|
||||
document.getElementById("exflag").style.fontSize = "large" ;
|
||||
r = "0";
|
||||
}
|
||||
else
|
||||
{
|
||||
mnti = r.indexOf("/mnt/");
|
||||
mntl = r.length;
|
||||
if ( mnti == -1 || mntl < 6 )
|
||||
{
|
||||
alert("<%:Invalid External Path. Reverting to Internal.%>");
|
||||
r = "0";
|
||||
document.getElementById("exflag").innerHTML="<%:Internal%>";
|
||||
document.getElementById("exflag").style.fontWeight = "bold" ;
|
||||
document.getElementById("exflag").style.fontSize = "large" ;
|
||||
}
|
||||
else
|
||||
{
|
||||
document.getElementById("exflag").innerHTML=r;
|
||||
document.getElementById("exflag").style.fontWeight = "bold" ;
|
||||
document.getElementById("exflag").style.fontSize = "small" ;
|
||||
}
|
||||
}
|
||||
XHR.get('<%=luci.dispatcher.build_url("admin", "nlbw", "change_external")%>',
|
||||
{ set: r },
|
||||
function()
|
||||
{
|
||||
}
|
||||
);
|
||||
document.getElementById("pass").value="";
|
||||
document.getElementById("apply2").disabled=false;
|
||||
return false;
|
||||
};
|
||||
|
||||
function unlock(btn)
|
||||
{
|
||||
document.getElementById("popup").style.display = "block";
|
||||
document.getElementById("apply2").disabled=true;
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -421,6 +330,8 @@ var backflg = "0";
|
||||
display:none;
|
||||
}
|
||||
</style>
|
||||
<link rel="stylesheet" href="rooter/css/iconmoon_splash.css">
|
||||
<link rel="stylesheet" href="rooter/css/splash.css">
|
||||
</head>
|
||||
<fieldset class="cbi-section" id="cbi-modw">
|
||||
<legend><%:Extra Internet Sources%></legend>
|
||||
@ -483,11 +394,6 @@ var backflg = "0";
|
||||
<td></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><div align="right" style="font-size : 17px" id="externalbw"><strong><%:Backup Storage Location%></strong></div></td>
|
||||
<td><div align="center" id="exflag" ></div></td>
|
||||
<td><input type="button" id="apply2" class="cbi-button cbi-button-apply" value="<%:Change Location%>" onclick="return unlock(this)" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</fieldset>
|
||||
@ -588,18 +494,41 @@ var backflg = "0";
|
||||
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="cbi-section" id="cbi-mod">
|
||||
<table width="1400" border="1" id="datar1" >
|
||||
<fieldset>
|
||||
<h2> Last 30 Day Bandwidth Usage <span class="msCell"><span></span></span></h2>
|
||||
<style>
|
||||
hr {
|
||||
border: 0;
|
||||
border-top: 2px solid brown;
|
||||
}
|
||||
</style>
|
||||
<table width="1000" border="0" id="datar1" >
|
||||
<tr>
|
||||
<td width="160px"><div align="center"><strong><%:IP Address%></strong></div></td>
|
||||
<td width="200px"><div align="center"><strong><%:Name%></strong></div></td>
|
||||
<td width="160px"><div align="center"><strong><%:MAC Address%></strong></div></td>
|
||||
<td width="150px"><div align="center"><strong><%:Bandwidth Down%></strong></div></td>
|
||||
<td width="150px"><div align="center"><strong><%:Bandwidth Up%></strong></div></td>
|
||||
<td width="150px"><div align="center"><strong><%:Bandwidth Total%></strong></div></td>
|
||||
<td width="160px" style="font-size : 17px"><div align="center"><strong><%:Days in Period%></strong></div></td>
|
||||
<td width="200px" style="font-size : 17px"><div align="center"><strong><%:Bandwidth Used%></strong></div></td>
|
||||
<td width="150px" style="font-size : 17px"><div align="center"><strong><%:%></strong></div></td>
|
||||
<td width="150px" style="font-size : 17px"><div align="center"><strong><%:%></strong></div></td>
|
||||
<td width="340" ></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><div align="center" id="stdate"></div></td>
|
||||
<td><div align="center" id="bdwn"></div></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
||||
<table width="1400" border="0" id="datar" >
|
||||
<br />
|
||||
<table width="1000" border="0" id="datar" >
|
||||
<tr>
|
||||
<td width="160px" style="font-size : 17px"><div align="center"><strong><%:Date%></strong></div></td>
|
||||
<td width="200px" style="font-size : 17px"><div align="center"><strong><%:Bandwidth Down%></strong></div></td>
|
||||
<td width="150px" style="font-size : 17px"><div align="center"><strong><%:Bandwidth Up%></strong></div></td>
|
||||
<td width="150px" style="font-size : 17px"><div align="center"><strong><%:Bandwidth Total%></strong></div></td>
|
||||
<td width="340" ></td>
|
||||
</tr>
|
||||
</table>
|
||||
<table width="1000" border="0" id="datar2" >
|
||||
<tr>
|
||||
</tr>
|
||||
</table>
|
||||
|
@ -21,10 +21,10 @@
|
||||
<div class="cbi-map-descr"><%:A Speed Test using OpenSpeedTest that runs in the browser%></div>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<link rel="stylesheet" href="/luci-static/speed/css/iconmoon_splash.css">
|
||||
<link rel="stylesheet" href="/luci-static/speed/css/splash.css">
|
||||
<link rel="SHORTCUT ICON" href="/luci-static/speed/img/favicon.gif">
|
||||
<link rel="icon" type="image/gif" href="/luci-static/speed/img/favicon.gif">
|
||||
<link rel="stylesheet" href="/luci-static/rooter/css/iconmoon_splash.css">
|
||||
<link rel="stylesheet" href="/luci-static/rooter/css/speed.css">
|
||||
<link rel="SHORTCUT ICON" href="/luci-static/rooter/img/favicon.gif">
|
||||
<link rel="icon" type="image/gif" href="/luci-static/rooter/img/favicon.gif">
|
||||
</head>
|
||||
|
||||
<body style="background-color: LightSteelBlue">
|
||||
|
@ -84,4 +84,9 @@ start() {
|
||||
|
||||
config_load wireguard
|
||||
config_foreach chk_start wireguard
|
||||
if [ -e /etc/crontabs/root ]; then
|
||||
sed -i '/wireguard_watchdog/d' /etc/crontabs/root
|
||||
fi
|
||||
echo '* * * * * /usr/bin/wireguard_watchdog' >> /etc/crontabs/root
|
||||
/etc/init.d/cron restart
|
||||
}
|
@ -59,6 +59,11 @@ pkey = s:option(Value, "privatekey", translate("Private Key :"), translate("Priv
|
||||
pkey.rmempty = true;
|
||||
pkey.optional=false;
|
||||
|
||||
il = s:option(ListValue, "wginter", translate("Interface to Use :"));
|
||||
il:value("0", translate("WG0"))
|
||||
il:value("1", translate("WG1"))
|
||||
il.default="0"
|
||||
|
||||
bl = s:option(ListValue, "auto", translate("Start on Boot :"));
|
||||
bl:value("0", translate("No"))
|
||||
bl:value("1", translate("Yes"))
|
||||
|
@ -40,10 +40,14 @@
|
||||
|
||||
XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "vpn", "wirestatus")%>', null,
|
||||
function(x, data) {
|
||||
both = {};
|
||||
bothbp={};
|
||||
iii = 1;
|
||||
for (var key in data) {
|
||||
if (!data.hasOwnProperty(key)) { continue; }
|
||||
var ifname = key;
|
||||
var iface = data[key];
|
||||
|
||||
var s = "";
|
||||
if (iface.public_key == '(none)') {
|
||||
s += '<em><%:Interface does not have a public key!%></em>';
|
||||
@ -65,7 +69,16 @@
|
||||
iface.fwmark
|
||||
);
|
||||
}
|
||||
if ( iii == 1 )
|
||||
{
|
||||
document.getElementById("iinfo").innerHTML = s;
|
||||
document.getElementById("leg").innerHTML = ifname;
|
||||
}
|
||||
else
|
||||
{
|
||||
document.getElementById("iinfo1").innerHTML = s;
|
||||
document.getElementById("leg1").innerHTML = ifname;
|
||||
}
|
||||
for (var i = 0, ilen = iface.peers.length; i < ilen; i++) {
|
||||
var peer = iface.peers[i];
|
||||
var s = String.format(
|
||||
@ -105,9 +118,18 @@
|
||||
bytes_to_str(peer.transfer_rx),
|
||||
bytes_to_str(peer.transfer_tx)
|
||||
);
|
||||
if ( iii == 1 )
|
||||
{
|
||||
document.getElementById("config").innerHTML = icon;
|
||||
document.getElementById("info").innerHTML = s;
|
||||
}
|
||||
else
|
||||
{
|
||||
document.getElementById("config1").innerHTML = icon;
|
||||
document.getElementById("info1").innerHTML = s;
|
||||
}
|
||||
}
|
||||
iii = iii + 1;
|
||||
}
|
||||
});
|
||||
//]]></script>
|
||||
@ -116,9 +138,16 @@
|
||||
|
||||
<fieldset class="cbi-section">
|
||||
|
||||
<legend><%:Interface%> WG0</legend>
|
||||
|
||||
<div>
|
||||
<table width="900" border="0">
|
||||
<tr>
|
||||
<td width="50px" style="vertical-align:center;font-size : 25px">
|
||||
<div><%:Interface %></div>
|
||||
</td>
|
||||
<td width="100px" id="leg" style="width:100px; text-align:left; padding:3px;font-size : 25px"> </td>
|
||||
<td width="650px"> </td>
|
||||
</tr>
|
||||
</table>
|
||||
<table width="900" border="0">
|
||||
<tr>
|
||||
<td width="20px"> </td>
|
||||
@ -147,6 +176,52 @@
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table width="900" border="0" id="second1">
|
||||
<tr>
|
||||
<td width="50px" style="vertical-align:center;font-size : 25px">
|
||||
<div><%:Interface %></div>
|
||||
</td>
|
||||
<td width="100px" id="leg1" style="width:100px; text-align:left; padding:3px;font-size : 25px"> </td>
|
||||
<td width="650px"> </td>
|
||||
</tr>
|
||||
</table>
|
||||
<table width="900" border="0" id="second">
|
||||
<tr>
|
||||
<td width="20px"> </td>
|
||||
<td width="150px" style="vertical-align:center;font-size : 20px">
|
||||
<div><%:Configuration%></div>
|
||||
</td>
|
||||
<td width="100px" id="config1" style="width:16px; text-align:center; padding:3px"> </td>
|
||||
<td width="50px"> </td>
|
||||
<td width="580px">
|
||||
<div id="info1" style="vertical-align:middle; padding: 3px">
|
||||
<em><%:Collecting data...%></em>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td style="vertical-align:center;font-size : 20px">
|
||||
<div><%:Peer%></div>
|
||||
</td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
<td>
|
||||
<div id="iinfo1" style="vertical-align:middle; padding: 3px">
|
||||
<em><%:Collecting data...%></em>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<!--
|
||||
<table id="cmdtxt" width="700" border="0" style="display:table;">
|
||||
<tr>
|
||||
<td width="100%">
|
||||
<textarea readonly="readonly" name="attxt" id="attxt" rows="6" style="width: 600px;" maxlength="160"></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
</table> -->
|
||||
</div>
|
||||
|
||||
</fieldset>
|
||||
|
@ -1,5 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
log() {
|
||||
modlog "Wireguard Conf" "$@"
|
||||
}
|
||||
|
||||
name=$1
|
||||
file=$2
|
||||
auto=$3
|
||||
@ -25,6 +29,13 @@ extract() {
|
||||
if [ ! -z "$PRK" ]; then
|
||||
PreSharedKey=$(echo $PRK | cut -d, -f3)
|
||||
fi
|
||||
INTER=$(echo "$line" | grep "WGinterface" | tr " " ",")
|
||||
if [ ! -z "$INTER" ]; then
|
||||
wginter=$(echo $INTER | cut -d, -f3)
|
||||
if [ "$wginter" -gt 1 ]; then
|
||||
wginter="1"
|
||||
fi
|
||||
fi
|
||||
PRK=$(echo "$line" | grep "Address" | tr " " "#")
|
||||
if [ ! -z "$PRK" ]; then
|
||||
if [ -z $Address ]; then
|
||||
@ -73,6 +84,8 @@ sed -i -e "s!PresharedKey= !PresharedKey=!g" $file
|
||||
sed -i -e "s!PresharedKey=!PresharedKey = !g" $file
|
||||
sed -i -e "s!Address= !Address=!g" $file
|
||||
sed -i -e "s!Address=!Address = !g" $file
|
||||
sed -i -e "s!WGinterface=!WGinterface = !g" $file
|
||||
sed -i -e "s!WGinterface= !WGinterface = !g" $file
|
||||
sed -i -e "s!dns= !dns=!g" $file
|
||||
sed -i -e "s!dns=!dns = !g" $file
|
||||
sed -i -e "s!DNS= !DNS=!g" $file
|
||||
@ -94,7 +107,9 @@ extract "$linex"
|
||||
PRK=$(echo "$endpoint" | tr ":" ",")
|
||||
endpoint=$(echo $PRK | cut -d, -f1)
|
||||
sport=$(echo $PRK | cut -d, -f2)
|
||||
|
||||
if [ -z "$wginter" ]; then
|
||||
wginter="0"
|
||||
fi
|
||||
uci delete wireguard.$name
|
||||
uci set wireguard.$name=wireguard
|
||||
uci set wireguard.$name.auto=$auto
|
||||
@ -105,6 +120,7 @@ uci set wireguard.$name.presharedkey="$PreSharedKey"
|
||||
uci set wireguard.$name.port="$listenport"
|
||||
uci set wireguard.$name.addresses="$Address"
|
||||
uci set wireguard.$name.dns="$dns"
|
||||
uci set wireguard.$name.wginter="$wginter"
|
||||
uci set wireguard.$name.publickey="$PublicKey"
|
||||
uci set wireguard.$name.endpoint_host="$endpoint"
|
||||
uci set wireguard.$name.ips="$allowedips"
|
||||
|
@ -33,6 +33,11 @@ do_create() {
|
||||
if [ ! -z $mtu ]; then
|
||||
echo "MTU = "$mtu >> ${PKI_DIR}/package/wg.conf
|
||||
fi
|
||||
config_get wginter $config wginter
|
||||
if [ -z"$wginter"]; then
|
||||
wginter=0
|
||||
fi
|
||||
echo "PrivateKey = "$wginter >> ${PKI_DIR}/package/wg.conf
|
||||
echo " " >> ${PKI_DIR}/package/wg.conf
|
||||
echo "[Peer]" >> ${PKI_DIR}/package/wg.conf
|
||||
PUB=$(uci get wireguard."$WG".publickey)
|
||||
|
@ -20,11 +20,12 @@ chk_zone() {
|
||||
|
||||
do_dns() {
|
||||
cdns=$1
|
||||
ldns=$(uci -q get network.wg0.dns)
|
||||
local ifce=$2
|
||||
ldns=$(uci -q get network.wg$ifce.dns)
|
||||
ex=$(echo "$ldns" | grep "$cdns")
|
||||
if [ -z $ex ]; then
|
||||
log "Add DNS $cdns to WG0"
|
||||
uci add_list network.wg0.dns="$cdns"
|
||||
log "Add DNS $cdns to WG$ifce"
|
||||
uci add_list network.wg$ifce.dns="$cdns"
|
||||
uci commit network
|
||||
/etc/init.d/network reload
|
||||
fi
|
||||
@ -87,8 +88,9 @@ create_speer() {
|
||||
|
||||
create_cpeer() {
|
||||
local config=$1
|
||||
local ifce=$2
|
||||
|
||||
uci set network.$config="wireguard_wg0"
|
||||
uci set network.$config="wireguard_wg$ifce"
|
||||
|
||||
publickey=$(uci -q get wireguard."$config".publickey)
|
||||
uci set network.$config.public_key="$publickey"
|
||||
@ -176,50 +178,51 @@ handle_server() {
|
||||
}
|
||||
|
||||
handle_client() {
|
||||
config_foreach do_delete wireguard_wg0
|
||||
ifce=$1
|
||||
config_foreach do_delete wireguard_wg$ifce
|
||||
|
||||
uci delete network.wg0
|
||||
uci set network.wg0="interface"
|
||||
uci set network.wg0.proto="wireguard"
|
||||
uci delete network.wg$ifce
|
||||
uci set network.wg$ifce="interface"
|
||||
uci set network.wg$ifce.proto="wireguard"
|
||||
|
||||
auto=$(uci -q get wireguard."$WG".auto)
|
||||
if [ -z $auto ]; then
|
||||
auto="0"
|
||||
fi
|
||||
uci set network.wg0.auto="$auto"
|
||||
uci set network.wg$ifce.auto="$auto"
|
||||
mtu=$(uci -q get wireguard."$WG".mtu)
|
||||
if [ ! -z $mtu ]; then
|
||||
uci set network.wg0.mtu="$mtu"
|
||||
uci set network.wg$ifce.mtu="$mtu"
|
||||
fi
|
||||
dns=$(uci -q get wireguard."$WG".dns)
|
||||
if [ ! -z $dns ]; then
|
||||
do_dns $dns
|
||||
do_dns $dns $ifce
|
||||
fi
|
||||
port=$(uci -q get wireguard."$WG".port)
|
||||
if [ -z $port ]; then
|
||||
port="51280"
|
||||
fi
|
||||
uci set network.wg0.listen_port="$port"
|
||||
uci set network.wg$ifce.listen_port="$port"
|
||||
do_port $port udp
|
||||
|
||||
privatekey=$(uci -q get wireguard."$WG".privatekey)
|
||||
uci set network.wg0.private_key="$privatekey"
|
||||
uci set network.wg$ifce.private_key="$privatekey"
|
||||
|
||||
ips=$(uci -q get wireguard."$WG".addresses)","
|
||||
cips=$(echo $ips | cut -d, -f1)
|
||||
i=1
|
||||
while [ ! -z "$cips" ]
|
||||
do
|
||||
uci add_list network.wg0.addresses="$cips"
|
||||
uci add_list network.wg$ifce.addresses="$cips"
|
||||
i=$((i+1))
|
||||
cips=$(echo "$ips" | cut -d, -f"$i")
|
||||
if [ -z "$cips" ]; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
uci add_list network.wg0.addresses="::/0"
|
||||
uci add_list network.wg$ifce.addresses="::/0"
|
||||
|
||||
create_cpeer $WG
|
||||
create_cpeer $WG $ifce
|
||||
|
||||
uci commit network
|
||||
}
|
||||
@ -298,17 +301,19 @@ if [ $SERVE = "0" ]; then
|
||||
else
|
||||
running=$(uci -q get wireguard.settings.client)
|
||||
log "Client running $running"
|
||||
if [ $running = 1 ]; then
|
||||
exit 0
|
||||
|
||||
INTER=$(uci -q get wireguard."$WG".wginter)
|
||||
if [ -z "$INTER" ]; then
|
||||
INTER=0
|
||||
fi
|
||||
UDP=$(uci -q get wireguard."$WG".udptunnel)
|
||||
if [ $UDP = 1 ]; then
|
||||
udp_client $WG
|
||||
fi
|
||||
handle_client
|
||||
handle_client $INTER
|
||||
uci commit network
|
||||
log "Start Interface"
|
||||
ifup wg0
|
||||
ifup wg$INTER
|
||||
sleep 2
|
||||
uci set wireguard.settings.client="1"
|
||||
fi
|
||||
|
@ -44,15 +44,19 @@ if [ $SERVE = "0" ]; then
|
||||
uci add_list network.wg1.addresses=""
|
||||
uci commit network
|
||||
else
|
||||
ifdown wg0
|
||||
INTER=$(uci -q get wireguard."$WG".wginter)
|
||||
if [ -z "$INTER" ]; then
|
||||
INTER=0
|
||||
fi
|
||||
ifdown wg$INTER
|
||||
uci set wireguard.settings.client="0"
|
||||
uci delete network.wg0
|
||||
uci set network.wg0=interface
|
||||
uci set network.wg0.proto="wireguard"
|
||||
uci set network.wg0.auto="0"
|
||||
uci set network.wg0.private_key=""
|
||||
uci set network.wg0.listen_port=""
|
||||
uci add_list network.wg0.addresses=""
|
||||
uci delete network.wg$INTER
|
||||
uci set network.wg$INTER=interface
|
||||
uci set network.wg$INTER.proto="wireguard"
|
||||
uci set network.wg$INTER.auto="0"
|
||||
uci set network.wg$INTER.private_key=""
|
||||
uci set network.wg$INTER.listen_port=""
|
||||
uci add_list network.wg$INTER.addresses=""
|
||||
uci commit network
|
||||
fi
|
||||
UDP=$(uci get wireguard."$WG".udptunnel)
|
||||
|
@ -34,4 +34,8 @@ check_config () {
|
||||
|
||||
start() {
|
||||
check_config
|
||||
if [ -s /etc/config/zerotier ]; then
|
||||
gr_backup=`grep "^/etc/config/zerotier" /etc/sysupgrade.conf`
|
||||
[ -z $gr_backup ] && echo "/etc/config/zerotier" >> /etc/sysupgrade.conf
|
||||
fi
|
||||
}
|
@ -6,6 +6,7 @@ translate = I18N.translate
|
||||
function index()
|
||||
local fs = require "nixio.fs"
|
||||
local lock = luci.model.uci.cursor():get("custom", "menu", "full")
|
||||
local default = luci.model.uci.cursor():get("custom", "menu", "default")
|
||||
local multilock = luci.model.uci.cursor():get("custom", "multiuser", "multi") or "0"
|
||||
local rootlock = luci.model.uci.cursor():get("custom", "multiuser", "root") or "0"
|
||||
if (multilock == "0") or (multilock == "1" and rootlock == "1") then
|
||||
@ -15,6 +16,10 @@ function index()
|
||||
if (multilock == "1" and rootlock == "1") then
|
||||
page = entry({"admin", "adminmenu", "zerotier"}, template("zerotier/zerotier"), translate("Zerotier"), 7)
|
||||
page.dependent = true
|
||||
else
|
||||
if default == "1" then
|
||||
page = entry({"admin", "adminmenu", "zerotier"}, template("zerotier/zerotier"), translate("Zerotier"), 7)
|
||||
page.dependent = true
|
||||
else
|
||||
page = entry({"admin", "adminmenu", "zerotier"}, template("zerotier/zerotier"), translate("---Router ID"), 7)
|
||||
page.dependent = true
|
||||
@ -22,6 +27,7 @@ function index()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
entry({"admin", "services", "getid"}, call("action_getid"))
|
||||
entry({"admin", "services", "sendid"}, call("action_sendid"))
|
||||
|
@ -1,12 +1,17 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ "$ACTION" = ifup -a "$INTERFACE" = "wwan" ]; then
|
||||
log() {
|
||||
wifilog "IFACE" "$@"
|
||||
}
|
||||
|
||||
wif=$(uci -q get travelmate.global.freq)
|
||||
if [ "$ACTION" = ifup -a "$INTERFACE" = "wwan$wif" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$ACTION" = ifdown -a "$INTERFACE" = "wwan" ]; then
|
||||
if [ "$ACTION" = ifdown -a "$INTERFACE" = "wwan$wif" ]; then
|
||||
wifilog "HOTSPOT" "hotplug (iface): action='$ACTION' interface='$INTERFACE'"
|
||||
conn=$(uci -q get travelmate.global.connecting)
|
||||
wif=$(uci -q get travelmate.global.freq)
|
||||
if [ "$conn" != "1" ]; then
|
||||
uci -q set wireless.wwan$wif.ssid="Hotspot Manager Interface"
|
||||
uci -q set wireless.wwan$wif.encryption="none"
|
||||
@ -17,6 +22,7 @@ if [ "$ACTION" = ifdown -a "$INTERFACE" = "wwan" ]; then
|
||||
ubus call network reload
|
||||
disa=$(uci -q get travelmate.global.ssid)
|
||||
# check for disconnect or lost connection
|
||||
if [ "$disa" != "8" ]; then
|
||||
if [ "$disa" != "7" ]; then
|
||||
uci set travelmate.global.ssid="9" # lost connection
|
||||
reconn=$(uci -q get travelmate.global.reconn)
|
||||
@ -30,11 +36,26 @@ if [ "$ACTION" = ifdown -a "$INTERFACE" = "wwan" ]; then
|
||||
uci set travelmate.global.lost=$lost
|
||||
uci set travelmate.global.delay="30"
|
||||
uci commit travelmate
|
||||
sleep 10
|
||||
PID=$(ps |grep "travelmate.sh" | grep -v grep |head -n 1 | awk '{print $1}')
|
||||
if [ ! -z "$PID" ]; then
|
||||
kill -9 $PID
|
||||
fi
|
||||
/usr/lib/hotspot/travelmate.sh &
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
else
|
||||
uci set travelmate.global.ssid="9"
|
||||
uci commit travelmate
|
||||
PID=$(ps |grep "travelmate.sh" | grep -v grep |head -n 1 | awk '{print $1}')
|
||||
if [ ! -z "$PID" ]; then
|
||||
kill -9 $PID
|
||||
fi
|
||||
/usr/lib/hotspot/travelmate.sh &
|
||||
exit 0
|
||||
fi
|
||||
uci set travelmate.global.trm_enabled="0"
|
||||
uci commit travelmate
|
||||
fi
|
||||
|
@ -34,7 +34,7 @@ do_radio() {
|
||||
|
||||
config_get channel $1 channel
|
||||
config_get hwmode $1 hwmode
|
||||
if [ $hwmode = "11g" ]; then
|
||||
if [ $channel -lt 20 ]; then
|
||||
w2=$(uci -q get wireless.wwan2.device)
|
||||
if [ -z $w2 ]; then
|
||||
uci set wireless.wwan2=wifi-iface
|
||||
@ -69,12 +69,16 @@ log "Hotspot Firewall"
|
||||
if [ -z $PRO ]; then
|
||||
uci set network.wwan2=interface
|
||||
uci set network.wwan2.proto=dhcp
|
||||
uci set network.wwan2.metric='2'
|
||||
uci set network.wwan26=interface
|
||||
uci set network.wwan26.proto=dhcpv6
|
||||
uci set network.wwan26.metric='2'
|
||||
uci set network.wwan5=interface
|
||||
uci set network.wwan5.proto=dhcp
|
||||
uci set network.wwan5.metric='2'
|
||||
uci set network.wwan56=interface
|
||||
uci set network.wwan56.proto=dhcpv6
|
||||
uci set network.wwan56.metric='2'
|
||||
uci commit network
|
||||
fi
|
||||
config_load firewall
|
||||
|
@ -22,6 +22,10 @@ if [ $SET = "1" ]; then
|
||||
uci -q set wireless.wwan$wif.key=
|
||||
uci set wireless.wwan$wif.ssid="Hotspot Manager Interface"
|
||||
uci -q commit wireless
|
||||
PID=$(ps |grep "travelmate.sh" | grep -v grep |head -n 1 | awk '{print $1}')
|
||||
if [ ! -z "$PID" ]; then
|
||||
kill -9 $PID
|
||||
fi
|
||||
/usr/lib/hotspot/travelmate.sh &
|
||||
fi
|
||||
else
|
||||
|
@ -22,7 +22,7 @@ trm_iw=1
|
||||
trm_auto=$(uci -q get travelmate.global.trm_auto)
|
||||
|
||||
check_wwan() {
|
||||
uci set travelmate.global.ssid="0"
|
||||
uci set travelmate.global.ssid="8"
|
||||
wif=$(uci -q get travelmate.global.freq)
|
||||
if [ -z "$wif" ]; then
|
||||
uci set travelmate.global.freq="2"
|
||||
@ -309,6 +309,9 @@ f_main()
|
||||
uci commit travelmate
|
||||
uci -q set wireless.wwan$wif.ssid="$ssid"
|
||||
uci -q set wireless.wwan$wif.encryption=$encrypt
|
||||
if [ "$encrypt" = "none" ]; then
|
||||
key=""
|
||||
fi
|
||||
uci -q set wireless.wwan$wif.key=$key
|
||||
uci -q set wireless.wwan$wif.disabled=0
|
||||
uci -q commit wireless
|
||||
@ -381,9 +384,11 @@ f_main()
|
||||
# No connection to any in list
|
||||
cnt=$((cnt+1))
|
||||
if [ $reconn -gt 0 ]; then
|
||||
if [ ${cnt} -lt $reconn ]; then
|
||||
f_log "info " "Sleep before retrying"
|
||||
sleep 30
|
||||
fi
|
||||
fi
|
||||
# repeat scan and connect
|
||||
done
|
||||
done
|
||||
|
11
rooter/0optionalapps/pingtest/files/etc/config/ping
Normal file
11
rooter/0optionalapps/pingtest/files/etc/config/ping
Normal file
@ -0,0 +1,11 @@
|
||||
|
||||
config ping 'ping'
|
||||
option enable '0'
|
||||
option delay '40'
|
||||
option conn '1'
|
||||
option interval '20'
|
||||
option type '1'
|
||||
option ipv41 'http://www.google.com/'
|
||||
option ipv6 'http://www.example.org/'
|
||||
option ipv42 'https://github.com'
|
||||
|
14
rooter/0optionalapps/pingtest/files/etc/init.d/pingtest
Normal file
14
rooter/0optionalapps/pingtest/files/etc/init.d/pingtest
Normal file
@ -0,0 +1,14 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2013 OpenWrt.org
|
||||
|
||||
START=99
|
||||
USE_PROCD=1
|
||||
|
||||
log() {
|
||||
logger -t "pingtest" "$@"
|
||||
}
|
||||
|
||||
start_service()
|
||||
{
|
||||
/usr/lib/custom/test_ping.sh &
|
||||
}
|
@ -19,6 +19,62 @@ tping() {
|
||||
fi
|
||||
}
|
||||
|
||||
doping() {
|
||||
TYPE=$(uci get ping.ping.type)
|
||||
if [ $TYPE = "1" ]; then
|
||||
log "Curl"
|
||||
RETURN_CODE_1=$(curl -s -m 10 -s -o /dev/null -w "%{http_code}" $ipv41)
|
||||
RETURN_CODE_2=$(curl -s --ipv6 -m 10 -s -o /dev/null -w "%{http_code}" $ipv6)
|
||||
RETURN_CODE_3=$(curl -s -m 10 -s -o /dev/null -w "%{http_code}" $ipv42)
|
||||
else
|
||||
log "Ping"
|
||||
tping "$ipv41"; RETURN_CODE_1=$tmp
|
||||
tping "$ipv6" "-6"; RETURN_CODE_2=$tmp
|
||||
tping "$ipv42"; RETURN_CODE_3=$tmp
|
||||
fi
|
||||
}
|
||||
|
||||
ptest() {
|
||||
tries=0
|
||||
status=0
|
||||
while [ $tries -lt $1 ]
|
||||
do
|
||||
CONN=$(uci -q get modem.modem$CURRMODEM.connected)
|
||||
if [ $CONN = "1" ]; then
|
||||
uci set ping.ping.conn="4"
|
||||
uci commit ping
|
||||
doping
|
||||
if [[ "$RETURN_CODE_1" != "200" && "$RETURN_CODE_2" != "200" && "$RETURN_CODE_3" != "200" ]]; then
|
||||
uci set ping.ping.conn="1"
|
||||
uci commit ping
|
||||
status=1
|
||||
return
|
||||
fi
|
||||
log "Second Ping Test Good"
|
||||
uci set ping.ping.conn="2"
|
||||
uci commit ping
|
||||
status=0
|
||||
return
|
||||
else
|
||||
sleep 20
|
||||
tries=$((tries+1))
|
||||
fi
|
||||
done
|
||||
status=1
|
||||
}
|
||||
|
||||
ipv41=$(uci -q get ping.ping.ipv41)
|
||||
if [ -z "$ipv41" ]; then
|
||||
ipv41="http://www.google.com/"
|
||||
fi
|
||||
ipv42=$(uci -q get ping.ping.ipv42)
|
||||
if [ -z "$ipv42" ]; then
|
||||
ipv42="https://github.com"
|
||||
fi
|
||||
ipv6=$(uci -q get ping.ping.ipv6)
|
||||
if [ -z "$ipv6" ]; then
|
||||
ipv6="http://ipv6.google.com"
|
||||
fi
|
||||
uci set ping.ping.conn="4"
|
||||
uci commit ping
|
||||
|
||||
@ -26,71 +82,38 @@ CURRMODEM=1
|
||||
CPORT=$(uci -q get modem.modem$CURRMODEM.commport)
|
||||
DELAY=$(uci get ping.ping.delay)
|
||||
|
||||
TYPE=$(uci get ping.ping.type)
|
||||
if [ $TYPE = "1" ]; then
|
||||
log "Curl"
|
||||
RETURN_CODE_1=$(curl -m 10 -s -o /dev/null -w "%{http_code}" http://www.google.com/)
|
||||
RETURN_CODE_2=$(curl --ipv6 -m 10 -s -o /dev/null -w "%{http_code}" http://www.example.org/)
|
||||
RETURN_CODE_3=$(curl -m 10 -s -o /dev/null -w "%{http_code}" https://github.com)
|
||||
else
|
||||
log "Ping"
|
||||
tping "http://www.google.com/"; RETURN_CODE_1=$tmp
|
||||
tping "http://www.example.org/" "-6"; RETURN_CODE_2=$tmp
|
||||
tping "https://github.com"; RETURN_CODE_3=$tmp
|
||||
fi
|
||||
doping
|
||||
|
||||
if [[ "$RETURN_CODE_1" != "200" && "$RETURN_CODE_2" != "200" && "$RETURN_CODE_3" != "200" ]]; then
|
||||
log "Bad Ping Test"
|
||||
if [ $TYPE = "1" ]; then
|
||||
tping "http://www.google.com/"; RETURN_CODE_1=$tmp
|
||||
tping "http://www.example.org/" "-6"; RETURN_CODE_2=$tmp
|
||||
tping "https://github.com"; RETURN_CODE_3=$tmp
|
||||
else
|
||||
RETURN_CODE_1=$(curl -m 10 -s -o /dev/null -w "%{http_code}" http://www.google.com/)
|
||||
RETURN_CODE_2=$(curl --ipv6 -m 10 -s -o /dev/null -w "%{http_code}" http://www.example.org/)
|
||||
RETURN_CODE_3=$(curl -m 10 -s -o /dev/null -w "%{http_code}" https://github.com)
|
||||
fi
|
||||
doping
|
||||
if [[ "$RETURN_CODE_1" != "200" && "$RETURN_CODE_2" != "200" && "$RETURN_CODE_3" != "200" ]]; then
|
||||
log "Second Bad Ping Test"
|
||||
uci set ping.ping.conn="3"
|
||||
uci commit ping
|
||||
ATCMDD="AT+CFUN=1,1"
|
||||
$ROOTER/gcom/gcom-locked "/dev/ttyUSB$CPORT" "run-at.gcom" "$CURRMODEM" "$ATCMDD"
|
||||
log "Restart Network"
|
||||
/usr/lib/rooter/luci/restart.sh $CURRMODEM 10
|
||||
sleep $DELAY
|
||||
tries=0
|
||||
while [ $tries -lt 9 ]
|
||||
do
|
||||
CONN=$(uci -q get modem.modem$CURRMODEM.connected)
|
||||
if [ $CONN = "1" ]; then
|
||||
uci set ping.ping.conn="4"
|
||||
uci commit ping
|
||||
if [ $TYPE = "1" ]; then
|
||||
log "Curl"
|
||||
RETURN_CODE_1=$(curl -m 10 -s -o /dev/null -w "%{http_code}" http://www.google.com/)
|
||||
RETURN_CODE_2=$(curl --ipv6 -m 10 -s -o /dev/null -w "%{http_code}" http://www.example.org/)
|
||||
RETURN_CODE_3=$(curl -m 10 -s -o /dev/null -w "%{http_code}" https://github.com)
|
||||
else
|
||||
log "Ping"
|
||||
tping "http://www.google.com/"; RETURN_CODE_1=$tmp
|
||||
tping "http://www.example.org/" "-6"; RETURN_CODE_2=$tmp
|
||||
tping "https://github.com"; RETURN_CODE_3=$tmp
|
||||
fi
|
||||
if [[ "$RETURN_CODE_1" != "200" && "$RETURN_CODE_2" != "200" && "$RETURN_CODE_3" != "200" ]]; then
|
||||
uci set ping.ping.conn="1"
|
||||
uci commit ping
|
||||
reboot -f
|
||||
fi
|
||||
log "Second Ping Test Good"
|
||||
ptest 3
|
||||
if [ $status -eq 0 ]; then
|
||||
log "Good Ping after Network Restart"
|
||||
uci set ping.ping.conn="2"
|
||||
uci commit ping
|
||||
exit 0
|
||||
else
|
||||
log "Hard Restart"
|
||||
/usr/lib/rooter/luci/restart.sh $CURRMODEM 11
|
||||
ptest 9
|
||||
if [ $status -eq 0 ]; then
|
||||
log "Good Ping after Hard Restart"
|
||||
uci set ping.ping.conn="2"
|
||||
uci commit ping
|
||||
exit 0
|
||||
else
|
||||
sleep 20
|
||||
tries=$((tries+1))
|
||||
fi
|
||||
done
|
||||
reboot -f
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
else
|
||||
log "Good Ping"
|
||||
uci set ping.ping.conn="2"
|
||||
|
@ -39,4 +39,16 @@ d1:value("100", "100 seconds")
|
||||
d1:value("120", "120 seconds")
|
||||
d1.default=40
|
||||
|
||||
ipv41 = d:option(Value, "ipv41", translate("IPv4 Server :"), translate("First IPv4 server to ping"));
|
||||
ipv41.rmempty = true;
|
||||
ipv41.optional=false;
|
||||
|
||||
ipv42 = d:option(Value, "ipv42", translate("IPv4 Server :"), translate("Second IPv4 server to ping"));
|
||||
ipv42.rmempty = true;
|
||||
ipv42.optional=false;
|
||||
|
||||
ipv6 = d:option(Value, "ipv6", translate("IPv6 Server :"), translate("IPv6 server to ping"));
|
||||
ipv6.rmempty = true;
|
||||
ipv6.optional=false;
|
||||
|
||||
return m
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user