From owner-freebsd-ports@FreeBSD.ORG Sun Jan 25 04:44:19 2009 Return-Path: Delivered-To: ports@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 67C061065672 for ; Sun, 25 Jan 2009 04:44:19 +0000 (UTC) (envelope-from v.a.popov@gmail.com) Received: from nf-out-0910.google.com (nf-out-0910.google.com [64.233.182.186]) by mx1.freebsd.org (Postfix) with ESMTP id DE3E78FC19 for ; Sun, 25 Jan 2009 04:44:18 +0000 (UTC) (envelope-from v.a.popov@gmail.com) Received: by nf-out-0910.google.com with SMTP id h3so862315nfh.33 for ; Sat, 24 Jan 2009 20:44:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:cc:subject:x-enigmail-version :content-type; bh=Gq/+7L0JttkUMzgK1yTrCt1hSC2W+xXJ+XtFlngBgsg=; b=lNiWhuxgUgw9TW3tQlGKck85n9TMIcZq3ErBNJylzZZjzF73yHE78u3gOifeohHKZ6 CMn8hxTG+/j2xqwNiHCo35HE4hgAfIcZJpdQ7duha268Nf+cnzaoLjzvWZ+N/P6cBayw 4dl9qokUHjQcfpNpoK09aOSbBM+/mvZrf9Js0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :x-enigmail-version:content-type; b=JgQMzRX8sUyCPjTu1OLTDiJjSkVTbXw6kUrnD52THFkxP7CE6zYMCxbhR/8jeSjWY8 +uTFCeAkWHxu/zId9x2xvLVliAJ9uVERSvX1ULfTrWbkzJMKnImcq4H28UgyB8Evco7S IyMEMJpByxn4QGHnGN8dCBg82C5Lz5CjjsmBQ= Received: by 10.67.123.1 with SMTP id a1mr650347ugn.42.1232857457867; Sat, 24 Jan 2009 20:24:17 -0800 (PST) Received: from vic.hcn-strela.ru (vic.hcn-strela.ru [91.192.71.126]) by mx.google.com with ESMTPS id 39sm2211983ugb.43.2009.01.24.20.24.16 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 24 Jan 2009 20:24:17 -0800 (PST) Message-ID: <497BE96E.7050004@gmail.com> Date: Sun, 25 Jan 2009 07:24:14 +0300 From: Victor Popov User-Agent: Thunderbird 2.0.0.19 (X11/20090124) MIME-Version: 1.0 To: Jeremy Messenger X-Enigmail-Version: 0.95.6 Content-Type: multipart/mixed; boundary="------------070200070502060008040804" Cc: ports@FreeBSD.org Subject: [patch] net-p2p/deluge port improvement - startup scripts X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Jan 2009 04:44:19 -0000 This is a multi-part message in MIME format. --------------070200070502060008040804 Content-Type: text/plain; charset=KOI8-R; format=flowed Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hello Jeremy and everybody on the list, Deluge bittorrent client is great, and has a flexible architecture, which allows user to run a downloading daemon, only occasionally launching an user interface to manage downloads; all the other time daemon can work unattended. net-p2p/deluge port is missing startup scripts for daemon, and this is what I want to be fixed. The attached patch adds two rc scripts, for launching the daemon, deluged, and for launching deluge in webui mode. Ideally, this should be several separate ports, like net-p2p/transmission-*, but deluge is installed by own installer, so dividing port into several would require a lot of work. Some comments about why I wrote these startup scripts in this way: - - First of all, I don't at all like the idea of running p2p client as usual desktop user for security reasons - desktop users may store sensitive information in their mailboxes, browser configs and other places, so it is better to dedicate different uid for peering task. This is why _user and _home configuration variables are introduced. I wonder, should we assign an uid in the UIDs file? What default homedir should this user have? I've set default to /home/deluge, and maybe there are better places? - - Minor bug in launching command-line: it should be --logfile=${logfile}, not a redirection, but unfortunately it does not work now. Could not investigate and fix it, sorry. - - run_rc_command is called with environment variable HOME set to ${home}, because deluged can't determine homedir from user, and it does not accept "-c" switch. - - Bug in deluge-webui script: when it is time to stop deluge, script has to find process due to lack of pidfile. If at that time you are running deluge with gtk UI, script will find your instance, and will try to kill it. If deluge_webui_user is not you, it's ok, your deluge is safe, but after that script will not be able to start webui, because it would think it is already running. This is because deluge program does not accept "--pidfile" parameter. There is already a feature-request in deluge bug-tracker for adding pidfile [http://dev.deluge-torrent.org/ticket/758], so maybe soon it would be possible to improve this script. Can this patch be commited, please? If something is wrong, comments would be very appreciated. P.S.: Sorry for my bad English, vast discourse on possibly obvious things and a long message. - -- Best regards, Victor Popov mailto:v.a.popov@gmail,com -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.10 (FreeBSD) iEYEARECAAYFAkl76UQACgkQtKisLOtMPvlCNACg07Bpkjm2YmxTGeNu6kY4tnOk Mu8AoLMUqFci6fwfCSG1XtllVUlGDuYs =KGuU -----END PGP SIGNATURE----- --------------070200070502060008040804 Content-Type: text/plain; name="deluge.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="deluge.txt" diff -urN net-p2p/deluge.orig/Makefile net-p2p/deluge/Makefile --- net-p2p/deluge.orig/Makefile 2009-01-19 07:18:08.000000000 +0300 +++ net-p2p/deluge/Makefile 2009-01-25 02:32:25.506351031 +0300 @@ -7,6 +7,7 @@ PORTNAME= deluge PORTVERSION= 1.1.0 +PORTREVISION= 1 CATEGORIES= net-p2p python MASTER_SITES= http://ftp.osuosl.org/pub/deluge/source/${PORTVERSION}/ @@ -53,6 +54,10 @@ @${ECHO_CMD} "Keep in mind, choice WITHOUT_PYGTK still will installing a lot of GUI files that are for pygtk. The installation tool does not provide option to disable install the GUI files. These GUI files are harmless as long as you do not touch these or it won't work because it needs pygtk." | ${FMT} 75 75 .endif +USE_RC_SUBR= deluged deluge-webui +SUB_LIST= PYTHON_CMD=${PYTHON_CMD} +SUB_FILES= deluged deluge-webui + post-patch: @${REINPLACE_CMD} -e 's|%%LOCALBASE%%|${LOCALBASE}|g ; \ s|%%PTHREAD_LIBS%%|${PTHREAD_LIBS}|g' \ diff -urN net-p2p/deluge.orig/files/deluge-webui.in net-p2p/deluge/files/deluge-webui.in --- net-p2p/deluge.orig/files/deluge-webui.in 1970-01-01 03:00:00.000000000 +0300 +++ net-p2p/deluge/files/deluge-webui.in 2009-01-25 02:31:14.036748983 +0300 @@ -0,0 +1,41 @@ +#!/bin/sh +# +# PROVIDE: deluge_webui +# REQUIRE: LOGIN deluged +# KEYWORD: shutdown +# +# +# Add the following line to /etc/rc.conf to enable the deluge web ui daemon: +# +# deluge_webui_enable (bool): Set to "NO" by default. +# Set it to "YES" to enable deluge web ui daemon. +# deluge_webui_user (str): Defaults to "deluge" +# User running deluge web ui daemon +# deluge_webui_home (str): Defaults to "/home/deluge" +# Directory to store configuration and possibly downloads +# deluge_webui_logfile (str): Defaults to "$deluge_webui_home/deluge_webui.log" +# deluge_webui_loglevel (str): Verbosity of logging, defaults to "error". Possible values: +# none, info, warning, error, critical, debug +# deluge_webui_args (str): Custom additional arguments for deluge, default empty +# + +. %%RC_SUBR%% + +name="deluge_webui" +rcvar=`set_rcvar` + +load_rc_config ${name} +: ${deluge_webui_enable="NO"} +: ${deluge_webui_user="deluge"} +: ${deluge_webui_home="/home/deluge"} +: ${deluge_webui_logfile="${deluge_webui_home}/${name}.log"} +: ${deluge_webui_loglevel="error"} +: ${deluge_webui_args=""} + +required_dirs=${deluge_webui_home} + +command="%%PREFIX%%/bin/deluge" +command_args="--ui=web --loglevel=${deluge_webui_loglevel} ${deluge_webui_args} >> ${deluge_webui_logfile} 2>&1 &" +command_interpreter="%%PYTHON_CMD%%" + +HOME=${deluge_webui_home} run_rc_command "$1" diff -urN net-p2p/deluge.orig/files/deluged.in net-p2p/deluge/files/deluged.in --- net-p2p/deluge.orig/files/deluged.in 1970-01-01 03:00:00.000000000 +0300 +++ net-p2p/deluge/files/deluged.in 2009-01-25 02:30:34.132295332 +0300 @@ -0,0 +1,45 @@ +#!/bin/sh +# +# PROVIDE: deluged +# REQUIRE: LOGIN +# KEYWORD: shutdown +# +# +# Add the following line to /etc/rc.conf to enable the deluged daemon: +# +# deluged_enable (bool): Set to "NO" by default. +# Set it to "YES" to enable deluged daemon. +# deluged_user (str): Defaults to "deluge" +# User running deluged daemon +# deluged_home (str): Defaults to "/home/deluge" +# Directory to store configuration and possibly downloads +# deluged_pidfile (str): Defaults to "$deluged_home/deluged.pid" +# deluged_logfile (str): Defaults to "$deluged_home/deluged.log" +# deluged_loglevel (str): Verbosity of logging, defaults to "error". Possible values: +# none, info, warning, error, critical, debug +# deluged_args (str): Custom additional arguments for deluged, default empty +# + +. %%RC_SUBR%% + +name="deluged" +rcvar=`set_rcvar` + +# read configuration and set defaults +load_rc_config ${name} +: ${deluged_enable="NO"} +: ${deluged_user="deluge"} +: ${deluged_home="/home/deluge"} +: ${deluged_port="58846"} +: ${deluged_pidfile="${deluged_home}/${name}.pid"} +: ${deluged_logfile="${deluged_home}/${name}.log"} +: ${deluged_loglevel="error"} +: ${deluged_args=""} + +required_dirs=${deluged_home} + +command="%%PREFIX%%/bin/deluged" +command_args="--port=${deluged_port} --pidfile=${deluged_pidfile} --loglevel=${deluged_loglevel} ${deluged_args} >> ${deluged_logfile} 2>&1" +command_interpreter="%%PYTHON_CMD%%" + +HOME=${deluged_home} run_rc_command "$1" --------------070200070502060008040804--