fix wirecon-mtu-probe unbound-variable under set -u
Bash expands all arithmetic substitutions on a `local` line before the preceding assignments take effect, so `local mtu=$1 payload=$((mtu-28))` triggered "mtu: unbound variable" under set -u. Split into two lines. Also updated the printed "apply on both peers" hint from the old systemd-era `systemctl restart wg-quick@wg0` to the OpenRC form `rc-service wg-quick.wg0 restart` that matches this project. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
1 parent
b27ca6b989
commit
61711e0e6b
1 file changed
+4
-3
@@ -29,7 +29,8 @@ echo "probing PMTU toward $target (range $MTU_MIN..$MTU_MAX)" >&2
|
|||||||
|
|
||||||
# ICMP payload = mtu - 28 (IP+ICMP headers)
|
# ICMP payload = mtu - 28 (IP+ICMP headers)
|
||||||
probe_ok() {
|
probe_ok() {
|
||||||
local mtu=$1 payload=$((mtu - 28))
|
local mtu=$1
|
||||||
|
local payload=$((mtu - 28))
|
||||||
ping -M do -s "$payload" -c 1 -W 2 -n "$target" >/dev/null 2>&1
|
ping -M do -s "$payload" -c 1 -W 2 -n "$target" >/dev/null 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,5 +62,5 @@ echo "path MTU: $best"
|
|||||||
echo "recommended WG MTU: $wg_mtu"
|
echo "recommended WG MTU: $wg_mtu"
|
||||||
echo
|
echo
|
||||||
echo "apply on both peers:"
|
echo "apply on both peers:"
|
||||||
echo " sudo sed -i 's/^MTU = .*/MTU = ${wg_mtu}/' /etc/wireguard/wg0.conf"
|
echo " sed -i 's/^MTU = .*/MTU = ${wg_mtu}/' /etc/wireguard/wg0.conf"
|
||||||
echo " sudo systemctl restart wg-quick@wg0"
|
echo " rc-service wg-quick.wg0 restart"
|
||||||
Reference in new issue
Block a user