Skip to content
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
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,6 @@ if(GPUFANCTL_ENABLE_TESTS)
add_subdirectory(tests)
endif()

add_subdirectory(init)

install(TARGETS gpufanctl)
45 changes: 45 additions & 0 deletions init/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
configure_file(
runit/run.in
sv/gpufanctl/run
@ONLY
)

configure_file(
systemd/gpufanctl.service.in
systemd/user/gpufanctl.service
@ONLY
)

include(GNUInstallDirs)

# Installs the runit service. Not installed by default. Requires...
#
# ```
# $ cmake --install . --component gpufanctl-runit
# ```
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/sv/gpufanctl/run"
DESTINATION "${CMAKE_INSTALL_SYSCONFDIR}/sv/gpufanctl"
PERMISSIONS
OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE
COMPONENT gpufanctl-runit
EXCLUDE_FROM_ALL
)

# Installs the systemd unit file. Not installed by default. Requires...
#
# ```
# $ cmake --install . --component gpufanctl-systemd
# ```
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/systemd/user/gpufanctl.service"
DESTINATION "lib/systemd/user/gpufanctl.service"
PERMISSIONS
OWNER_READ OWNER_WRITE
GROUP_READ
WORLD_READ
COMPONENT gpufanctl-systemd
EXCLUDE_FROM_ALL
)
9 changes: 9 additions & 0 deletions init/runit/run.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh

exec 2>&1

if [ -r ./conf ]; then
. ./conf
fi

exec @CMAKE_INSTALL_FULL_BINDIR@/gpufanctl ${OPTS} "${CURVE_DEFINITION}"
14 changes: 14 additions & 0 deletions init/systemd/gpufanctl.service.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Unit]
Description=GPU fan control
After=multi-user.target

[Service]
Type=simple
ExecStart=@CMAKE_INSTALL_FULL_BINDIR@/gpufanctl
Restart=always
RestartSec=5s
StandardOutput=journal
StandardError=journal

[Install]
WantedBy=multi-user.target