mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-02 17:03:56 +08:00
🌴 Sync 2026-03-05 23:51:42
This commit is contained in:
1 parent
97c049ed0a
commit
0acff03804
14253 files changed
+3893239
No files matched your search
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"protocol": "ipv4",
|
||||
"interval": "5",
|
||||
"showMore": false,
|
||||
"showZero": true,
|
||||
"useBits": false,
|
||||
"useMultiple": "1000",
|
||||
"useDSL": false,
|
||||
"upstream": "100",
|
||||
"downstream": "100",
|
||||
"hideMACs": []
|
||||
}
|
||||
+124
@@ -0,0 +1,124 @@
|
||||
#!/bin/sh
|
||||
|
||||
. "$IPKG_INSTROOT/usr/share/libubox/jshn.sh"
|
||||
|
||||
renamefile() {
|
||||
local base=$(basename -- "$1")
|
||||
local ext=$([ -z "${base/*.*/}" ] && echo ".${base##*.}" || echo '')
|
||||
local base="${base%.*}"
|
||||
echo "$(dirname $1)/${base}$2$ext" && return
|
||||
}
|
||||
|
||||
_get_db_path() {
|
||||
local db db_4 db_6 db_46
|
||||
db="$(uci -q get wrtbwmon.general.path)"
|
||||
db_4=$(renamefile "${db:-/tmp/usage.db}" "")
|
||||
db_6=$(renamefile "${db:-/tmp/usage.db}" ".6")
|
||||
db_46=$(renamefile "${db:-/tmp/usage.db}" ".46")
|
||||
json_init
|
||||
json_add_string file_4 "$db_4"
|
||||
json_add_string file_6 "$db_6"
|
||||
json_add_string file_46 "$db_46"
|
||||
json_dump
|
||||
json_cleanup
|
||||
}
|
||||
|
||||
_get_db_raw() {
|
||||
json_init
|
||||
json_add_string file "$1"
|
||||
json_add_string data "$(cat "$1")"
|
||||
json_dump
|
||||
json_cleanup
|
||||
}
|
||||
|
||||
_remove_db() {
|
||||
local result
|
||||
rm "$1" && result=1 || result=0
|
||||
json_init
|
||||
json_add_boolean result "$result"
|
||||
json_dump
|
||||
json_cleanup
|
||||
}
|
||||
|
||||
_change_db_path() {
|
||||
json_init
|
||||
json_load "$(_get_db_path)"
|
||||
json_get_var db_4 'file_4'
|
||||
json_get_var db_6 'file_6'
|
||||
json_get_var db_46 'file_46'
|
||||
json_cleanup
|
||||
if [ "$1" = "before" ]; then
|
||||
mv "$db_4" /tmp/usage.db.tmp
|
||||
mv "$db_6" /tmp/usage.6.db.tmp
|
||||
mv "$db_46" /tmp/usage.46.db.tmp
|
||||
elif [ "$1" = "after" ]; then
|
||||
mv -f /tmp/usage.db.tmp "$db_4"
|
||||
mv -f /tmp/usage.6.db.tmp "$db_6"
|
||||
mv -f /tmp/usage.46.db.tmp "$db_46"
|
||||
fi
|
||||
json_init
|
||||
json_add_boolean result $([ "$?" = 0 ] && echo 1 || echo 0 )
|
||||
json_dump
|
||||
json_cleanup
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
list)
|
||||
json_init
|
||||
json_add_object remove_db
|
||||
json_add_string protocol "protocol"
|
||||
json_close_object
|
||||
json_add_object get_db_raw
|
||||
json_add_string protocol "protocol"
|
||||
json_close_object
|
||||
json_add_object get_db_path
|
||||
json_close_object
|
||||
json_add_object change_db_path
|
||||
json_add_string state "state"
|
||||
json_close_object
|
||||
json_dump
|
||||
json_cleanup
|
||||
;;
|
||||
call)
|
||||
case "$2" in
|
||||
remove_db)
|
||||
read -r input
|
||||
json_init
|
||||
json_load "$input"
|
||||
json_get_var protocol 'protocol'
|
||||
json_cleanup
|
||||
json_load "$(_get_db_path)"
|
||||
json_get_var db_s $([ "$protocol" = "ipv4" ] && echo file_4 || echo file_6)
|
||||
json_cleanup
|
||||
_remove_db "$db_s"
|
||||
;;
|
||||
get_db_raw)
|
||||
read -r input
|
||||
json_init
|
||||
json_load "$input"
|
||||
json_get_var protocol 'protocol'
|
||||
json_cleanup
|
||||
json_load "$(_get_db_path)"
|
||||
json_get_var db_s $([ "$protocol" = "ipv4" ] && echo file_4 || echo file_6)
|
||||
json_cleanup
|
||||
_get_db_raw "$db_s"
|
||||
;;
|
||||
get_db_path)
|
||||
read -r input
|
||||
json_init
|
||||
json_load "$input"
|
||||
json_get_var protocol 'protocol'
|
||||
json_cleanup
|
||||
_get_db_path
|
||||
;;
|
||||
change_db_path)
|
||||
read -r input
|
||||
json_init
|
||||
json_load "$input"
|
||||
json_get_var state 'state'
|
||||
json_cleanup
|
||||
_change_db_path "$state"
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"admin/network/usage": {
|
||||
"title": "Traffic Status",
|
||||
"order": 60,
|
||||
"action": {
|
||||
"type": "alias",
|
||||
"path": "admin/network/usage/details"
|
||||
},
|
||||
"depends": {
|
||||
"acl": [ "luci-app-wrtbwmon" ],
|
||||
"uci": { "wrtbwmon": true }
|
||||
}
|
||||
},
|
||||
|
||||
"admin/network/usage/details": {
|
||||
"title": "Details",
|
||||
"order": 10,
|
||||
"action": {
|
||||
"type": "view",
|
||||
"path": "wrtbwmon/details"
|
||||
}
|
||||
},
|
||||
|
||||
"admin/network/usage/config": {
|
||||
"title": "Configuration",
|
||||
"order": 20,
|
||||
"action": {
|
||||
"type": "view",
|
||||
"path": "wrtbwmon/config"
|
||||
}
|
||||
},
|
||||
|
||||
"admin/network/usage/custom": {
|
||||
"title": "User file",
|
||||
"order": 30,
|
||||
"action": {
|
||||
"type": "view",
|
||||
"path": "wrtbwmon/custom"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"luci-app-wrtbwmon": {
|
||||
"description": "Grant access to LuCI app wrtbwmon",
|
||||
"read": {
|
||||
"ubus": {
|
||||
"luci.wrtbwmon": [
|
||||
"get_db_raw",
|
||||
"get_db_path"
|
||||
],
|
||||
"luci-rpc": [
|
||||
"getDHCPLeases",
|
||||
"getDSLStatus"
|
||||
]
|
||||
},
|
||||
"file": {
|
||||
"/etc/wrtbwmon.user": [ "read" ],
|
||||
"/usr/sbin/wrtbwmon": [ "exec" ],
|
||||
"/etc/luci-wrtbwmon.conf": [ "read" ]
|
||||
},
|
||||
"uci": [ "wrtbwmon" ]
|
||||
},
|
||||
"write": {
|
||||
"ubus": {
|
||||
"luci.wrtbwmon": [
|
||||
"remove_db",
|
||||
"change_db_path"
|
||||
]
|
||||
},
|
||||
"file": {
|
||||
"/etc/luci-wrtbwmon.conf": [ "write" ],
|
||||
"/etc/wrtbwmon.user": [ "write" ]
|
||||
},
|
||||
"uci": [ "wrtbwmon" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user