All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tools: add wireguard@.service
@ 2017-05-26  8:44 Florian Klink
  2017-05-26 15:30 ` Daniel Kahn Gillmor
  0 siblings, 1 reply; 4+ messages in thread
From: Florian Klink @ 2017-05-26  8:44 UTC (permalink / raw)
  To: wireguard

If you simply want to create wireguard interfaces and configure them,
wg-quick might be too much, as it also configures Addresses, MTU and
adds routes. This unit file can be used in cases where you want to use
wg(8) to configure the wireguard interface, but do regular network
configuration on top of the link by something else (possibly not knowing
wireguard, like systemd-networkd or NetworkManager.

Signed-off-by: Florian Klink <flokli@flokli.de>
---
 src/tools/Makefile           |  3 ++-
 src/tools/wireguard@.service | 19 +++++++++++++++++++
 2 files changed, 21 insertions(+), 1 deletion(-)
 create mode 100644 src/tools/wireguard@.service

diff --git a/src/tools/Makefile b/src/tools/Makefile
index 2dd7f6a..5206832 100644
--- a/src/tools/Makefile
+++ b/src/tools/Makefile
@@ -51,6 +51,7 @@ clean:
 install: wg
 	@install -v -d "$(DESTDIR)$(BINDIR)" && install -m 0755 -v wg "$(DESTDIR)$(BINDIR)/wg"
 	@install -v -d "$(DESTDIR)$(MANDIR)/man8" && install -m 0644 -v wg.8 "$(DESTDIR)$(MANDIR)/man8/wg.8"
+	[ "$(WITH_SYSTEMDUNITS)" = "yes" ] && install -v -d "$(DESTDIR)$(SYSTEMDUNITDIR)" && install -m 0644 -v wireguard@.service "$(DESTDIR)$(SYSTEMDUNITDIR)/wireguard@.service"
 	@[ "$(WITH_BASHCOMPLETION)" = "yes" ] || exit 0; \
 	install -v -d "$(DESTDIR)$(BASHCOMPDIR)" && install -m 0644 -v completion/wg.bash-completion "$(DESTDIR)$(BASHCOMPDIR)/wg"
 	@[ "$(WITH_WGQUICK)" = "yes" ] || exit 0; \
@@ -60,7 +61,7 @@ install: wg
 	@[ "$(WITH_WGQUICK)" = "yes" -a "$(WITH_BASHCOMPLETION)" = "yes" ] || exit 0; \
 	install -m 0644 -v completion/wg-quick.bash-completion "$(DESTDIR)$(BASHCOMPDIR)/wg-quick"
 	@[ "$(WITH_WGQUICK)" = "yes" -a "$(WITH_SYSTEMDUNITS)" = "yes" ] || exit 0; \
-	install -v -d "$(DESTDIR)$(SYSTEMDUNITDIR)" && install -m 0644 -v wg-quick@.service "$(DESTDIR)$(SYSTEMDUNITDIR)/wg-quick@.service"
+	install -m 0644 -v wg-quick@.service "$(DESTDIR)$(SYSTEMDUNITDIR)/wg-quick@.service"
 
 check: clean
 	CFLAGS=-g scan-build --view --keep-going $(MAKE) wg
diff --git a/src/tools/wireguard@.service b/src/tools/wireguard@.service
new file mode 100644
index 0000000..b6d53bf
--- /dev/null
+++ b/src/tools/wireguard@.service
@@ -0,0 +1,19 @@
+[Unit]
+Description=WireGuard via wg(8) for %I
+After=network-online.target
+Wants=network-online.target
+Documentation=man:wg(8)
+Documentation=https://www.wireguard.io/
+Documentation=https://www.wireguard.io/quickstart/
+Documentation=https://git.zx2c4.com/WireGuard/about/src/tools/wg.8
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+ExecStartPre=/sbin/ip link add dev %i type wireguard
+ExecStart=/usr/bin/wg setconf %i /etc/wireguard/%i.conf
+ExecStop=/sbin/ip link del %i
+ExecReload=/usr/bin/wg setconf %i /etc/wireguard/%i.conf
+
+[Install]
+WantedBy=multi-user.target
-- 
2.13.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-05-26 20:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-26  8:44 [PATCH] tools: add wireguard@.service Florian Klink
2017-05-26 15:30 ` Daniel Kahn Gillmor
2017-05-26 17:01   ` Florian Klink
2017-05-26 21:09   ` Jörg Thalheim

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.