#!/usr/bin/env bash # Update Wireguard running configuration without restart set -euo pipefail select_interface() { select interface in $(wg show interfaces); do if [ -z "$interface" ]; then exit 1 fi echo "$interface" return done } main() { if [[ $(/usr/bin/id -u) -ne 0 ]]; then sudo "$(realpath "$0")" "$@" exit fi local interface if [ $# = 0 ]; then interface=$(select_interface) else interface="$1" fi if [ -z "$interface" ]; then echo "No wireguard interface." exit 1 fi wg syncconf "$interface" <(wg-quick strip "$interface") } main "$@"