blob: bea4a353d54c94202ef58ce59a91bf8415f36161 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
#!/bin/sh
# shellcheck disable=SC3037,SC3043
readonly pbrFunctionsFile='/etc/init.d/pbr'
if [ -s "$pbrFunctionsFile" ]; then
# shellcheck source=../../etc/init.d/pbr
. "$pbrFunctionsFile"
else
printf "%b: pbr init.d file (%s) not found! \n" '\033[0;31mERROR\033[0m' "$pbrFunctionsFile"
fi
# shellcheck disable=SC2317
pbr_iface_setup() {
local iface="${1}"
local proto
if is_supported_interface "${iface}"; then
output "Setting up ${packageName} routing tables for ${iface}... "
uci_set 'network' "${iface}" 'ip4table' "${ipTablePrefix}_${iface%6}"
uci_set 'network' "${iface}" 'ip6table' "${ipTablePrefix}_${iface%6}"
if ! grep -q -E -e "^[0-9]+\s+${ipTablePrefix}_${iface%6}$" "$rtTablesFile"; then
sed -i -e "\$a $(($(sort -r -n "$rtTablesFile" | grep -o -E -m 1 "^[0-9]+")+1))\t${ipTablePrefix}_${iface%6}" \
"$rtTablesFile"
fi
output_okbn
fi
}
sed -i "/${ipTablePrefix}_/d" "$rtTablesFile"
sync
config_load network
config_foreach pbr_iface_setup interface
uci_commit network
sync
output "Restarting network... "
/etc/init.d/network restart
output_okn
exit 0
|