diff --git a/speedtest-rs.service b/speedtest-rs.service new file mode 100644 index 0000000..587fad2 --- /dev/null +++ b/speedtest-rs.service @@ -0,0 +1,20 @@ +[Unit] +Description=Speedtest-rs Server +Documentation=https://cloud.silique.fr/gitea/Silique/speedtest-rs +After=network.target + +[Service] +User=speedtest +Group=speedtest +Environment=LATITUDE=0.0 LONGITUDE=0.0 SPEEDTEST_DIR=/var/lib/speedtest-rs SPEEDTEST_PORT=80 +EnvironmentFile=-/etc/speedtest-rs/config.sh +ExecStart=/usr/bin/speedtest-rs --ip=0.0.0.0 --port=${SPEEDTEST_PORT} --assets=${SPEEDTEST_DIR} --ipinfo_token=${IPINFO_TOKEN} --latitude=${LATITUDE} --longitude=${LONGITUDE} --cert=${SPEEDTEST_CERT} --key=${SPEEDTEST_KEY} --ca_cert=${SPEEDTEST_CA_CERT} +PrivateTmp=true +PrivateDevices=true +ProtectHome=true +ProtectSystem=strict +# Allow speedtest-rs to bind ports in the range of 0-1024 +AmbientCapabilities=CAP_NET_BIND_SERVICE + +[Install] +WantedBy=multi-user.target diff --git a/speedtest-rs.spec b/speedtest-rs.spec new file mode 100644 index 0000000..1be4115 --- /dev/null +++ b/speedtest-rs.spec @@ -0,0 +1,50 @@ +%define debug_package %{nil} +%define repo https://cloud.silique.fr/gitea/Silique/speedtest-rs + +Name: speedtest-rs +Version: 1.0.0 +Release: 1%{?dist} +Summary: Unofficial Librespeed compatible server written in Rust +License: LGPL-3.0-only +URL: %{repo} +Source0: %{repo}/archive/%{version}.tar.gz +Source1: speedtest-rs.service +Source2: speedtest-rs.sysusers +BuildRequires: pkgconfig(openssl) +BuildRequires: systemd +BuildRequires: systemd-rpm-macros +BuildRequires: rust-packaging + +%description +A Librespeed server API implementation written in Rust compatible with upstream Librespeed clients. + +%prep +%setup -qn speedtest-rs + +%build +cargo build --release + +%install +install -d %{buildroot}%{_sysconfdir}/%{name} +install -Dpm 755 target/release/speedtest-rs %{buildroot}%{_bindir}/speedtest-rs +install -d %{buildroot}%{_sharedstatedir}/%{name} +install -Dpm 644 assets/* %{buildroot}%{_sharedstatedir}/%{name} +ln -s example-singleServer-full.html %{buildroot}%{_sharedstatedir}/%{name}/index.html +install -Dpm 644 %{SOURCE1} %{buildroot}%{_unitdir}/speedtest-rs.service +install -Dpm 644 %{SOURCE2} %{buildroot}%{_sysusersdir}/speedtest-rs.conf + +%files +%license LICENSE +%{_sysconfdir}/%{name} +%{_bindir}/speedtest-rs +%{_sharedstatedir}/%{name} +%{_unitdir}/speedtest-rs.service +%{_sysusersdir}/speedtest-rs.conf + +%pre +%sysusers_create_compat %{SOURCE2} + +%changelog +* Sat Oct 15 2022 Emmanuel Garette 1.0.0 +- Initial rpm : version 1.0.0 + diff --git a/speedtest-rs.sysusers b/speedtest-rs.sysusers new file mode 100644 index 0000000..b52455c --- /dev/null +++ b/speedtest-rs.sysusers @@ -0,0 +1 @@ +u speedtest - "Speedtest server" /var/lib/speedtest-rs /sbin/nologin