diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index cb8cfe0..1342520 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -27,6 +27,9 @@ project(FastNetMon) set (FASTNETMON_VERSION_MAJOR 1) set (FASTNETMON_VERSION_MINOR 1) +set(CMAKE_INSTALL_SYSTEMD_SERVICEDIR "/lib/systemd/system" + CACHE PATH "Location for systemd service files") + if (ENABLE_GOBGP_SUPPORT) # We could not compile gRPC without C++ 11 set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -std=c++11") @@ -600,6 +603,10 @@ install(FILES networks_whitelist DESTINATION "${CMAKE_INSTALL_SYSCONFDIR}") install(FILES man/fastnetmon.1 DESTINATION /usr/share/man/man1) install(FILES man/fastnetmon_client.1 DESTINATION /usr/share/man/man1) +# service files +configure_file(fastnetmon.service.in "${CMAKE_CURRENT_BINARY_DIR}/fastnetmon.service" @ONLY) +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/fastnetmon.service" DESTINATION ${CMAKE_INSTALL_SYSTEMD_SERVICEDIR}) + # Configure cpack package builder # Run it with: cd build; cpack -G DEB .. set(CPACK_PACKAGE_NAME "fastnetmon") diff --git a/src/fastnetmon.service b/src/fastnetmon.service.in similarity index 85% rename from src/fastnetmon.service rename to src/fastnetmon.service.in index d7e2fdc..ffca8b8 100644 --- a/src/fastnetmon.service +++ b/src/fastnetmon.service.in @@ -4,7 +4,7 @@ After=syslog.target network.target remote-fs.target [Service] Type=forking -ExecStart=/opt/fastnetmon/fastnetmon --daemonize +ExecStart=@CMAKE_INSTALL_SBINDIR@/fastnetmon --daemonize PIDFile=/run/fastnetmon.pid Restart=on-failure RestartSec=3