From cb03e4ac1c4c633df3f238c58189461b886897b4 Mon Sep 17 00:00:00 2001 From: Victor Antonovich Date: Tue, 20 Feb 2018 23:42:19 +0300 Subject: [PATCH] Fix path to mbusd binary in systemd service file (#27) --- CMakeLists.txt | 16 +++++++++++----- README.md | 2 +- systemd-units/mbusd@.service.in | 2 +- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7009788..4dbd28f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,12 +1,13 @@ cmake_minimum_required(VERSION 3.2) + +project(mbusd VERSION 0.3.1) + list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/extern_GPL) include(CheckFunctionExists) include(CheckLibraryExists) include(GNUInstallDirs) include(FindSystemd) -project(mbusd VERSION 0.3.0) - #TODO ISC_Posix, prog_libtool # single-configuration generator setup SET(BASIC_C_FLAGS "-W -pedantic -fno-builtin-log -Wall") @@ -73,7 +74,7 @@ install(TARGETS mbusd DESTINATION bin) # aggregate the man page template configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doc/mbusd.8.in mbusd.8) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/mbusd.8 DESTINATION share/man/man8) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/mbusd.8 DESTINATION ${CMAKE_INSTALL_FULL_DATADIR}/man/man8) # install example configuration file install( @@ -85,7 +86,7 @@ if(SYSTEMD_FOUND) message(STATUS "Systemd service file will be installed to ${SYSTEMD_SERVICES_INSTALL_DIR}") # aggregate mbusd@.service from its template configure_file(${CMAKE_CURRENT_SOURCE_DIR}/systemd-units/mbusd@.service.in mbusd@.service) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/mbusd@.service DESTINATION ${SYSTEMD_SERVICES_INSTALL_DIR}) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/mbusd@.service DESTINATION ${SYSTEMD_SERVICES_INSTALL_DIR}) endif() # uninstall target @@ -140,4 +141,9 @@ set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE") set(CPACK_SOURCE_STRIP_FILES TRUE) set(CPACK_STRIP_FILES TRUE) #the include must be after all the cpack concerning set's -include(CPack) \ No newline at end of file +include(CPack) + +message(STATUS "Install prefix ${CMAKE_INSTALL_PREFIX}") +message(STATUS "Install bindir: ${CMAKE_INSTALL_FULL_BINDIR}") +message(STATUS "Install sysconfdir: ${CMAKE_INSTALL_FULL_SYSCONFDIR}") +message(STATUS "Install datadir: ${CMAKE_INSTALL_FULL_DATADIR}") diff --git a/README.md b/README.md index 9d5611e..bc03332 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ Installation instructions: $ git clone https://github.com/3cky/mbusd.git mbusd.git $ cd mbusd.git $ mkdir -p build && cd build -$ cmake ../ +$ cmake -DCMAKE_INSTALL_PREFIX=/usr .. $ make $ sudo make install ``` diff --git a/systemd-units/mbusd@.service.in b/systemd-units/mbusd@.service.in index 4b9c6e6..3a8e2cb 100644 --- a/systemd-units/mbusd@.service.in +++ b/systemd-units/mbusd@.service.in @@ -3,7 +3,7 @@ Description=Modbus TCP to Modbus RTU (RS-232/485) gateway. Requires=network.target [Service] -ExecStart=@CMAKE_INSTALL_FULL_BINDIR@/mbusd -d -v2 -L - -c /etc/mbusd/mbusd-%i.conf -p /dev/%i +ExecStart=@CMAKE_INSTALL_FULL_BINDIR@/mbusd -d -v2 -L - -c @CMAKE_INSTALL_FULL_SYSCONFDIR@/mbusd/mbusd-%i.conf -p /dev/%i Restart=on-failure RestartSec=1 StandardOutput=journal