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

wgsd-client: Add systemd timer/service example #52

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions cmd/wgsd-client/systemd/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# wgsd-client systemd Integration

systemd timers can be used to periodically invoke `wgsd-client`.

## Installation

* Copy `[email protected]` to `/etc/systemd/system/`.
* Copy `[email protected]` to `/etc/systemd/system/`.

## Configuration

* To configure `wgsd-client` for WireGuard interface `wg-foo` copy `wg-example.template.env` to `/etc/wgsd/wg-foo.env` and adjust variables accordingly.

## Activation

* To activate periodic `wgsd-client` invocation for WireGuard interface `wg-foo` run `systemctl enable [email protected]`.
17 changes: 17 additions & 0 deletions cmd/wgsd-client/systemd/etc/systemd/system/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[Unit]
Description=WireGuard Service Discovery (wgsd) Client
Wants=network-online.target
After=network-online.target

[Service]
PermissionsStartOnly=true
LimitNOFILE=512
LimitNPROC=16
CapabilityBoundingSet=CAP_NET_ADMIN
AmbientCapabilities=CAP_NET_ADMIN
NoNewPrivileges=true
User=wgsd-client
Group=wgsd-client
DynamicUser=true
EnvironmentFile=/etc/wgsd/%i.env
ExecStart=/usr/local/bin/wgsd-client -device %i -dns $DNS -zone $ZONE
11 changes: 11 additions & 0 deletions cmd/wgsd-client/systemd/etc/systemd/system/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Unit]
Description=Run WireGuard Service Discovery (wgsd) Client

[Timer]
OnActiveSec=10
OnUnitActiveSec=45
AccuracySec=1s
Persistent=true

[Install]
WantedBy=timers.target
2 changes: 2 additions & 0 deletions cmd/wgsd-client/systemd/etc/wgsd/wg-example.template.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DNS=10.13.37.1:5353
ZONE=wg.example.net.