summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Spek <p.spek@tyil.nl>2024-02-15 11:35:52 +0100
committerPatrick Spek <p.spek@tyil.nl>2024-02-15 11:35:52 +0100
commit2267deb50774f0f4ebc95887a3abfea9e3dac37a (patch)
treef502a10dbadd00d4ab6c600db58daeaa4b96046d
parenta9bfb14dbd0d9c182bfb281bd314ed75d6c89931 (diff)
Make wg-quick restart rather than reload
-rw-r--r--playbooks.d/vpn-wireguard/playbook.bash8
1 files changed, 7 insertions, 1 deletions
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() {