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:
d4nn13andClaude Opus 4.7 committed 2026-04-19 20:06:58 +02:00
1 parent b27ca6b989
commit 61711e0e6b
1 file changed
+4 -3
+4 -3
View File
@@ -29,7 +29,8 @@ echo "probing PMTU toward $target (range $MTU_MIN..$MTU_MAX)" >&2
# ICMP payload = mtu - 28 (IP+ICMP headers)
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
}
@@ -61,5 +62,5 @@ echo "path MTU: $best"
echo "recommended WG MTU: $wg_mtu"
echo
echo "apply on both peers:"
echo " sudo sed -i 's/^MTU = .*/MTU = ${wg_mtu}/' /etc/wireguard/wg0.conf"
echo " sudo systemctl restart wg-quick@wg0"
echo " sed -i 's/^MTU = .*/MTU = ${wg_mtu}/' /etc/wireguard/wg0.conf"
echo " rc-service wg-quick.wg0 restart"