Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

README.md: use "systemctl reload" #362

Closed
wants to merge 1 commit into from

Conversation

jakob-tsd
Copy link

@jakob-tsd jakob-tsd commented Apr 17, 2023

This fixes two problems:

1) systemctl may not live in /usr/bin/systemctl but in /bin. This is what I got on my Debian Bullseye that was upgraded over many generations:

systemd[1]: Starting wg0-reload.service...
systemd[1609458]: wg0-reload.service: Failed to locate executable /usr/bin/systemctl: No such file or directory
systemd[1609458]: wg0-reload.service: Failed at step EXEC spawning /usr/bin/systemctl: No such file or directory
systemd[1]: wg0-reload.service: Main process exited, code=exited, status=203/EXEC
systemd[1]: wg0-reload.service: Failed with result 'exit-code'.
systemd[1]: Failed to start wg0-reload.service.

After this change:

systemd[1]: Starting wg0-reload.service...
systemd[1]: Reloading WireGuard via wg-quick(8) for wg0.
systemd[1]: Reloaded WireGuard via wg-quick(8) for wg0.
systemd[1]: wg0-reload.service: Succeeded.
systemd[1]: Finished wg0-reload.service.

The docs for ExecStart say

https://www.freedesktop.org/software/systemd/man/systemd.service.html :

[...] either an absolute path to an executable or a simple file name without any slashes

So this is OK, and works fine as tested here.

2) Using "reload" instead of "restart" avoids breaking existing connections.

Supersedes #316 Fixes #228 Fixes #167

This fixes two problems:

1) systemctl may not live in /usr/bin/systemctl but in /bin.
This is what I got on my Debian Bullseye that was upgraded over many generations:

	systemd[1]: Starting wg0-reload.service...
	systemd[1609458]: wg0-reload.service: Failed to locate executable /usr/bin/systemctl: No such file or directory
	systemd[1609458]: wg0-reload.service: Failed at step EXEC spawning /usr/bin/systemctl: No such file or directory
	systemd[1]: wg0-reload.service: Main process exited, code=exited, status=203/EXEC
	systemd[1]: wg0-reload.service: Failed with result 'exit-code'.
	systemd[1]: Failed to start wg0-reload.service.

After this change:

	systemd[1]: Starting wg0-reload.service...
	systemd[1]: Reloading WireGuard via wg-quick(8) for wg0.
	systemd[1]: Reloaded WireGuard via wg-quick(8) for wg0.
	systemd[1]: wg0-reload.service: Succeeded.
	systemd[1]: Finished wg0-reload.service.

The docs for ExecStart say

	https://www.freedesktop.org/software/systemd/man/systemd.service.html :

	[...] either an absolute path to an executable or a simple file name without any slashes

So this is OK, and works fine as tested here.

2) Using "reload" instead of "restart" avoids breaking existing
connections.

Supersedes ngoduykhanh#316
Fixes ngoduykhanh#228
Fixes ngoduykhanh#167
@ngoduykhanh
Copy link
Owner

Does it work for every distro? My ubuntu server gave errors

May 24 10:12:25 server-1 systemd[1]: Starting Restart WireGuard...
May 24 10:12:25 server-1 systemctl[1733902]: Failed to reload wg-quick@wg0.service: Job type reload is not applicable for unit wg-quick@wg0.service.
May 24 10:12:25 server-1 systemd[1]: wgui.service: Main process exited, code=exited, status=3/NOTIMPLEMENTED
May 24 10:12:25 server-1 systemd[1]: wgui.service: Failed with result 'exit-code'.
May 24 10:12:25 server-1 systemd[1]: Failed to start Restart WireGuard.

@petiepooo
Copy link

Ubuntu 22.04 has this line in the [Service] portion of wg-quick@.service def:

ExecReload=/bin/bash -c 'exec /usr/bin/wg syncconf %i <(exec /usr/bin/wg-quick strip %i)'

Ubuntu 20.04 does not.

@DrTon
Copy link

DrTon commented Nov 9, 2023

Does it work for every distro? My ubuntu server gave errors

May 24 10:12:25 server-1 systemd[1]: Starting Restart WireGuard...
May 24 10:12:25 server-1 systemctl[1733902]: Failed to reload wg-quick@wg0.service: Job type reload is not applicable for unit wg-quick@wg0.service.
May 24 10:12:25 server-1 systemd[1]: wgui.service: Main process exited, code=exited, status=3/NOTIMPLEMENTED
May 24 10:12:25 server-1 systemd[1]: wgui.service: Failed with result 'exit-code'.
May 24 10:12:25 server-1 systemd[1]: Failed to start Restart WireGuard.

Doesn't work for me on Ubuntu 20.0.4.

But if in wgui.service I put:

ExecStart=/bin/bash -c 'exec /usr/bin/wg syncconf wg0 <(exec /usr/bin/wg-quick strip wg0)'

it works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants