From e5829756249b91375e3ac1bff8d41b9cf58aeeb6 Mon Sep 17 00:00:00 2001 From: Rozhuk Ivan Date: Wed, 23 Dec 2020 03:31:45 +0300 Subject: [PATCH] net-p2p/rtorrent: drop EXAMPLES, add rc.d script. Private patch. --- net-p2p/rtorrent/Makefile | 17 +++--- net-p2p/rtorrent/files/rtorrent.in | 91 ++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+), 7 deletions(-) create mode 100755 net-p2p/rtorrent/files/rtorrent.in diff --git a/net-p2p/rtorrent/Makefile b/net-p2p/rtorrent/Makefile index e09c58a0f079..b24e6be2c585 100644 --- a/net-p2p/rtorrent/Makefile +++ b/net-p2p/rtorrent/Makefile @@ -19,12 +19,14 @@ GNU_CONFIGURE= yes CONFIGURE_ARGS= --disable-debug LDFLAGS+= -lexecinfo -pthread -PLIST_FILES= bin/rtorrent +PLIST_FILES= bin/rtorrent \ + "@dir ${ETCDIR}" \ + "@sample ${ETCDIR}/rtorrent.config.sample" PORTDOCS= README -PORTEXAMPLES= rtorrent.rc +USE_RC_SUBR= rtorrent SUB_FILES= pkg-message -OPTIONS_DEFINE= DOCS EXAMPLES IPV6 XMLRPC +OPTIONS_DEFINE= DOCS IPV6 XMLRPC OPTIONS_DEFAULT=XMLRPC XMLRPC_DESC= Compile with xmlrpc-c support @@ -45,12 +47,13 @@ post-patch: -exec ${REINPLACE_CMD} -e '/include/s,tr1/,,' {} \; .endif +post-install: + ${MKDIR} ${STAGEDIR}${ETCDIR} + ${INSTALL_DATA} ${WRKSRC}/doc/rtorrent.rc \ + ${STAGEDIR}${ETCDIR}/rtorrent.config.sample + post-install-DOCS-on: @${MKDIR} ${STAGEDIR}${DOCSDIR}/ ${INSTALL_DATA} ${WRKSRC}/${PORTDOCS} ${STAGEDIR}${DOCSDIR}/ -post-install-EXAMPLES-on: - @${MKDIR} ${STAGEDIR}${EXAMPLESDIR}/ - ${INSTALL_DATA} ${WRKSRC}/doc/rtorrent.rc ${STAGEDIR}${EXAMPLESDIR}/ - .include diff --git a/net-p2p/rtorrent/files/rtorrent.in b/net-p2p/rtorrent/files/rtorrent.in new file mode 100755 index 000000000000..18a8fc7bd998 --- /dev/null +++ b/net-p2p/rtorrent/files/rtorrent.in @@ -0,0 +1,91 @@ +#!/bin/sh +### Rozhuk Ivan 2009.12 - 2021 +### startup script file for rtorrent +### + +# PROVIDE: rtorrent +# REQUIRE: LOGIN +# KEYWORD: shutdown + +. /etc/rc.subr + +name="rtorrent" +rcvar=rtorrent_enable + +load_rc_config $name + +: ${rtorrent_enable='NO'} +: ${rtorrent_pidfile="/var/run/${name}.pid"} +: ${rtorrent_user='www'} +: ${rtorrent_group='www'} +: ${rtorrent_args=''} +: ${rtorrent_bindaddr=''} # Bind listening socket and outgoing connections to this network interface address. +: ${rtorrent_bindport=''} # Try to open a listening port in the range a up to and including b +: ${rtorrent_download_dir=''} # Set the default download directory. +: ${rtorrent_session_dir="/var/db/${name}"} # Session management will be enabled and the torrent files for all open downloads will be stored in this directory. +: ${rtorrent_config="%%PREFIX%%/etc/${name}/${name}.conf"} # .rtorrent.rc config file name. +: ${rtorrent_rpc_bindaddr=''} # tcp (ip:port) socket for scgi/rpc connect. +: ${rtorrent_rpc_bindsocket="/var/run/${name}-rpc.sock"} # Unix domain socket for scgi/rpc connect. +: ${rtorrent_rpc_bindsocket_mode='0660'} # Only for unix domain socket. + + +command='/usr/sbin/daemon' +procname='%%PREFIX%%/bin/rtorrent' +command_args='-n' + +if [ -n "${rtorrent_bindaddr}" ]; then + command_args="${command_args} -b ${rtorrent_bindaddr}" +fi +if [ -n "${rtorrent_bindport}" ]; then + command_args="${command_args} -p ${rtorrent_bindport}" +fi +if [ -n "${rtorrent_download_dir}" ]; then + command_args="${command_args} -d ${rtorrent_download_dir}" +fi +if [ -n "${rtorrent_session_dir}" ]; then + command_args="${command_args} -s ${rtorrent_session_dir}" +fi +if [ -n "${rtorrent_config}" ]; then + command_args="${command_args} -o import=${rtorrent_config}" +fi +if [ -n "${rtorrent_rpc_bindsocket}" ]; then + command_args="${command_args} -o scgi_local=${rtorrent_rpc_bindsocket}" +else + if [ -n "${rtorrent_rpc_bindaddr}" ]; then + command_args="${command_args} -o scgi_local=${rtorrent_rpc_bindaddr}" + fi +fi +command_args="-p ${rtorrent_pidfile} -S -T ${name} ${procname} ${command_args} -o session.path.set=${rtorrent_session_dir} -o system.daemon.set=yes ${rtorrent_args}" + + +pidfile="${rtorrent_pidfile}" +required_dirs="${rtorrent_download_dir}" +required_files="${command} ${procname}" + + +start_precmd="${name}_clean_cmd" +start_postcmd="${name}_start_postcmd" +stop_postcmd="${name}_clean_cmd" + +rtorrent_clean_cmd() +{ + mkdir -p "${rtorrent_session_dir}" + chown -R "${rtorrent_user}:${rtorrent_group}" "${rtorrent_session_dir}" + if [ -n "${rtorrent_session_dir}" ]; then + rm -f "${rtorrent_session_dir}/rtorrent.lock" + fi + if [ -e "${rtorrent_rpc_bindsocket}" ]; then + rm -f "${rtorrent_rpc_bindsocket}" + fi +} + +rtorrent_start_postcmd() +{ + if [ -S "${rtorrent_rpc_bindsocket}" ]; then + sleep 2 + chown "${rtorrent_user}:${rtorrent_group} ${rtorrent_rpc_bindsocket}" + chmod "${rtorrent_rpc_bindsocket_mode} ${rtorrent_rpc_bindsocket}" + fi +} + +run_rc_command "$1"