From b41d8023b6f811ec39069ac0db89c9709d227e6a Mon Sep 17 00:00:00 2001 From: Dmitrii Krosh Date: Wed, 24 Jun 2026 18:52:56 +0300 Subject: [PATCH] add systemd templates --- README.md | 66 +++++++++++++++++++ template/{darwin.yaml => darwin-config.yaml} | 0 template/{linux.yaml => linux-config.yaml} | 0 template/systemd/nexus-sync-client.service | 8 +++ template/systemd/nexus-sync-client.timer | 12 ++++ template/systemd/nexus-sync-server.service | 15 +++++ .../{windows.yaml => windows-config.yaml} | 0 7 files changed, 101 insertions(+) rename template/{darwin.yaml => darwin-config.yaml} (100%) rename template/{linux.yaml => linux-config.yaml} (100%) create mode 100644 template/systemd/nexus-sync-client.service create mode 100644 template/systemd/nexus-sync-client.timer create mode 100644 template/systemd/nexus-sync-server.service rename template/{windows.yaml => windows-config.yaml} (100%) diff --git a/README.md b/README.md index f54dda4..1575543 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,72 @@ later heartbeat. make [client|server] ``` +## systemd templates + +Template units are available in: + +```text +template/systemd/nexus-sync-server.service +template/systemd/nexus-sync-client.service +template/systemd/nexus-sync-client.timer +``` + +Replace `ExecStart` with the absolute path to your built binary or script before installing. +For example: + +```ini +ExecStart=/opt/nexus-sync/nexus-sync-server +``` + +The client is a oneshot service triggered by a timer every minute. + +### Install server service + +```bash +sudo install -Dm644 template/systemd/nexus-sync-server.service \ + /etc/systemd/system/nexus-sync-server.service +sudo editor /etc/systemd/system/nexus-sync-server.service +sudo mkdir -p /var/lib/nexus-sync +sudo systemctl daemon-reload +sudo systemctl enable --now nexus-sync-server.service +``` + +Optional server env file used by the template: + +```bash +sudo install -Dm600 .env.example /etc/nexus-sync/server.env +sudo editor /etc/nexus-sync/server.env +sudo systemctl restart nexus-sync-server.service +``` + +### Install client timer + +```bash +sudo install -Dm644 template/systemd/nexus-sync-client.service \ + /etc/systemd/system/nexus-sync-client.service +sudo install -Dm644 template/systemd/nexus-sync-client.timer \ + /etc/systemd/system/nexus-sync-client.timer +sudo editor /etc/systemd/system/nexus-sync-client.service +sudo systemctl daemon-reload +sudo systemctl enable --now nexus-sync-client.timer +``` + +Install the client YAML config separately, for example: + +```bash +sudo install -Dm600 template/linux.yaml /root/.config/nexus/config.yaml +sudo editor /root/.config/nexus/config.yaml +``` + +Check status and logs: + +```bash +systemctl status nexus-sync-server.service +systemctl list-timers nexus-sync-client.timer +journalctl -u nexus-sync-server.service -f +journalctl -u nexus-sync-client.service -f +``` + ### To test ``` diff --git a/template/darwin.yaml b/template/darwin-config.yaml similarity index 100% rename from template/darwin.yaml rename to template/darwin-config.yaml diff --git a/template/linux.yaml b/template/linux-config.yaml similarity index 100% rename from template/linux.yaml rename to template/linux-config.yaml diff --git a/template/systemd/nexus-sync-client.service b/template/systemd/nexus-sync-client.service new file mode 100644 index 0000000..120122a --- /dev/null +++ b/template/systemd/nexus-sync-client.service @@ -0,0 +1,8 @@ +[Unit] +Description=nexus-sync client heartbeat and command runner +After=network-online.target +Wants=network-online.target + +[Service] +Type=oneshot +ExecStart=/absolute/path/to/nexus-sync-client diff --git a/template/systemd/nexus-sync-client.timer b/template/systemd/nexus-sync-client.timer new file mode 100644 index 0000000..3ba039d --- /dev/null +++ b/template/systemd/nexus-sync-client.timer @@ -0,0 +1,12 @@ +[Unit] +Description=Run nexus-sync client every minute + +[Timer] +OnBootSec=30s +OnUnitActiveSec=1min +AccuracySec=5s +Persistent=true +Unit=nexus-sync-client.service + +[Install] +WantedBy=timers.target diff --git a/template/systemd/nexus-sync-server.service b/template/systemd/nexus-sync-server.service new file mode 100644 index 0000000..a11c2ed --- /dev/null +++ b/template/systemd/nexus-sync-server.service @@ -0,0 +1,15 @@ +[Unit] +Description=nexus-sync server +After=network-online.target +Wants=network-online.target + +[Service] +Type=simple +ExecStart=/absolute/path/to/nexus-sync-server +Restart=on-failure +RestartSec=5s +EnvironmentFile=-/etc/nexus-sync/server.env +WorkingDirectory=/var/lib/nexus-sync + +[Install] +WantedBy=multi-user.target diff --git a/template/windows.yaml b/template/windows-config.yaml similarity index 100% rename from template/windows.yaml rename to template/windows-config.yaml