mirror of
https://github.com/3proxy/3proxy.git
synced 2026-04-06 21:30:12 +08:00
add rc.d script
Some checks are pending
C/C++ CI / ${{ matrix.target }} (macos-15) (push) Waiting to run
C/C++ CI / ${{ matrix.target }} (ubuntu-24.04-arm) (push) Waiting to run
C/C++ CI / ${{ matrix.target }} (ubuntu-latest) (push) Waiting to run
C/C++ CI / ${{ matrix.target }} (windows-2022) (push) Waiting to run
Some checks are pending
C/C++ CI / ${{ matrix.target }} (macos-15) (push) Waiting to run
C/C++ CI / ${{ matrix.target }} (ubuntu-24.04-arm) (push) Waiting to run
C/C++ CI / ${{ matrix.target }} (ubuntu-latest) (push) Waiting to run
C/C++ CI / ${{ matrix.target }} (windows-2022) (push) Waiting to run
This commit is contained in:
parent
d502ecb0fd
commit
28969bbc5a
@ -509,53 +509,80 @@ if(NOT WIN32)
|
|||||||
install(FILES scripts/add3proxyuser.sh DESTINATION ${CMAKE_INSTALL_BINDIR})
|
install(FILES scripts/add3proxyuser.sh DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Install service files (systemd or init.d)
|
# Install service files (systemd, init.d, or rc.d)
|
||||||
if(NOT WIN32)
|
if(NOT WIN32)
|
||||||
# Check for systemd
|
if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD|Darwin|OpenBSD|NetBSD")
|
||||||
find_package(PkgConfig QUIET)
|
# BSD/macOS - install rc.d script
|
||||||
if(PkgConfig_FOUND)
|
set(RCD_DIR "/usr/local/etc/rc.d")
|
||||||
pkg_check_modules(SYSTEMD QUIET systemd)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(SYSTEMD_FOUND)
|
configure_file(
|
||||||
# systemd is available - install systemd service
|
${CMAKE_CURRENT_SOURCE_DIR}/scripts/rc.d/3proxy.in
|
||||||
# Get systemd unit directory
|
${CMAKE_CURRENT_BINARY_DIR}/3proxy.rc
|
||||||
pkg_get_variable(SYSTEMD_UNIT_DIR systemd systemdsystemunitdir)
|
@ONLY
|
||||||
if(NOT SYSTEMD_UNIT_DIR)
|
)
|
||||||
# Fallback to common location
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/3proxy.rc
|
||||||
set(SYSTEMD_UNIT_DIR "/lib/systemd/system")
|
DESTINATION ${RCD_DIR}
|
||||||
|
RENAME 3proxy
|
||||||
|
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
|
||||||
|
)
|
||||||
|
|
||||||
|
message(STATUS " rc.d: YES (${RCD_DIR})")
|
||||||
|
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||||
|
# Linux - check for systemd
|
||||||
|
find_package(PkgConfig QUIET)
|
||||||
|
if(PkgConfig_FOUND)
|
||||||
|
pkg_check_modules(SYSTEMD QUIET systemd)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Configure and install systemd service file
|
if(SYSTEMD_FOUND)
|
||||||
configure_file(
|
# systemd is available - install systemd service
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/scripts/3proxy.service.in
|
# Get systemd unit directory
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/3proxy.service
|
pkg_get_variable(SYSTEMD_UNIT_DIR systemd systemdsystemunitdir)
|
||||||
@ONLY
|
if(NOT SYSTEMD_UNIT_DIR)
|
||||||
)
|
# Fallback to common location
|
||||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/3proxy.service
|
set(SYSTEMD_UNIT_DIR "/lib/systemd/system")
|
||||||
DESTINATION ${SYSTEMD_UNIT_DIR}
|
endif()
|
||||||
)
|
|
||||||
|
|
||||||
# Install tmpfiles.d configuration for runtime directory
|
# Configure and install systemd service file
|
||||||
configure_file(
|
configure_file(
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/scripts/3proxy.tmpfiles.in
|
${CMAKE_CURRENT_SOURCE_DIR}/scripts/3proxy.service.in
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/3proxy.conf
|
${CMAKE_CURRENT_BINARY_DIR}/3proxy.service
|
||||||
@ONLY
|
@ONLY
|
||||||
)
|
)
|
||||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/3proxy.conf
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/3proxy.service
|
||||||
DESTINATION /usr/lib/tmpfiles.d
|
DESTINATION ${SYSTEMD_UNIT_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
message(STATUS " systemd: YES (${SYSTEMD_UNIT_DIR})")
|
# Install tmpfiles.d configuration for runtime directory
|
||||||
|
configure_file(
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/scripts/3proxy.tmpfiles.in
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/3proxy.conf
|
||||||
|
@ONLY
|
||||||
|
)
|
||||||
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/3proxy.conf
|
||||||
|
DESTINATION /usr/lib/tmpfiles.d
|
||||||
|
)
|
||||||
|
|
||||||
|
message(STATUS " systemd: YES (${SYSTEMD_UNIT_DIR})")
|
||||||
|
else()
|
||||||
|
# No systemd - install init.d script
|
||||||
|
install(FILES scripts/init.d/3proxy.sh
|
||||||
|
DESTINATION /etc/init.d
|
||||||
|
RENAME 3proxy
|
||||||
|
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
|
||||||
|
)
|
||||||
|
|
||||||
|
message(STATUS " systemd: NO (using init.d)")
|
||||||
|
endif()
|
||||||
else()
|
else()
|
||||||
# No systemd - install init.d script
|
# Other Unix - install init.d script
|
||||||
install(FILES scripts/init.d/3proxy.sh
|
install(FILES scripts/init.d/3proxy.sh
|
||||||
DESTINATION /etc/init.d
|
DESTINATION /etc/init.d
|
||||||
RENAME 3proxy
|
RENAME 3proxy
|
||||||
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
|
||||||
)
|
)
|
||||||
|
|
||||||
message(STATUS " systemd: NO (using init.d)")
|
message(STATUS " init.d: YES (/etc/init.d)")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|||||||
@ -50,7 +50,7 @@ install: all
|
|||||||
if [ ! -d "/usr/local/3proxy/bin" ]; then mkdir -p /usr/local/3proxy/bin/; fi
|
if [ ! -d "/usr/local/3proxy/bin" ]; then mkdir -p /usr/local/3proxy/bin/; fi
|
||||||
install bin/3proxy /usr/local/3proxy/bin/3proxy
|
install bin/3proxy /usr/local/3proxy/bin/3proxy
|
||||||
install bin/mycrypt /usr/local/3proxy/bin/mycrypt
|
install bin/mycrypt /usr/local/3proxy/bin/mycrypt
|
||||||
install scripts/init.d/proxy.sh /usr/local/etc/rc.d/3proxy
|
install scripts/rc.d/3proxy /usr/local/etc/rc.d/3proxy
|
||||||
install scripts/add3proxyuser.sh /usr/local/3proxy/bin/
|
install scripts/add3proxyuser.sh /usr/local/3proxy/bin/
|
||||||
if [ -s /usr/local/etc/3proxy/3proxy.cfg ]; then /usr/local/3proxy/3proxy.cfg already exists ; else install scripts/3proxy.cfg /usr/local/etc/3proxy/; fi
|
if [ -s /usr/local/etc/3proxy/3proxy.cfg ]; then /usr/local/3proxy/3proxy.cfg already exists ; else install scripts/3proxy.cfg /usr/local/etc/3proxy/; fi
|
||||||
if [ ! -d /var/log/3proxy/ ]; then mkdir /var/log/3proxy/; fi
|
if [ ! -d /var/log/3proxy/ ]; then mkdir /var/log/3proxy/; fi
|
||||||
|
|||||||
@ -51,7 +51,7 @@ install: all
|
|||||||
if [ ! -d "/usr/local/3proxy/bin" ]; then mkdir -p /usr/local/3proxy/bin/; fi
|
if [ ! -d "/usr/local/3proxy/bin" ]; then mkdir -p /usr/local/3proxy/bin/; fi
|
||||||
install bin/3proxy /usr/local/3proxy/bin/3proxy
|
install bin/3proxy /usr/local/3proxy/bin/3proxy
|
||||||
install bin/mycrypt /usr/local/3proxy/bin/mycrypt
|
install bin/mycrypt /usr/local/3proxy/bin/mycrypt
|
||||||
install scripts/init.d/proxy.sh /usr/local/etc/rc.d/3proxy
|
install scripts/rc.d/3proxy /usr/local/etc/rc.d/3proxy
|
||||||
install scripts/add3proxyuser.sh /usr/local/3proxy/bin/
|
install scripts/add3proxyuser.sh /usr/local/3proxy/bin/
|
||||||
if [ -s /usr/local/etc/3proxy/3proxy.cfg ]; then /usr/local/3proxy/3proxy.cfg already exists ; else install scripts/3proxy.cfg /usr/local/etc/3proxy/; fi
|
if [ -s /usr/local/etc/3proxy/3proxy.cfg ]; then /usr/local/3proxy/3proxy.cfg already exists ; else install scripts/3proxy.cfg /usr/local/etc/3proxy/; fi
|
||||||
if [ ! -d /var/log/3proxy/ ]; then mkdir /var/log/3proxy/; fi
|
if [ ! -d /var/log/3proxy/ ]; then mkdir /var/log/3proxy/; fi
|
||||||
|
|||||||
27
scripts/rc.d/3proxy
Normal file
27
scripts/rc.d/3proxy
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# PROVIDE: 3proxy
|
||||||
|
# REQUIRE: LOGIN DAEMON
|
||||||
|
# KEYWORD: shutdown
|
||||||
|
|
||||||
|
. /etc/rc.subr
|
||||||
|
|
||||||
|
name="3proxy"
|
||||||
|
rcvar="3proxy_enable"
|
||||||
|
|
||||||
|
command="/usr/local/3proxy/bin/3proxy"
|
||||||
|
pidfile="/var/run/3proxy/${name}.pid"
|
||||||
|
command_args="${3proxy_config:-/usr/local/etc/3proxy/3proxy.cfg}"
|
||||||
|
required_files="${3proxy_config:-/usr/local/etc/3proxy/3proxy.cfg}"
|
||||||
|
|
||||||
|
start_precmd="3proxy_precmd"
|
||||||
|
|
||||||
|
3proxy_precmd()
|
||||||
|
{
|
||||||
|
if [ ! -d /var/run/3proxy ]; then
|
||||||
|
mkdir -p /var/run/3proxy
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
load_rc_config $name
|
||||||
|
run_rc_command "$1"
|
||||||
27
scripts/rc.d/3proxy.in
Normal file
27
scripts/rc.d/3proxy.in
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# PROVIDE: 3proxy
|
||||||
|
# REQUIRE: LOGIN DAEMON
|
||||||
|
# KEYWORD: shutdown
|
||||||
|
|
||||||
|
. /etc/rc.subr
|
||||||
|
|
||||||
|
name="3proxy"
|
||||||
|
rcvar="3proxy_enable"
|
||||||
|
|
||||||
|
command="@CMAKE_INSTALL_FULL_BINDIR@/3proxy"
|
||||||
|
pidfile="/var/run/3proxy/${name}.pid"
|
||||||
|
command_args="${3proxy_config:-/etc/3proxy/3proxy.cfg}"
|
||||||
|
required_files="${3proxy_config:-/etc/3proxy/3proxy.cfg}"
|
||||||
|
|
||||||
|
start_precmd="3proxy_precmd"
|
||||||
|
|
||||||
|
3proxy_precmd()
|
||||||
|
{
|
||||||
|
if [ ! -d /var/run/3proxy ]; then
|
||||||
|
mkdir -p /var/run/3proxy
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
load_rc_config $name
|
||||||
|
run_rc_command "$1"
|
||||||
Loading…
Reference in New Issue
Block a user