Skip to content

Commit

Permalink
Package t2fanrd fan daemon
Browse files Browse the repository at this point in the history
The systemd service is run as root but is significanty hardened. There
is no default config file shipped.
  • Loading branch information
sharpenedblade committed Jan 29, 2024
1 parent e5afc55 commit 2947fdc
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ jobs:
rust-arraydeque/*
rust-nonempty/*
rust-rust-ini0.20/*
t2fanrd/*
dir_names: "true"

- name: "Increase Disk Space"
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/copr-webhooks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:
- "rust-arraydeque/*"
- "rust-nonempty/*"
- "rust-rust-ini0.20/*"
- "t2fanrd/*"

jobs:
copr-webhook:
Expand Down
2 changes: 1 addition & 1 deletion build-packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -e

if [ $# -eq 0 ]; then
packages=( "t2linux-config" "t2linux-audio" "rust-tiny-dfr" "kernel" "copr-sharpenedblade-t2linux-release" "rust-arraydeque" "rust-nonempty" "rust-rust-ini0.20" )
packages=( "t2linux-config" "t2linux-audio" "rust-tiny-dfr" "kernel" "copr-sharpenedblade-t2linux-release" "rust-arraydeque" "rust-nonempty" "rust-rust-ini0.20" "t2fanrd" )
else
packages=( "$@" )
fi
Expand Down
13 changes: 13 additions & 0 deletions copr-webhooks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

# Expects array $CHANGED_PACKAGES with list of changed packages
# Expects $COPR_API_CONFIG with copr API token

echo "$COPR_API_CONFIG" > ~/.config/copr

for package in "$CHANGED_PACKAGES"; do
echo $package
curl -X POST $COPR_WEBHOOK/$(echo $package )
done


34 changes: 34 additions & 0 deletions t2fanrd/t2fanrd.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[Unit]
Description=T2FanRD daemon to manage fan curves for t2 macs

[Service]
Type=exec
ExecStart=t2fanrd
Restart=always

PrivateTmp=true
ProtectSystem=true
ProtectHome=true
ProtectClock=true
ProtectHostname=true
ProtectControlGroups=true
ProtectHostname=true
ProtectKernelLogs=true
ProtectKernelModules=true
ProtectProc=invisible
PrivateDevices=true
PrivateNetwork=true
NoNewPrivileges=true
DevicePolicy=closed
KeyringMode=private
LockPersonality=true
MemoryDenyWriteExecute=true
PrivateUsers=yes
RemoveIPC=yes
RestrictNamespaces=yes
RestrictRealtime=yes
RestrictSUIDSGID=yes
SystemCallArchitectures=native

[Install]
WantedBy=multi-user.target
68 changes: 68 additions & 0 deletions t2fanrd/t2fanrd.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
%global forgeurl https://github.com/GnomedDev/T2FanRD
%global commit 68859ca5f858d542444c64391faa90678afb6995
%forgemeta -iv

%bcond_without check

# prevent library files from being installed
%global __cargo_is_lib() 0

%global crate t2fanrd

Name: t2fanrd
Version: 0.1.0
Release: 1%{?dist}
Summary: Simple Fan Daemon for T2 Macs

SourceLicense: GPL-3.0-or-later
License: GPL-3.0-or-later AND Apache-2.0 OR MIT AND MIT

URL: %{forgeurl}
Source0: %{forgesource}
Source1: t2fanrd.service

BuildRequires: cargo-rpm-macros >= 24
BuildRequires: systemd-rpm-macros

%description
Simple Fan Daemon for T2 Macs.

%prep
%forgeautosetup -p1
%cargo_prep

%generate_buildrequires
%cargo_generate_buildrequires

%build
%cargo_build
%{cargo_license_summary}
%{cargo_license} > LICENSE.dependencies

%install
%cargo_install
install -Dpm0644 -t %{buildroot}%{_unitdir} %{SOURCE1}

%if %{with check}
%check
%cargo_test
%endif

%post
%systemd_post %{crate}.service

%preun
%systemd_preun %{crate}.service

%postun
%systemd_postun_with_restart %{crate}.service

%files
%license LICENCE
%license LICENSE.dependencies
%doc README.md
%{_bindir}/%{crate}
%{_unitdir}/%{crate}.service

%changelog
%autochangelog

0 comments on commit 2947fdc

Please sign in to comment.