mirror of
https://github.com/novatiq/packages.git
synced 2026-04-30 15:38:40 +01:00
Correctly get runtime LAN ifname and addresses
1. Correctly get LAN runtime ifname and addresses using network functions 2. Do not store ip settings in config files as they may change next time.
This commit is contained in:
Regular → Executable
+15
-12
@@ -3,6 +3,8 @@
|
|||||||
START=50
|
START=50
|
||||||
USE_PROCD=1
|
USE_PROCD=1
|
||||||
|
|
||||||
|
. $IPKG_INSTROOT/lib/functions/network.sh
|
||||||
|
|
||||||
setup_config() {
|
setup_config() {
|
||||||
config_get port $1 port "4443"
|
config_get port $1 port "4443"
|
||||||
config_get max_clients $1 max_clients "8"
|
config_get max_clients $1 max_clients "8"
|
||||||
@@ -33,26 +35,27 @@ setup_config() {
|
|||||||
uci set dhcp.lan.start=100
|
uci set dhcp.lan.start=100
|
||||||
uci set dhcp.lan.limit=91
|
uci set dhcp.lan.limit=91
|
||||||
fi
|
fi
|
||||||
ip=$(uci get network.lan.ipaddr)
|
network_get_ipaddr ip lan
|
||||||
ipaddr="$(echo $ip|cut -d . -f1,2,3).192"
|
ipaddr="$(echo $ip|cut -d . -f1,2,3).192"
|
||||||
netmask="255.255.255.192"
|
netmask="255.255.255.192"
|
||||||
uci set ocserv.config.ipaddr="$ipaddr"
|
|
||||||
uci set ocserv.config.netmask="$netmask"
|
|
||||||
uci commit
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test -z "$ip6addr";then
|
if test -z "$ip6addr";then
|
||||||
ip6addr=$(uci get network.lan.ip6addr 2>/dev/null)
|
network_get_ipaddr6 ip6addr lan
|
||||||
test -n "$ip6addr" && uci set ocserv.config.ip6addr="$ip6addr"
|
# Append ipv6 prefix
|
||||||
uci commit
|
test -n "$ip6addr" && ip6addr="$ip6addr/96"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ping_leases=1
|
ping_leases=1
|
||||||
test -n "$ipaddr" && sysctl -w "net.ipv4.conf.$(uci get network.lan.ifname).proxy_arp"=1 >/dev/null
|
local ifname
|
||||||
test -n "$ip6addr" && sysctl -w "net.ipv6.conf.$(uci get network.lan.ifname).proxy_ndp"=1 >/dev/null
|
network_get_device ifname lan
|
||||||
|
if test -n "ifname";then
|
||||||
|
test -n "$ipaddr" && sysctl -w "net.ipv4.conf.$ifname.proxy_arp"=1 >/dev/null
|
||||||
|
test -n "$ip6addr" && sysctl -w "net.ipv6.conf.$ifname.proxy_ndp"=1 >/dev/null
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
test "$ipaddr" = "" && ipaddr="192.168.100.0"
|
test -z "$ipaddr" && ipaddr="192.168.100.0"
|
||||||
test "$netmask" = "" && ipaddr="255.255.255.0"
|
test -z "$netmask" && netmask="255.255.255.0"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
enable_default_domain="#"
|
enable_default_domain="#"
|
||||||
@@ -147,7 +150,7 @@ start_service() {
|
|||||||
[ -f /etc/config/ocserv-dir/ca-key.pem ] && mv /etc/config/ocserv-dir/ca-key.pem /etc/ocserv/ca-key.pem
|
[ -f /etc/config/ocserv-dir/ca-key.pem ] && mv /etc/config/ocserv-dir/ca-key.pem /etc/ocserv/ca-key.pem
|
||||||
[ -f /etc/config/ocserv-dir/ca.pem ] && mv /etc/config/ocserv-dir/ca.pem /etc/ocserv/ca.pem
|
[ -f /etc/config/ocserv-dir/ca.pem ] && mv /etc/config/ocserv-dir/ca.pem /etc/ocserv/ca.pem
|
||||||
[ -f /etc/config/ocserv-dir/server-key.pem ] && mv /etc/config/ocserv-dir/server-key.pem /etc/ocserv/server-key.pem
|
[ -f /etc/config/ocserv-dir/server-key.pem ] && mv /etc/config/ocserv-dir/server-key.pem /etc/ocserv/server-key.pem
|
||||||
[ -f /etc/config/ocserv-dir/server-cert.pem ] && mv /etc/config/ocserv-dir/server-cert.pem /etc/ocserv/server-cert.pem
|
[ -f /etc/config/ocserv-dir/server-cert.pem ] && mv /etc/config/ocserv-dir/server-cert.pem /etc/ocserv/server-cert.pem
|
||||||
[ -d /etc/config/ocserv-dir ] && rmdir /etc/config/ocserv-dir
|
[ -d /etc/config/ocserv-dir ] && rmdir /etc/config/ocserv-dir
|
||||||
|
|
||||||
[ ! -f /etc/ocserv/ca-key.pem ] && [ -x /usr/bin/certtool ] && {
|
[ ! -f /etc/ocserv/ca-key.pem ] && [ -x /usr/bin/certtool ] && {
|
||||||
|
|||||||
Reference in New Issue
Block a user