mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-03-09 15:40:03 +00:00
Set some settings at startup
This commit is contained in:
parent
087561e002
commit
c4cfdcda06
1 changed files with 28 additions and 19 deletions
|
@ -18,31 +18,12 @@ omr_intf_check() {
|
||||||
omr_intf_set() {
|
omr_intf_set() {
|
||||||
local device
|
local device
|
||||||
local ifname
|
local ifname
|
||||||
local multipath
|
|
||||||
config_get multipath "$1" multipath
|
|
||||||
config_get ifname "$1" ifname
|
config_get ifname "$1" ifname
|
||||||
config_get device "$1" device
|
config_get device "$1" device
|
||||||
config_get proto "$1" proto
|
|
||||||
config_get type "$1" type
|
config_get type "$1" type
|
||||||
config_get addlatency "$1" addlatency
|
|
||||||
[ -z "$addlatency" ] && addlatency=0
|
|
||||||
devicename=$(echo "$device" | cut -d'/' -f3)
|
|
||||||
|
|
||||||
[ -z "$ifname" ] && ifname=$(ifstatus "$1" | jsonfilter -q -e '@["l3_device"]')
|
[ -z "$ifname" ] && ifname=$(ifstatus "$1" | jsonfilter -q -e '@["l3_device"]')
|
||||||
|
|
||||||
if [ -n "$ifname" ]; then
|
|
||||||
if [ "$addlatency" = "0" ] && [ "$(tc qdisc show dev $ifname | grep delay)" != "" ]; then
|
|
||||||
tc qdisc del dev ${ifname} root netem
|
|
||||||
fi
|
|
||||||
if [ "$addlatency" != "0" ]; then
|
|
||||||
if [ "$(tc qdisc show dev $ifname | grep delay)" != "" ]; then
|
|
||||||
tc qdisc add dev ${ifname} root netem delay ${addlatency}ms
|
|
||||||
elif [ "$(tc qdisc show dev $ifname | awk '/delay/ { print $10 }' | sed 's/ms//')" != "$addlatency" ]; then
|
|
||||||
tc qdisc replace dev ${ifname} root netem delay ${addlatency}ms
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$type" != "macvlan" ] && [ -n "$ifname" ] && [ -f /sys/class/net/${ifname}/device/uevent ]; then
|
if [ "$type" != "macvlan" ] && [ -n "$ifname" ] && [ -f /sys/class/net/${ifname}/device/uevent ]; then
|
||||||
devicepath=$(readlink -f /sys/class/net/${ifname})
|
devicepath=$(readlink -f /sys/class/net/${ifname})
|
||||||
if [ -n "$devicepath" ] && [ "$(echo ${devicepath} | grep virtual)" = "" ] && [ "$(cat /sys/class/net/${ifname}/device/uevent | grep PRODUCT)" != "" ] && [ "$(cat /sys/class/net/${ifname}/device/uevent | grep PCI_SLOT_NAME)" = "" ]; then
|
if [ -n "$devicepath" ] && [ "$(echo ${devicepath} | grep virtual)" = "" ] && [ "$(cat /sys/class/net/${ifname}/device/uevent | grep PRODUCT)" != "" ] && [ "$(cat /sys/class/net/${ifname}/device/uevent | grep PCI_SLOT_NAME)" = "" ]; then
|
||||||
|
@ -63,6 +44,15 @@ omr_intf_set() {
|
||||||
}
|
}
|
||||||
|
|
||||||
omr_set_settings() {
|
omr_set_settings() {
|
||||||
|
local device
|
||||||
|
local ifname
|
||||||
|
local multipath
|
||||||
|
config_get multipath "$1" multipath
|
||||||
|
config_get ifname "$1" ifname
|
||||||
|
config_get device "$1" device
|
||||||
|
config_get proto "$1" proto
|
||||||
|
config_get type "$1" type
|
||||||
|
config_get addlatency "$1" addlatency
|
||||||
[ -z "$multipath" ] || [ "$multipath" = "off" ] && [ "$1" != "omrvpn" ] && [ "$1" != "glorytun" ] && return
|
[ -z "$multipath" ] || [ "$multipath" = "off" ] && [ "$1" != "omrvpn" ] && [ "$1" != "glorytun" ] && return
|
||||||
|
|
||||||
uci -q set openmptcprouter.$1=interface
|
uci -q set openmptcprouter.$1=interface
|
||||||
|
@ -73,6 +63,25 @@ omr_set_settings() {
|
||||||
else
|
else
|
||||||
uci -q set network.$1.ipv6=1
|
uci -q set network.$1.ipv6=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
[ -z "$addlatency" ] && addlatency=0
|
||||||
|
devicename=$(echo "$device" | cut -d'/' -f3)
|
||||||
|
|
||||||
|
[ -z "$ifname" ] && ifname=$(ifstatus "$1" | jsonfilter -q -e '@["l3_device"]')
|
||||||
|
|
||||||
|
if [ -n "$ifname" ]; then
|
||||||
|
if [ "$addlatency" = "0" ] && [ "$(tc qdisc show dev $ifname | grep delay)" != "" ]; then
|
||||||
|
tc qdisc del dev ${ifname} root netem
|
||||||
|
fi
|
||||||
|
if [ "$addlatency" != "0" ]; then
|
||||||
|
if [ "$(tc qdisc show dev $ifname | grep delay)" != "" ]; then
|
||||||
|
tc qdisc add dev ${ifname} root netem delay ${addlatency}ms
|
||||||
|
elif [ "$(tc qdisc show dev $ifname | awk '/delay/ { print $10 }' | sed 's/ms//')" != "$addlatency" ]; then
|
||||||
|
tc qdisc replace dev ${ifname} root netem delay ${addlatency}ms
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
start_service() {
|
start_service() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue