[PATCH] Adding support for reloading configuration via systemd

Dominique Martinet asmadeus at codewreck.org
Fri Jul 24 16:46:05 CEST 2020

Jason A. Donenfeld wrote on Fri, Jul 24, 2020:
> Great, good to know. Made some small adjustments and committed this as:
> https://git.zx2c4.com/wireguard-tools/commit/?id=a66219fa107e1bf0a03ebbbc405879c1f0a826c5

diff --git a/src/systemd/wg-quick at .service
b/src/systemd/wg-quick at .service
index a9cbb58..dbdab44 100644
--- a/src/systemd/wg-quick at .service
+++ b/src/systemd/wg-quick at .service
@@ -15,6 +15,7 @@ Type=oneshot
 ExecStart=/usr/bin/wg-quick up %i
 ExecStop=/usr/bin/wg-quick down %i
+ExecReload=/bin/bash -c 'exec /usr/bin/wg syncconf %i <(exec /usr/bin/wg-quick strip %i)'

FWIW, bash (and zsh, ksh etc) will optimise the last command call of a
script to not fork, `bash -c 'exec foo'`  is the same as `bash -c 'foo'`

(for some reason it doesn't in the subshell though so that one makes a
difference; you can check with e.g. `strace -f -e clone bash -c ...`)

Simpler shells e.g. dash or busybox ash don't, but they don't support
the pipe substitution syntax either so I guess it doesn't matter here.


More information about the WireGuard mailing list