From 2267deb50774f0f4ebc95887a3abfea9e3dac37a Mon Sep 17 00:00:00 2001 From: Patrick Spek Date: Thu, 15 Feb 2024 11:35:52 +0100 Subject: Make wg-quick restart rather than reload --- playbooks.d/vpn-wireguard/playbook.bash | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/playbooks.d/vpn-wireguard/playbook.bash b/playbooks.d/vpn-wireguard/playbook.bash index 5abe24a..a8ed753 100644 --- a/playbooks.d/vpn-wireguard/playbook.bash +++ b/playbooks.d/vpn-wireguard/playbook.bash @@ -48,10 +48,12 @@ playbook_sync() { local data local wgconf local interface + local hash data="$(playbook_path "data")" interface="$(config "$BASHTARD_PLAYBOOK.interface" "wg0")" wgconf="$(config "fs.etcdir")/wireguard/$interface.conf" + hash="$(file_hash "$wgconf")" # Create the wireguard config directory mkdir -pv "$(config "fs.etcdir")/wireguard" @@ -92,9 +94,13 @@ playbook_sync() { # Don't continue here if this was just part of the add invocation [[ "$BASHTARD_COMMAND" == "add" ]] && return + # Nothing left to do if the Wireguard configs are the same + [[ "$hash" == "$(file_hash "$wgconf")" ]] && return + # Refresh the wireguard interface + # A simple reload seems to not discover newly added peers info "$BASHTARD_PLAYBOOK" "Reloading wireguard interface $interface" - systemctl reload "wg-quick@$interface.service" + systemctl restart "wg-quick@$interface.service" } playbook_del() { -- cgit v1.1