Skip to content

Commit

Permalink
bpfilter: add systemd service file
Browse files Browse the repository at this point in the history
Configure and install a systemd service file to manage the daemon.
  • Loading branch information
qdeslandes committed Feb 4, 2025
1 parent f9377ff commit a048676
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/bpfilter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
find_package(PkgConfig REQUIRED)
pkg_check_modules(nl REQUIRED IMPORTED_TARGET libnl-3.0)

configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/bpfilter.service.in
${CMAKE_BINARY_DIR}/output/usr/lib/systemd/system/bpfilter.service
@ONLY
)

add_executable(bpfilter
${CMAKE_CURRENT_SOURCE_DIR}/main.c
${CMAKE_CURRENT_SOURCE_DIR}/cgen/cgen.h ${CMAKE_CURRENT_SOURCE_DIR}/cgen/cgen.c
Expand Down Expand Up @@ -53,3 +59,9 @@ target_link_libraries(bpfilter
install(TARGETS bpfilter
DESTINATION ${CMAKE_INSTALL_SBINDIR}
)

message("${CMAKE_INSTALL_PREFIX}")
install(
FILES ${CMAKE_BINARY_DIR}/output/usr/lib/systemd/system/bpfilter.service
DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/systemd/system
)
9 changes: 9 additions & 0 deletions src/bpfilter/bpfilter.service.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Unit]
Description=BPF-based packet filtering framework

[Service]
ExecStart=/usr/sbin/bpfilter --no-nftables --no-iptables
Restart=on-failure

[Install]
WantedBy=multi-user.target

0 comments on commit a048676

Please sign in to comment.