Luigit
repositories / bugabinga.net

bugabinga.net

personal infrastructure for bugabinga!

owned by admin

scripts/local/deploy-wireguard-mtu.sh

Raw
#!/usr/bin/env bash
set -euo pipefail

[[ "$#" -eq 3 ]] || {
  echo 'usage: deploy-wireguard-mtu.sh HOST PORT MTU' >&2
  exit 2
}
host="$1"
port="$2"
mtu="$3"
[[ "$host" =~ ^[a-zA-Z0-9._-]+$ && "$port" =~ ^[0-9]+$ && "$port" -gt 0 && "$port" -lt 65536 && "$mtu" =~ ^[0-9]+$ && "$mtu" -ge 1280 && "$mtu" -le 1420 ]] || {
  echo 'invalid WireGuard fixed-MTU deployment input' >&2
  exit 2
}
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
ssh -oBatchMode=yes -p "$port" "root@$host" "bash -s -- $mtu" <"$repo_root/scripts/remote/apply-wireguard-mtu.sh"