mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-02-15 03:51:51 +00:00
Keep ethernet name of USB devices
This commit is contained in:
parent
fcf41ac85d
commit
5e9a5791de
2 changed files with 56 additions and 18 deletions
|
@ -0,0 +1,25 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# Copyright (C) 2020 Ycarus (Yannick Chabanois) <ycarus@zugaina.org> for OpenMPTCProuter
|
||||||
|
|
||||||
|
[ "$ACTION" = "add" ] || exit
|
||||||
|
[ -n "${INTERFACE}" ] || exit
|
||||||
|
[ -n "${DEVPATH}" ] || exit
|
||||||
|
|
||||||
|
. /lib/functions.sh
|
||||||
|
|
||||||
|
_set_intf_name() {
|
||||||
|
local intfname=$1
|
||||||
|
local device
|
||||||
|
local ifname
|
||||||
|
config_get device $intfname device
|
||||||
|
config_get ifname $intfname ifname
|
||||||
|
[ -n "$device" ] && [ -n "$ifname" ] && [ "/sys${DEVPATH}" = "$device" ] && [ "$INTERFACE" != "$ifname" ] && {
|
||||||
|
logger -t "OMR-Rename" "Rename ${INTERFACE} to ${ifname}"
|
||||||
|
ip link set ${INTERFACE} down
|
||||||
|
ip link set ${INTERFACE} name ${ifname}
|
||||||
|
ip link set ${ifname} up
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
config_load network
|
||||||
|
config_foreach _set_intf_name interface
|
|
@ -16,8 +16,17 @@ omr_intf_check() {
|
||||||
}
|
}
|
||||||
|
|
||||||
omr_intf_set() {
|
omr_intf_set() {
|
||||||
|
local device
|
||||||
|
local ifname
|
||||||
|
local multipath
|
||||||
config_get multipath "$1" multipath
|
config_get multipath "$1" multipath
|
||||||
config_get ifname "$1" ifname
|
config_get ifname "$1" ifname
|
||||||
|
|
||||||
|
[ -n "$ifname" ] && [ -L /sys/class/net/${ifname} ] && {
|
||||||
|
device=$(readlink -f /sys/class/net/${ifname})
|
||||||
|
[ "$(echo ${device} | grep virtual)" = "" ] && uci -q set network.$1.device="$device"
|
||||||
|
}
|
||||||
|
|
||||||
[ -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
|
||||||
|
@ -37,6 +46,8 @@ start_service() {
|
||||||
config_foreach omr_intf_check interface
|
config_foreach omr_intf_check interface
|
||||||
config_load network
|
config_load network
|
||||||
config_foreach omr_intf_set interface
|
config_foreach omr_intf_set interface
|
||||||
|
uci -q commit network
|
||||||
|
uci -q commit openmptcprouter
|
||||||
|
|
||||||
[ -n "$(ubus call system board | jsonfilter -e '@.board_name' | grep raspberry)" ] && {
|
[ -n "$(ubus call system board | jsonfilter -e '@.board_name' | grep raspberry)" ] && {
|
||||||
# force CPU speed for RPI
|
# force CPU speed for RPI
|
||||||
|
@ -45,24 +56,26 @@ start_service() {
|
||||||
uci -q set openmptcprouter.settings.scaling_governor='performance'
|
uci -q set openmptcprouter.settings.scaling_governor='performance'
|
||||||
}
|
}
|
||||||
|
|
||||||
config_load openmptcprouter
|
[ -d /sys/devices/system/cpu/cpufreq/policy0 ] && {
|
||||||
config_get scaling_min_freq settings scaling_min_freq
|
config_load openmptcprouter
|
||||||
[ -n "$scaling_min_freq" ] && {
|
config_get scaling_min_freq settings scaling_min_freq
|
||||||
for c in $(ls -d /sys/devices/system/cpu/cpufreq/policy[0-9]*); do
|
[ -n "$scaling_min_freq" ] && {
|
||||||
echo $scaling_min_freq > $c/scaling_min_freq
|
for c in $(ls -d /sys/devices/system/cpu/cpufreq/policy[0-9]*); do
|
||||||
done
|
echo $scaling_min_freq > $c/scaling_min_freq
|
||||||
}
|
done
|
||||||
config_get scaling_max_freq settings scaling_max_freq
|
}
|
||||||
[ -n "$scaling_max_freq" ] && {
|
config_get scaling_max_freq settings scaling_max_freq
|
||||||
for c in $(ls -d /sys/devices/system/cpu/cpufreq/policy[0-9]*); do
|
[ -n "$scaling_max_freq" ] && {
|
||||||
echo $scaling_max_freq > $c/scaling_max_freq
|
for c in $(ls -d /sys/devices/system/cpu/cpufreq/policy[0-9]*); do
|
||||||
done
|
echo $scaling_max_freq > $c/scaling_max_freq
|
||||||
}
|
done
|
||||||
config_get scaling_governor settings scaling_governor
|
}
|
||||||
[ -n "$scaling_governor" ] && {
|
config_get scaling_governor settings scaling_governor
|
||||||
for c in $(ls -d /sys/devices/system/cpu/cpufreq/policy[0-9]*); do
|
[ -n "$scaling_governor" ] && {
|
||||||
echo $scaling_governor > $c/scaling_governor
|
for c in $(ls -d /sys/devices/system/cpu/cpufreq/policy[0-9]*); do
|
||||||
done
|
echo $scaling_governor > $c/scaling_governor
|
||||||
|
done
|
||||||
|
}
|
||||||
}
|
}
|
||||||
# remove sysctl already defined in /etc/sysctl.d/
|
# remove sysctl already defined in /etc/sysctl.d/
|
||||||
sed -i -e '/tcp_fin_timeout/d' -e '/tcp_keepalive_time/d' -e '/nf_conntrack_max/d' -e '/tcp_syn_retries/d' -e '/tcp_fastopen/d' -e '/tcp_retries2/d' /etc/sysctl.conf
|
sed -i -e '/tcp_fin_timeout/d' -e '/tcp_keepalive_time/d' -e '/nf_conntrack_max/d' -e '/tcp_syn_retries/d' -e '/tcp_fastopen/d' -e '/tcp_retries2/d' /etc/sysctl.conf
|
||||||
|
|
Loading…
Reference in a new issue