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

add systemd contrib & rpm spec #216

Open
wants to merge 7 commits into
base: master
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
78 changes: 78 additions & 0 deletions contrib/rpm/opensuse_udpt.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#
# spec file for package udpt
#
# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


Name: udpt
Version: 3.1.2
Release: 0
Summary: A lightweight UDP torrent tracker
License: MIT
URL: https://github.com/naim94a/udpt
Source0: udpt-3.1.2.tar.zst
Source1: vendor.tar.zst
Source2: contrib.tar.zst
BuildRequires: cargo-packaging
BuildRequires: systemd-rpm-macros
BuildRequires: sysuser-tools
BuildRequires: zstd
Provides: user(udpt)
%{sysusers_requires}

%description
UDPT is a lightweight torrent tracker that uses the UDP protocol for tracking and fully implements BEP-15. This project was developed with security & simplicity in mind, so it shouldn't be difficult to get a server started.

%prep
%setup -qa1 -qa2
#%%autosetup -a2 -a1

%build
%{cargo_build}

%check
cargo test --offline --verbose

%install
install -Dm 755 target/release/udpt-rs %{buildroot}%{_bindir}/udpt
install -Dm 644 contrib/systemd/udpt.service %{buildroot}%{_unitdir}/udpt.service
install -Dm 644 contrib/systemd/udpt.tmpfiles %{buildroot}%{_tmpfilesdir}/udpt.conf
install -Dm 644 contrib/systemd/udpt.sysusers %{buildroot}%{_sysusersdir}/system-user-udpt.conf
install -Dm 644 contrib/systemd/udpt.conf %{buildroot}%{_sysconfdir}/udpt.conf

%files
%license LICENSE
%doc README.md docs/src/config.md docs/src/tracking_modes.md docs/src/api.md
%config(noreplace) %{_sysconfdir}/udpt.conf
%{_bindir}/udpt
%{_unitdir}/udpt.service
%{_tmpfilesdir}/udpt.conf
%{_sysusersdir}/system-user-udpt.conf

%pre
%service_add_pre udpt.service

%post
%sysusers_create %{_sysusersdir}/system-user-udpt.conf
%tmpfiles_create %{_tmpfilesdir}/udpt.conf
%service_add_post udpt.service

%preun
%service_del_preun udpt.service

%postun
%service_del_postun udpt.service

%changelog
35 changes: 35 additions & 0 deletions contrib/systemd/udpt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Root Level
# mode - Required. Possbile Values: private, static or dynamic.
# log_level - Default: info. Possible Values: off, error, warning, info, debug, trace.
# db_path - Database path. If not set, database will be volatile.
# cleanup_interval - Default: 600. Interval to run cleanup in seconds. Cleanup also saves the Database.
#
# [udp] section
# This section must exist.
# bind_address - Required. This is where the UDP port will bind to. Example: 0.0.0.0:6969.
# announce_interval - Required. Sets the announce_interval that will be sent to peers (in seconds).
#
# [http] section
# This section is optional.
# bind_address - Required (if section exists). The HTTP REST API will be bound to this address.
# It's best not to expose this address publically. Example: 127.0.0.1:1234.
#
# [http.access_tokens] section
# Section is required if [http] section exists.
#
# In this section you can make up keys that would be user ids, and values that would be their access token. If this section is empty, the REST API will not be very useful.

mode = "dynamic"
db_path = "udpt_database.json.bz2"
log_level = "info"
cleanup_interval = 600

[udp]
announce_interval = 120
bind_address = "0.0.0.0:1212"

[http]
bind_address = "0.0.0.0:1212"

[http.access_tokens]
someone = "MyAccessToken"
27 changes: 27 additions & 0 deletions contrib/systemd/udpt.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[Unit]
Description=UDPT is a lightweight torrent tracker
Wants=network-online.target
After=multi-user.target network.target network-online.target

[Service]
Type=simple
User=udpt
Group=udpt
WorkingDirectory=/var/lib/udpt
ExecStart=/usr/bin/udpt -c /etc/udpt.conf
Restart=always
RestartSec=30
TimeoutStartSec=300
NoNewPrivileges=yes
PrivateTmp=yes
PrivateDevices=yes
ProtectKernelTunables=yes
ProtectKernelModules=yes
ProtectControlGroups=yes
ProtectSystem=strict
ProtectHome=read-only
SystemCallFilter=~@mount
ReadWritePaths=/var/lib/udpt

[Install]
WantedBy=multi-user.target
3 changes: 3 additions & 0 deletions contrib/systemd/udpt.sysusers
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
u udpt - "udpt user" /var/lib/udpt -
g udpt - -
m udpt udpt
1 change: 1 addition & 0 deletions contrib/systemd/udpt.tmpfiles
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
d /var/lib/udpt 700 udpt udpt