1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-02-14 19:41:51 +00:00

Set some settings at startup

This commit is contained in:
Ycarus (Yannick Chabanois) 2021-01-25 09:33:02 +01:00
parent 087561e002
commit c4cfdcda06

View file

@ -18,31 +18,12 @@ omr_intf_check() {
omr_intf_set() {
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 "$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
if [ "$type" != "macvlan" ] && [ -n "$ifname" ] && [ -f /sys/class/net/${ifname}/device/uevent ]; then
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
@ -63,6 +44,15 @@ omr_intf_set() {
}
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
uci -q set openmptcprouter.$1=interface
@ -73,6 +63,25 @@ omr_set_settings() {
else
uci -q set network.$1.ipv6=1
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() {