Skip to content

Commit a9de45a

Browse files
committed
init vnet-start: support custom pf.conf
1 parent dc8b4fa commit a9de45a

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

share/pot/init.sh

+7-6
Original file line numberDiff line numberDiff line change
@@ -85,17 +85,18 @@ pot-init()
8585
# service syslogd restart
8686

8787
# Add pot anchors if needed
88-
if [ -r /etc/pf.conf ] && [ "$(grep -c '^nat-anchor pot-nat$' /etc/pf.conf )" -eq 1 ] && [ "$(grep -c '^rdr-anchor "pot-rdr/\*"$' /etc/pf.conf )" -eq 1 ] ; then
88+
pf_file="$(sysrc -n pf_rules)"
89+
if [ -r "$pf_file" ] && [ "$(grep -c '^nat-anchor pot-nat$' "$pf_file" )" -eq 1 ] && [ "$(grep -c '^rdr-anchor "pot-rdr/\*"$' "$pf_file" )" -eq 1 ] ; then
8990
_debug "pf alredy properly configured"
9091
else
91-
if [ -w /etc/pf.conf ]; then
92+
if [ -w "$pf_file" ]; then
9293
# delete incomplete/broken ancory entries - just in case
93-
sed -i '' '/^nat-anchor pot-nat$/d' /etc/pf.conf
94-
sed -i '' '/^rdr-anchor "pot-rdr\/\*"$/d' /etc/pf.conf
94+
sed -i '' '/^nat-anchor pot-nat$/d' "$pf_file"
95+
sed -i '' '/^rdr-anchor "pot-rdr\/\*"$/d' "$pf_file"
9596
else
96-
touch /etc/pf.conf
97+
touch "$pf_file"
9798
fi
98-
printf "%s\n" 0a "nat-anchor pot-nat" "rdr-anchor \"pot-rdr/*\"" . x | ex /etc/pf.conf
99+
printf "%s\n" 0a "nat-anchor pot-nat" "rdr-anchor \"pot-rdr/*\"" . x | ex "$pf_file"
99100
fi
100101
}
101102

share/pot/vnet-start.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,12 @@ pot-vnet-start()
7373

7474
# load pf module
7575
kldload -n pf
76+
pf_file="$(sysrc -n pf_rules)"
7677
# check anchors
7778
if ! pfctl -s Anchors | grep -q '^[ \t]*pot-nat$' ||
7879
! pfctl -s Anchors | grep -q '^[ \t]*pot-rdr$' ; then
79-
_debug "Pot anchors are missing - load pf.conf"
80-
pfctl -f /etc/pf.conf
80+
_debug "Pot anchors are missing - load $pf_file"
81+
pfctl -f "$pf_file"
8182
fi
8283
_nat_rules="/tmp/pot_pf_nat_rules"
8384
if [ -w "$_nat_rules" ]; then

0 commit comments

Comments
 (0)