Mercurial > irccd
changeset 1109:251976043986
cmake: add systemd service
author | David Demelier <markand@malikania.fr> |
---|---|
date | Wed, 20 Oct 2021 15:54:07 +0200 |
parents | a09d4c9b8518 |
children | 8c53096eef1e |
files | CMakeLists.txt systemd/CMakeLists.txt systemd/irccd.service systemd/irccd.service.in |
diffstat | 4 files changed, 58 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/CMakeLists.txt Wed Oct 20 15:45:18 2021 +0200 +++ b/CMakeLists.txt Wed Oct 20 15:54:07 2021 +0200 @@ -58,6 +58,9 @@ option(IRCCD_WITH_SSL "Enable SSL (requires OpenSSL)" On) option(IRCCD_WITH_TESTS "Enable unit tests" On) +set(IRCCD_WITH_UID "irccd" CACHE STRING "Default uid to run irccd as") +set(IRCCD_WITH_GID "irccd" CACHE STRING "Default gid to run irccd as") + # Check presence of POSIX m library find_library(M_LIBRARY m libm) @@ -81,6 +84,7 @@ add_subdirectory(irccd) add_subdirectory(irccdctl) add_subdirectory(plugins) +add_subdirectory(systemd) if (IRCCD_WITH_EXAMPLES) add_subdirectory(examples)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/systemd/CMakeLists.txt Wed Oct 20 15:54:07 2021 +0200 @@ -0,0 +1,43 @@ +# +# CMakeLists.txt -- CMake build system for irccd +# +# Copyright (c) 2013-2021 David Demelier <markand@malikania.fr> +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +# + +project(systemd) + +find_program(systemd SYSTEMD_EXECUTABLE) + +if (SYSTEMD_EXECUTABLE) + set(default On) +else () + set(default Off) +endif () + +option(IRCCD_WITH_SYSTEMD "Install irccd.service" ${default}) + +if (IRCCD_WITH_SYSTEMD) + set(PATH ${CMAKE_INSTALL_FULL_BINDIR}/irccd) + + configure_file( + ${systemd_SOURCE_DIR}/irccd.service.in + ${systemd_BINARY_DIR}/irccd.service + ) + + install( + FILES ${systemd_BINARY_DIR}/irccd.service + DESTINATION ${CMAKE_INSTALL_LIBDIR}/systemd/system + ) +endif ()
--- a/systemd/irccd.service Wed Oct 20 15:45:18 2021 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,11 +0,0 @@ -[Unit] -Description=IRC Client Daemon -After=network.target - -[Service] -ExecStart=@PATH@ -User=@USER@ -Group=@GROUP@ - -[Install] -WantedBy=multi-user.target
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/systemd/irccd.service.in Wed Oct 20 15:54:07 2021 +0200 @@ -0,0 +1,11 @@ +[Unit] +Description=IRC Client Daemon +After=network.target + +[Service] +ExecStart=@PATH@ +User=@IRCCD_WITH_UID@ +Group=@IRCCD_WITH_GID@ + +[Install] +WantedBy=multi-user.target