diff options
Diffstat (limited to 'net/pbr/files/etc/uci-defaults/91-pbr')
-rw-r--r-- | net/pbr/files/etc/uci-defaults/91-pbr | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/net/pbr/files/etc/uci-defaults/91-pbr b/net/pbr/files/etc/uci-defaults/91-pbr index 16693864f..9fc47e4bb 100644 --- a/net/pbr/files/etc/uci-defaults/91-pbr +++ b/net/pbr/files/etc/uci-defaults/91-pbr @@ -1,8 +1,13 @@ #!/bin/sh -# shellcheck disable=SC1091,SC3037,SC3043 +# shellcheck disable=SC3037,SC3043 -readonly packageName='pbr' -readonly __OK__='\033[0;32m[\xe2\x9c\x93]\033[0m' +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() { @@ -15,17 +20,17 @@ pbr_iface_setup() { case "${proto}" in (gre*|nebula|relay|vti*|vxlan|xfrm) return 0 ;; (none) - uci -q set "network.${iface}_rt=route" - uci -q set "network.${iface}_rt.interface=${iface}" - uci -q set "network.${iface}_rt.target=0.0.0.0/0" - uci -q set "network.${iface}_rt6=route6" - uci -q set "network.${iface}_rt6.interface=${iface}" - uci -q set "network.${iface}_rt6.target=::/0" + uci_add network route "${iface}_rt" + uci_set network "${iface}_rt" interface "${iface}" + uci_set network "${iface}_rt" target '0.0.0.0/0' + uci_add route6 network "${iface}_rt6" + uci_set network "${iface}_rt6" interface "${iface}" + uci_set network "${iface}_rt6" target '::/0' ;; esac echo -en "Setting up ${packageName} routing tables for ${iface}... " - uci -q set "network.${iface}.ip4table=${packageName}_${iface%6}" - uci -q set "network.${iface}.ip6table=${packageName}_${iface%6}" + uci_set 'network' "${iface}" 'ip4table' "${packageName}_${iface%6}" + uci_set 'network' "${iface}" 'ip6table' "${packageName}_${iface%6}" if ! grep -q -E -e "^[0-9]+\s+${packageName}_${iface%6}$" /etc/iproute2/rt_tables; then sed -i -e "\$a $(($(sort -r -n /etc/iproute2/rt_tables | grep -o -E -m 1 "^[0-9]+")+1))\t${packageName}_${iface%6}" \ /etc/iproute2/rt_tables @@ -33,8 +38,6 @@ pbr_iface_setup() { echo -e "${__OK__}" } -. /lib/functions.sh -. /lib/functions/network.sh config_load network config_foreach pbr_iface_setup interface network_flush_cache @@ -51,7 +54,7 @@ set network.default6='rule6' set network.default6.lookup='${packageName}_${iface6%6}' set network.default6.priority='80000' EOF -uci commit network +uci_commit network echo -en "Restarting network... " /etc/init.d/network restart echo -e "${__OK__}" |