Added support for installing a systemd unit file for wesnothd

This commit is contained in:
Sergey Popov 2012-08-24 15:55:19 +00:00
parent a37bd824eb
commit c62cccd0ab
6 changed files with 36 additions and 1 deletions

View File

@ -412,6 +412,7 @@ if(ENABLE_GAME OR ENABLE_TESTS)
find_package( PkgConfig REQUIRED )
pkg_check_modules( PANGOCAIRO REQUIRED pangocairo>=1.14.8 )
pkg_check_modules( FONTCONFIG REQUIRED fontconfig>=2.4.1 )
pkg_check_modules( SYSTEMD systemd )
endif(NOT MSVC)
endif(ENABLE_GAME OR ENABLE_TESTS)
@ -502,6 +503,13 @@ endif(ENABLE_DESKTOP_ENTRY AND ENABLE_GAME)
if(ENABLE_SERVER AND FIFO_DIR)
install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory \$ENV{DESTDIR}/${FIFO_DIR})")
# install systemd stuff if it is installed
if(SYSTEMD_FOUND)
configure_file(packaging/systemd/wesnothd.tmpfiles.conf.in ${CMAKE_BINARY_DIR}/wesnothd.conf)
configure_file(packaging/systemd/wesnothd.service.in ${CMAKE_BINARY_DIR}/wesnothd.service)
install(FILES ${CMAKE_BINARY_DIR}/wesnothd.conf DESTINATION lib/tmpfiles.d)
install(FILES ${CMAKE_BINARY_DIR}/wesnothd.service DESTINATION lib/systemd/system)
endif()
if(SERVER_UID AND SERVER_GID)
install(CODE "execute_process(COMMAND chown ${SERVER_UID}:${SERVER_GID} \$ENV{DESTDIR}/${FIFO_DIR})")
endif()

View File

@ -59,6 +59,7 @@ opts.AddVariables(
PathVariable('fifodir', 'directory for the wesnothd fifo socket file', "/var/run/wesnothd", PathVariable.PathAccept),
BoolVariable('fribidi','Clear to disable bidirectional-language support', True),
BoolVariable('desktop_entry','Clear to disable desktop-entry', True),
BoolVariable('systemd','Install systemd unit file for wesnothd', bool(WhereIs("systemd"))),
PathVariable('datarootdir', 'sets the root of data directories to a non-default location', "share", PathVariable.PathAccept),
PathVariable('datadirname', 'sets the name of data directory', "wesnoth$version_suffix", PathVariable.PathAccept),
PathVariable('desktopdir', 'sets the desktop entry directory to a non-default location', "$datarootdir/applications", PathVariable.PathAccept),
@ -461,7 +462,7 @@ else:
env["svnrev"] = ""
Export(Split("env client_env test_env have_client_prereqs have_server_prereqs have_test_prereqs"))
SConscript(dirs = Split("po doc packaging/windows"))
SConscript(dirs = Split("po doc packaging/windows packaging/systemd"))
binaries = Split("wesnoth wesnothd cutter exploder campaignd test")
builds = {
@ -572,6 +573,9 @@ if not access(fifodir, F_OK):
])
AlwaysBuild(fifodir)
env.Alias("install-wesnothd", fifodir)
if env["systemd"]:
env.InstallData("prefix", "wesnothd", "#packaging/systemd/wesnothd.service", "lib/systemd/system")
env.InstallData("prefix", "wesnothd", "#packaging/systemd/wesnothd.conf", "lib/tmpfiles.d")
# Wesnoth campaign server
env.InstallBinary(campaignd)

View File

@ -0,0 +1,4 @@
Import("env")
env.ScanReplace("wesnothd.service", "wesnothd.service.scons.in")
env.ScanReplace("wesnothd.conf", "wesnothd.tmpfiles.conf.in")

View File

@ -0,0 +1,9 @@
[Unit]
Description=Wesnoth Server Daemon
After=network.target
[Service]
ExecStart=@CMAKE_INSTALL_PREFIX@/@BINDIR@/wesnothd
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,9 @@
[Unit]
Description=Wesnoth Server Daemon
After=network.target
[Service]
ExecStart=%bindir/wesnothd
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1 @@
d @FIFO_DIR@ 0700 root root -