mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-02 09:53: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
Whitespace-only changes.
Executable
+34
@@ -0,0 +1,34 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=99
|
||||
USE_PROCD=1
|
||||
|
||||
|
||||
check_modems(){
|
||||
for m in $(mmcli -L | awk '{print $1}'); do
|
||||
devm=$(mmcli -m ${m} -J | jsonfilter -e '@["modem"]["generic"]["device"]')
|
||||
uci show mmconfig | grep "$devm" || {
|
||||
echo "uci section not found"
|
||||
secname=$(uci show mmconfig | tail -1 | awk -F [.] '{num = $2; gsub(/[^0-9]/, "", num); if(num != "") printf "%s%d\n", substr($2, 1, length($2)-length(num)), num+1; else print $0 "1"}')
|
||||
[ $secname ] || secname=modem1
|
||||
uci set mmconfig.${secname}=modem
|
||||
uci set mmconfig.${secname}.device=$devm
|
||||
uci commit
|
||||
}
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
start_service(){
|
||||
logger -t "MMconfig" "MMConfig started"
|
||||
# generate config uci
|
||||
check_modems
|
||||
}
|
||||
|
||||
reload_service(){
|
||||
/usr/share/modeminfo/mmconfig
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger mmconfig
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
# disable mode setting to any in modemnanager proto
|
||||
[ -f /lib/netifd/proto/modemmanager.sh ] && {
|
||||
sed -i '/^[[:space:]]*modemmanager_set_allowed_mode "$device" "$interface" "any"$/s/.*/\t\t:/' /lib/netifd/proto/modemmanager.sh
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"admin/modem/main": {
|
||||
"title": "Modeminfo",
|
||||
"order": 10,
|
||||
"action": {
|
||||
"type": "alias",
|
||||
"path": "admin/modem/main/main"
|
||||
},
|
||||
"depends": {
|
||||
"acl": [ "luci-app-mmconfig" ],
|
||||
"uci": { "mmconfig": true }
|
||||
}
|
||||
},
|
||||
|
||||
"admin/modem/main/bands": {
|
||||
"title": "Bands",
|
||||
"order": 63,
|
||||
"action": {
|
||||
"type": "view",
|
||||
"path": "modem/bands"
|
||||
}
|
||||
}
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
#!/bin/sh
|
||||
|
||||
. /lib/functions.sh
|
||||
|
||||
# get vars
|
||||
|
||||
get_mm_config(){
|
||||
local device bands preffer
|
||||
config_get device $1 device
|
||||
config_get bands $1 bands
|
||||
config_get preffer $1 preffer
|
||||
|
||||
mmcli -m $device > /dev/null 2>&1 && {
|
||||
|
||||
setpref=$(echo "$preffer" | awk -F'[:;]' '{ gsub(/[ \t]+/, "", $0); gsub(",", "|", $0); print "--set-"$1"-modes="$2" --set-"$3"-mode="$NF}')
|
||||
setbands=$(echo $bands | awk -v OFS='|' '{$1=$1}1')
|
||||
defbands=$(mmcli -J -m $device | jsonfilter -e '@["modem"]["generic"]["supported-bands"].*' | awk '{bands = (NR==1 ? $1 : bands "|"$1)} END {print bands}')
|
||||
curbands=$(mmcli -J -m $device | jsonfilter -e '@["modem"]["generic"]["current-bands"].*' | awk '{bands = (NR==1 ? $1 : bands "|"$1)} END {print bands}')
|
||||
curpref=$(mmcli -J -m $device | jsonfilter -e '@["modem"]["generic"]["current-modes"]')
|
||||
[ -n "$bands" ] || {
|
||||
setbands=$defbands
|
||||
}
|
||||
[ "$curbands" = "$setbands" ] && [ "$preffer" = "$curpref" ] || {
|
||||
modemif=$(uci show network | grep "$device" | awk -F [.] '{print $2}')
|
||||
[ "$preffer" = "$curpref" ] || mmcli -m $device $setpref
|
||||
[ "$curbands" = "$setbands" ] || mmcli -m $device --set-current-bands="$setbands"
|
||||
sleep 3
|
||||
ifup $modemif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
config_load mmconfig
|
||||
config_foreach get_mm_config modem
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"luci-app-mmconfig": {
|
||||
"description": "Grant access to mmconfig configuration",
|
||||
"read": {
|
||||
"file": {
|
||||
"/etc/init.d/mmconfig": [ "exec" ]
|
||||
},
|
||||
"cgi-io": [ "exec" ],
|
||||
"ubus": {
|
||||
"file": [ "exec" ],
|
||||
"uci": [ "changes", "get" ]
|
||||
},
|
||||
"uci": [ "mmconfig" ]
|
||||
},
|
||||
"write": {
|
||||
"cgi-io": [ "exec" ],
|
||||
"ubus": {
|
||||
"file": [ "exec" ],
|
||||
"uci": [ "add", "apply", "confirm", "delete", "order", "rename", "set" ]
|
||||
},
|
||||
"uci": [ "mmconfig" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user