Merge pull request #20 from Lukas-Heiligenbrunner/servicebinarypackagesamename

Servicebinarypackagesamename
This commit is contained in:
Lukas-Heiligenbrunner 2020-05-21 14:16:35 +02:00 committed by GitHub
commit af4a9c8350
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 21 deletions

View File

@ -9,7 +9,7 @@
# for test build gtest needs to be installed. # for test build gtest needs to be installed.
cmake_minimum_required(VERSION 3.13) cmake_minimum_required(VERSION 3.13)
project(iprefresher DESCRIPTION "Dynu ip refresher" LANGUAGES) project(dynuiprefresher DESCRIPTION "Dynu ip refresher" LANGUAGES)
SET(PROJECT_VERSION 1.3.3) SET(PROJECT_VERSION 1.3.3)
# CONFIGURATION # CONFIGURATION
@ -24,6 +24,7 @@ option(WinBuild "cross compile for Windows Platform" OFF)
# helper variables # helper variables
SET(CMAKE_CXX_STANDARD 17) SET(CMAKE_CXX_STANDARD 17)
string(TIMESTAMP TIMESTAMP_NOW "%d.%m.%Y") string(TIMESTAMP TIMESTAMP_NOW "%d.%m.%Y")
SET(Application_Name "dynuiprefresher")
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
@ -142,7 +143,7 @@ endif ()
message("") message("")
#read sample config #read sample config
FILE(READ ${CMAKE_SOURCE_DIR}/config/iprefresher.cfg SAMPLECONFIG) FILE(READ ${CMAKE_SOURCE_DIR}/config/dynuiprefresher.cfg SAMPLECONFIG)
#add version header #add version header
FILE(WRITE ${CMAKE_SOURCE_DIR}/inc/Version.h FILE(WRITE ${CMAKE_SOURCE_DIR}/inc/Version.h
"/** "/**
@ -160,7 +161,7 @@ FILE(WRITE ${CMAKE_SOURCE_DIR}/inc/Version.h
namespace Version { namespace Version {
const std::string VERSION = \"${PROJECT_VERSION}\"; const std::string VERSION = \"${PROJECT_VERSION}\";
const std::string ConfigDir = ${CONFIG_PATH}; const std::string ConfigDir = ${CONFIG_PATH};
const std::string ConfName = \"iprefresher.cfg\"; const std::string ConfName = \"${Application_Name}.cfg\";
const std::string SAMPLECONFIG = R\"(${SAMPLECONFIG})\"; const std::string SAMPLECONFIG = R\"(${SAMPLECONFIG})\";
}" }"
) )
@ -171,7 +172,7 @@ add_library(api ${LIB_METHOD}
src/api/DynuAPI.cpp src/api/DynuAPI.cpp
src/api/IPAPI.cpp) src/api/IPAPI.cpp)
add_library(dynuiprefresher ${LIB_METHOD} add_library(libdynuiprefresher ${LIB_METHOD}
src/IPRefresher.cpp src/IPRefresher.cpp
src/Config.cpp src/Config.cpp
src/IpHelper.cpp src/IpHelper.cpp
@ -179,28 +180,25 @@ add_library(dynuiprefresher ${LIB_METHOD}
src/Logger.cpp src/Logger.cpp
) )
add_executable(iprefresher src/main.cpp) add_executable(${Application_Name} src/main.cpp)
# LINK generated LIBS # # LINK generated LIBS #
target_link_libraries(iprefresher dynuiprefresher api ${CURL_LIBRARIES} ${LIBCONFIG++_LIBRARIES}) target_link_libraries(${Application_Name} libdynuiprefresher api ${CURL_LIBRARIES} ${LIBCONFIG++_LIBRARIES})
# setting install targets # setting install targets
IF (NOT ${WinBuild}) IF (NOT ${WinBuild})
# INSTALL to Linux SYSTEM # # INSTALL to Linux SYSTEM #
# install binaries # install binaries
install(TARGETS iprefresher DESTINATION usr/bin) install(TARGETS ${Application_Name} DESTINATION usr/bin)
# install systemd service and enable it # install systemd service and enable it
install(FILES service/iprefresher.service DESTINATION lib/systemd/system) install(FILES service/${Application_Name}.service DESTINATION lib/systemd/system)
ELSE () ELSE ()
# INSTALL to Windows SYSTEM # # INSTALL to Windows SYSTEM #
# install binary to current folder # install binary to current folder
set_target_properties(iprefresher PROPERTIES SUFFIX ".exe") set_target_properties(${Application_Name} PROPERTIES SUFFIX ".exe")
install(TARGETS iprefresher DESTINATION .) install(TARGETS ${Application_Name} DESTINATION .)
# create config directory
install(DIRECTORY DESTINATION "../Common\ Files/iprefresher")
# install .dll dependencies # install .dll dependencies
# todo check if files exist... # todo check if files exist...
@ -242,8 +240,8 @@ if [ ! -f ${CONFIG_PATH} ]; then
${SAMPLECONFIG}EOM ${SAMPLECONFIG}EOM
fi fi
systemctl enable iprefresher.service systemctl enable ${Application_Name}.service
systemctl start iprefresher.service") systemctl start ${Application_Name}.service")
SET(CPACK_DEB_COMPONENT_INSTALL 1) SET(CPACK_DEB_COMPONENT_INSTALL 1)
@ -295,8 +293,8 @@ systemctl start iprefresher.service")
add_custom_target(build-packages add_custom_target(build-packages
"${CMAKE_COMMAND}" --build "${CMAKE_BINARY_DIR}" --target package "${CMAKE_COMMAND}" --build "${CMAKE_BINARY_DIR}" --target package
DEPENDS ${PROJECT_NAME} DEPENDS ${Application_Name}
COMMENT "Packing ${PROJECT_NAME}") COMMENT "Packing ${Application_Name}")
message("") message("")
ENDIF () ENDIF ()
@ -344,7 +342,7 @@ if (TESTS)
# create an exectuable in which the tests will be stored # create an exectuable in which the tests will be stored
add_executable(${TESTNAME} ${ARGN}) add_executable(${TESTNAME} ${ARGN})
# link the Google test infrastructure, mocking library, and a default main fuction to # link the Google test infrastructure, mocking library, and a default main fuction to
target_link_libraries(${TESTNAME} gtest gtest_main -lpthread -lm dynuiprefresher api ${CURL_LIBRARIES} ${LIBCONFIG++_LIBRARIES}) target_link_libraries(${TESTNAME} gtest gtest_main -lpthread -lm libdynuiprefresher api ${CURL_LIBRARIES} ${LIBCONFIG++_LIBRARIES})
# see https://cmake.org/cmake/help/v3.10/module/GoogleTest.html for more options to pass to it # see https://cmake.org/cmake/help/v3.10/module/GoogleTest.html for more options to pass to it
gtest_discover_tests(${TESTNAME}) gtest_discover_tests(${TESTNAME})

View File

@ -9,14 +9,14 @@ I'm providing executables for Debian/Ubuntu (.deb) and RHEL/Debian (.rpm).
But you can still compile the code my your own (see build section). But you can still compile the code my your own (see build section).
## Configuration ## Configuration
There is a configuration file `/etc/iprefresher.cfg` where you have to specify the DYNU API key (get it from their homepage), the domainid and your domain. There is a configuration file `/etc/dynuiprefresher.cfg` where you have to specify the DYNU API key (get it from their homepage), the domainid and your domain.
Furthermore, you can optionally specify a Telegram API key and a Chat ID if you want to be notfied when your local ip changes. Furthermore, you can optionally specify a Telegram API key and a Chat ID if you want to be notfied when your local ip changes.
To enable and start the service: To enable and start the service:
`systemctl enable iprefresher.service` and `systemctl start iprefresher.service` `systemctl enable dynuiprefresher.service` and `systemctl start dynuiprefresher.service`
## Usage ## Usage
First of all configure the right keys in the `/etc/iprefresher.cfg` or `%appdata%\DynuIpRefresher\iprefresher.cfg` config file. First of all configure the right keys in the `/etc/dynuiprefresher.cfg` or `%appdata%\DynuIpRefresher\dynuiprefresher.cfg` config file.
Afterwards use the following options: Afterwards use the following options: