1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-02-13 19:11:51 +00:00
openmptcprouter-feeds/luci-app-openmptcprouter/root/etc/init.d/openmptcprouter

102 lines
3.3 KiB
Text
Raw Normal View History

2018-04-17 07:27:15 +00:00
#!/bin/sh /etc/rc.common
# Copyright (C) 2018 Ycarus (Yannick Chabanois) <ycarus@zugaina.org>
# Released under GPL 3. See LICENSE for the full terms.
2018-04-17 07:27:15 +00:00
START=5
USE_PROCD=1
omr_intf_del() {
uci -q delete openmptcprouter.$1
}
omr_intf_set() {
config_get multipath "$1" multipath
config_get ifname "$1" ifname
[ -n "$(ubus call system board | jsonfilter -e '@.board_name' | grep raspberry)" ] && [ -n "$(echo $ifname | grep usb)" ] && {
2018-09-05 20:59:43 +00:00
uci -q set openmptcprouter.settings.scaling_min_freq=800000
uci -q set openmptcprouter.settings.scaling_max_freq=800000
}
2018-09-05 20:59:43 +00:00
[ -z "$multipath" ] || [ "$multipath" = "off" ] && [ "$1" != "omrvpn" ] && [ "$1" != "glorytun" ] && return
uci -q set openmptcprouter.$1=interface
config_get disable_ipv6 settings disable_ipv6 "0"
if [ "$disable_ipv6" = "1" ] || [ "$1" != "omr6in4" ]; then
uci -q set network.$1.ipv6=0
else
uci -q set network.$1.ipv6=1
fi
}
set_ipv6_state() {
local disable_ipv6=$1
local sysctl_ipv6=0
sysctl -w net.ipv6.conf.all.disable_ipv6=$sysctl_ipv6
sed -i 's:^net.ipv6.conf.all.disable_ipv6=[0-9]*:net.ipv6.conf.all.disable_ipv6=$sysctl_ipv6:' /etc/sysctl.d/zzz_openmptcprouter.conf
uci -q set firewall.@defaults[0].disable_ipv6=$disable_ipv6
uci -q commit firewall
2019-03-11 18:35:49 +00:00
if [ "$disable_ipv6" == "1" ]; then
uci -q set dhcp.lan.ra_default="0"
2019-02-03 18:46:21 +00:00
uci -q set network.lan.ipv6="0"
uci -q delete network.lan.ipv6
uci -q delete dhcp.lan.dhcpv6
uci -q delete dhcp.lan.ra
uci -q delete dhcp.lan.ra_default
uci -q set shadowsocks-libev.hi.local_address="0.0.0.0"
else
2019-03-11 18:35:49 +00:00
uci -q set dhcp.lan.ra_default="1"
uci -q set network.lan.ipv6="1"
uci -q set network.lan.delegate="0"
uci -q set shadowsocks-libev.hi.local_address="::"
fi
uci -q commit shadowsocks-libev
uci -q commit dhcp
2019-04-05 06:49:25 +00:00
uci -q commit network
#if [ "$disable_ipv6" == "1" ]; then
# /etc/init.d/odhcpd stop >/dev/null 2>&1
# /etc/init.d/odhcpd disable >/dev/null 2>&1
#fi
}
2018-04-17 07:27:15 +00:00
start_service() {
local scaling_min_freq scaling_max_freq
#config_load openmptcprouter
#config_foreach omr_intf_del interface
config_load network
config_foreach omr_intf_set interface
2018-04-17 07:27:15 +00:00
config_load openmptcprouter
config_get scaling_min_freq settings scaling_min_freq
[ -n "$scaling_min_freq" ] && {
2018-04-17 12:48:55 +00:00
for c in $(ls -d /sys/devices/system/cpu/cpufreq/policy[0-9]*); do
echo $scaling_min_freq > $c/scaling_min_freq
done
2018-04-17 07:27:15 +00:00
}
config_get scaling_max_freq settings scaling_max_freq
[ -n "$scaling_max_freq" ] && {
2018-04-17 12:48:55 +00:00
for c in $(ls -d /sys/devices/system/cpu/cpufreq/policy[0-9]*); do
echo $scaling_max_freq > $c/scaling_max_freq
done
2018-04-17 07:27:15 +00:00
}
config_get scaling_governor settings scaling_governor
[ -n "$scaling_governor" ] && {
2018-04-17 12:48:55 +00:00
for c in $(ls -d /sys/devices/system/cpu/cpufreq/policy[0-9]*); do
echo $scaling_governor > $c/scaling_governor
done
2018-04-17 07:27:15 +00:00
}
config_get disable_ipv6 settings disable_ipv6 "0"
if [ "$(uci -q get firewall.@defaults[0].disable_ipv6)" != "$disable_ipv6" ]; then
set_ipv6_state $disable_ipv6
fi
2018-05-12 08:07:51 +00:00
# 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' /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' /etc/sysctl.d/10-default.conf
2018-04-17 07:27:15 +00:00
}
reload_service() {
rc_procd start_service
return 0
}