mirror of
https://github.com/SoftEtherVPN/SoftEtherVPN.git
synced 2024-11-23 01:49:53 +03:00
Merge PR #690: CMake: install systemd configuration files
This commit is contained in:
commit
8fdd224ba7
@ -31,6 +31,7 @@ matrix:
|
|||||||
- ./configure
|
- ./configure
|
||||||
- make -C tmp
|
- make -C tmp
|
||||||
- otool -L build/vpnserver/vpnserver
|
- otool -L build/vpnserver/vpnserver
|
||||||
|
- sudo make -C tmp install
|
||||||
|
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
@ -55,4 +56,5 @@ script:
|
|||||||
- ./configure
|
- ./configure
|
||||||
- make -C tmp
|
- make -C tmp
|
||||||
- ldd build/vpnserver/vpnserver
|
- ldd build/vpnserver/vpnserver
|
||||||
|
- sudo LD_LIBRARY_PATH="${HOME}/opt/lib:${LD_LIBRARY_PATH:-}" make -C tmp install
|
||||||
- if [ "${BUILD_DEB}" = "1" ]; then make package -C tmp; fi
|
- if [ "${BUILD_DEB}" = "1" ]; then make package -C tmp; fi
|
||||||
|
@ -1,19 +1,39 @@
|
|||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
macro(install_wrapper_script component target destination)
|
# Creates wrapper scripts and installs them in the user's binaries directory, which is usually "/usr/local/bin".
|
||||||
get_filename_component(filename ${target} NAME)
|
# This is required because symlinks use the folder they are in as working directory.
|
||||||
|
macro(install_wrapper_script component target)
|
||||||
|
get_filename_component(file_name ${target} NAME)
|
||||||
|
|
||||||
file(WRITE ${CMAKE_SOURCE_DIR}/tmp/script/${filename} "#!/bin/sh\n")
|
file(WRITE ${CMAKE_SOURCE_DIR}/tmp/script/${file_name} "#!/bin/sh\n")
|
||||||
file(APPEND ${CMAKE_SOURCE_DIR}/tmp/script/${filename} "${target} \"$@\"\n")
|
file(APPEND ${CMAKE_SOURCE_DIR}/tmp/script/${file_name} "${target} \"$@\"\n")
|
||||||
file(APPEND ${CMAKE_SOURCE_DIR}/tmp/script/${filename} "exit $?\n")
|
file(APPEND ${CMAKE_SOURCE_DIR}/tmp/script/${file_name} "exit $?\n")
|
||||||
|
|
||||||
install(FILES ${CMAKE_SOURCE_DIR}/tmp/script/${filename}
|
install(FILES ${CMAKE_SOURCE_DIR}/tmp/script/${file_name}
|
||||||
COMPONENT ${component}
|
COMPONENT ${component}
|
||||||
DESTINATION ${destination}
|
DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
|
||||||
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
|
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
|
||||||
)
|
)
|
||||||
endmacro(install_wrapper_script)
|
endmacro(install_wrapper_script)
|
||||||
|
|
||||||
|
macro(install_systemd_service component file_path binary_path)
|
||||||
|
get_filename_component(file_name ${file_path} NAME)
|
||||||
|
get_filename_component(binary_directory ${binary_path} DIRECTORY)
|
||||||
|
|
||||||
|
file(READ ${file_path} FILE_CONTENT)
|
||||||
|
string(REPLACE "[DIRECTORY]" ${binary_directory} FILE_CONTENT ${FILE_CONTENT})
|
||||||
|
string(REPLACE "[BINARY]" ${binary_path} FILE_CONTENT ${FILE_CONTENT})
|
||||||
|
file(WRITE ${CMAKE_SOURCE_DIR}/tmp/systemd/${file_name} ${FILE_CONTENT})
|
||||||
|
|
||||||
|
if(EXISTS "/lib/systemd/system")
|
||||||
|
install(FILES ${CMAKE_SOURCE_DIR}/tmp/systemd/${file_name}
|
||||||
|
COMPONENT ${component}
|
||||||
|
DESTINATION "/lib/systemd/system"
|
||||||
|
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
endmacro(install_systemd_service)
|
||||||
|
|
||||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
add_definitions(-D_DEBUG -DDEBUG)
|
add_definitions(-D_DEBUG -DDEBUG)
|
||||||
endif()
|
endif()
|
||||||
@ -128,7 +148,7 @@ add_custom_command(TARGET hamcore-archive-build
|
|||||||
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/tmp/hamcore.se2 ${VPNCMD_RUNTIME_OUTPUT_DIRECTORY}
|
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/tmp/hamcore.se2 ${VPNCMD_RUNTIME_OUTPUT_DIRECTORY}
|
||||||
)
|
)
|
||||||
|
|
||||||
# Copy "vpnserver" directory to /usr/lib(exec)/softether/
|
# Copy "vpnserver" directory to /usr/lib(exec)/softether/, install launch script and systemd service
|
||||||
install(DIRECTORY ${VPNSERVER_RUNTIME_OUTPUT_DIRECTORY}
|
install(DIRECTORY ${VPNSERVER_RUNTIME_OUTPUT_DIRECTORY}
|
||||||
COMPONENT "vpnserver"
|
COMPONENT "vpnserver"
|
||||||
DESTINATION "${CMAKE_INSTALL_LIBEXECDIR}/softether"
|
DESTINATION "${CMAKE_INSTALL_LIBEXECDIR}/softether"
|
||||||
@ -136,7 +156,10 @@ install(DIRECTORY ${VPNSERVER_RUNTIME_OUTPUT_DIRECTORY}
|
|||||||
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
|
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
|
||||||
)
|
)
|
||||||
|
|
||||||
# Copy "vpnclient" directory to /usr/lib(exec)/softether/
|
install_wrapper_script("vpnserver" "${CMAKE_INSTALL_FULL_LIBEXECDIR}/softether/vpnserver/vpnserver")
|
||||||
|
install_systemd_service("vpnserver" "${CMAKE_SOURCE_DIR}/systemd/softether-vpnserver.service" "${CMAKE_INSTALL_FULL_LIBEXECDIR}/softether/vpnserver/vpnserver")
|
||||||
|
|
||||||
|
# Copy "vpnclient" directory to /usr/lib(exec)/softether/, install launch script and systemd service
|
||||||
install(DIRECTORY ${VPNCLIENT_RUNTIME_OUTPUT_DIRECTORY}
|
install(DIRECTORY ${VPNCLIENT_RUNTIME_OUTPUT_DIRECTORY}
|
||||||
COMPONENT "vpnclient"
|
COMPONENT "vpnclient"
|
||||||
DESTINATION "${CMAKE_INSTALL_LIBEXECDIR}/softether"
|
DESTINATION "${CMAKE_INSTALL_LIBEXECDIR}/softether"
|
||||||
@ -144,7 +167,10 @@ install(DIRECTORY ${VPNCLIENT_RUNTIME_OUTPUT_DIRECTORY}
|
|||||||
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
|
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
|
||||||
)
|
)
|
||||||
|
|
||||||
# Copy "vpnbridge" directory to /usr/lib(exec)/softether/
|
install_wrapper_script("vpnclient" "${CMAKE_INSTALL_FULL_LIBEXECDIR}/softether/vpnclient/vpnclient")
|
||||||
|
install_systemd_service("vpnclient" "${CMAKE_SOURCE_DIR}/systemd/softether-vpnclient.service" "${CMAKE_INSTALL_FULL_LIBEXECDIR}/softether/vpnclient/vpnclient")
|
||||||
|
|
||||||
|
# Copy "vpnbridge" directory to /usr/lib(exec)/softether/, install launch script and systemd service
|
||||||
install(DIRECTORY ${VPNBRIDGE_RUNTIME_OUTPUT_DIRECTORY}
|
install(DIRECTORY ${VPNBRIDGE_RUNTIME_OUTPUT_DIRECTORY}
|
||||||
COMPONENT "vpnbridge"
|
COMPONENT "vpnbridge"
|
||||||
DESTINATION "${CMAKE_INSTALL_LIBEXECDIR}/softether"
|
DESTINATION "${CMAKE_INSTALL_LIBEXECDIR}/softether"
|
||||||
@ -152,7 +178,10 @@ install(DIRECTORY ${VPNBRIDGE_RUNTIME_OUTPUT_DIRECTORY}
|
|||||||
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
|
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
|
||||||
)
|
)
|
||||||
|
|
||||||
# Copy "vpncmd" directory to /usr/lib(exec)/softether/
|
install_wrapper_script("vpnbridge" "${CMAKE_INSTALL_FULL_LIBEXECDIR}/softether/vpnbridge/vpnbridge")
|
||||||
|
install_systemd_service("vpnbridge" "${CMAKE_SOURCE_DIR}/systemd/softether-vpnbridge.service" "${CMAKE_INSTALL_FULL_LIBEXECDIR}/softether/vpnbridge/vpnbridge")
|
||||||
|
|
||||||
|
# Copy "vpncmd" directory to /usr/lib(exec)/softether/, install launch script and systemd service
|
||||||
install(DIRECTORY ${VPNCMD_RUNTIME_OUTPUT_DIRECTORY}
|
install(DIRECTORY ${VPNCMD_RUNTIME_OUTPUT_DIRECTORY}
|
||||||
COMPONENT "vpncmd"
|
COMPONENT "vpncmd"
|
||||||
DESTINATION "${CMAKE_INSTALL_LIBEXECDIR}/softether"
|
DESTINATION "${CMAKE_INSTALL_LIBEXECDIR}/softether"
|
||||||
@ -160,12 +189,7 @@ install(DIRECTORY ${VPNCMD_RUNTIME_OUTPUT_DIRECTORY}
|
|||||||
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
|
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
|
||||||
)
|
)
|
||||||
|
|
||||||
# Create wrapper scripts in the user's binaries directory, which is usually "/usr/local/bin".
|
install_wrapper_script("vpncmd" "${CMAKE_INSTALL_FULL_LIBEXECDIR}/softether/vpncmd/vpncmd")
|
||||||
# This is required because symlinks use the folder they are in as working directory.
|
|
||||||
install_wrapper_script("vpnserver" "${CMAKE_INSTALL_FULL_LIBEXECDIR}/softether/vpnserver/vpnserver" ${CMAKE_INSTALL_FULL_BINDIR})
|
|
||||||
install_wrapper_script("vpnclient" "${CMAKE_INSTALL_FULL_LIBEXECDIR}/softether/vpnclient/vpnclient" ${CMAKE_INSTALL_FULL_BINDIR})
|
|
||||||
install_wrapper_script("vpnbridge" "${CMAKE_INSTALL_FULL_LIBEXECDIR}/softether/vpnbridge/vpnbridge" ${CMAKE_INSTALL_FULL_BINDIR})
|
|
||||||
install_wrapper_script("vpncmd" "${CMAKE_INSTALL_FULL_LIBEXECDIR}/softether/vpncmd/vpncmd" ${CMAKE_INSTALL_FULL_BINDIR})
|
|
||||||
|
|
||||||
# Print message after installing the targets
|
# Print message after installing the targets
|
||||||
install(CODE "message(\"\n----------------------------------------------------------------------------------------------------------------------------\")")
|
install(CODE "message(\"\n----------------------------------------------------------------------------------------------------------------------------\")")
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=SoftEther VPN Bridge
|
Description=SoftEther VPN Bridge
|
||||||
After=network.target auditd.service
|
After=network.target auditd.service
|
||||||
ConditionPathExists=!/opt/vpnbridge/do_not_run
|
ConditionPathExists=![DIRECTORY]/do_not_run
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=forking
|
Type=forking
|
||||||
ExecStart=/opt/vpnbridge/vpnbridge start
|
EnvironmentFile=-[DIRECTORY]
|
||||||
ExecStop=/opt/vpnbridge/vpnbridge stop
|
ExecStart=[BINARY] start
|
||||||
|
ExecStop=[BINARY] stop
|
||||||
KillMode=process
|
KillMode=process
|
||||||
Restart=on-failure
|
Restart=on-failure
|
||||||
|
|
||||||
@ -15,9 +16,8 @@ PrivateTmp=yes
|
|||||||
ProtectHome=yes
|
ProtectHome=yes
|
||||||
ProtectSystem=full
|
ProtectSystem=full
|
||||||
ReadOnlyDirectories=/
|
ReadOnlyDirectories=/
|
||||||
ReadWriteDirectories=-/opt/vpnbridge
|
ReadWriteDirectories=-[DIRECTORY]
|
||||||
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_NET_BROADCAST CAP_NET_RAW CAP_SYS_NICE CAP_SYS_ADMIN CAP_SETUID
|
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_NET_BROADCAST CAP_NET_RAW CAP_SYS_NICE CAP_SYS_ADMIN CAP_SETUID
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=SoftEther VPN Client
|
Description=SoftEther VPN Client
|
||||||
After=network.target auditd.service
|
After=network.target auditd.service
|
||||||
ConditionPathExists=!/opt/vpnclient/do_not_run
|
ConditionPathExists=![DIRECTORY]/do_not_run
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=forking
|
Type=forking
|
||||||
EnvironmentFile=-/opt/vpnclient
|
EnvironmentFile=-[DIRECTORY]
|
||||||
ExecStart=/opt/vpnclient/vpnclient start
|
ExecStart=[BINARY] start
|
||||||
ExecStop=/opt/vpnclient/vpnclient stop
|
ExecStop=[BINARY] stop
|
||||||
KillMode=process
|
KillMode=process
|
||||||
Restart=on-failure
|
Restart=on-failure
|
||||||
|
|
||||||
@ -16,10 +16,8 @@ PrivateTmp=yes
|
|||||||
ProtectHome=yes
|
ProtectHome=yes
|
||||||
ProtectSystem=full
|
ProtectSystem=full
|
||||||
ReadOnlyDirectories=/
|
ReadOnlyDirectories=/
|
||||||
ReadWriteDirectories=-/opt/vpnclient
|
ReadWriteDirectories=-[DIRECTORY]
|
||||||
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_NET_BROADCAST CAP_NET_RAW CAP_SYS_NICE CAP_SYS_ADMIN CAP_SETUID
|
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_NET_BROADCAST CAP_NET_RAW CAP_SYS_NICE CAP_SYS_ADMIN CAP_SETUID
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=SoftEther VPN Server
|
Description=SoftEther VPN Server
|
||||||
After=network.target auditd.service
|
After=network.target auditd.service
|
||||||
ConditionPathExists=!/opt/vpnserver/do_not_run
|
ConditionPathExists=![DIRECTORY]/do_not_run
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=forking
|
Type=forking
|
||||||
EnvironmentFile=-/opt/vpnserver
|
EnvironmentFile=-[DIRECTORY]
|
||||||
ExecStart=/opt/vpnserver/vpnserver start
|
ExecStart=[BINARY] start
|
||||||
ExecStop=/opt/vpnserver/vpnserver stop
|
ExecStop=[BINARY] stop
|
||||||
KillMode=process
|
KillMode=process
|
||||||
Restart=on-failure
|
Restart=on-failure
|
||||||
|
|
||||||
@ -16,10 +16,8 @@ PrivateTmp=yes
|
|||||||
ProtectHome=yes
|
ProtectHome=yes
|
||||||
ProtectSystem=full
|
ProtectSystem=full
|
||||||
ReadOnlyDirectories=/
|
ReadOnlyDirectories=/
|
||||||
ReadWriteDirectories=-/opt/vpnserver
|
ReadWriteDirectories=-[DIRECTORY]
|
||||||
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_NET_BROADCAST CAP_NET_RAW CAP_SYS_NICE CAP_SYS_ADMIN CAP_SETUID
|
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_NET_BROADCAST CAP_NET_RAW CAP_SYS_NICE CAP_SYS_ADMIN CAP_SETUID
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user