Date: Sun, 25 Jan 2009 07:24:14 +0300 From: Victor Popov <v.a.popov@gmail.com> To: Jeremy Messenger <mezz@FreeBSD.org> Cc: ports@FreeBSD.org Subject: [patch] net-p2p/deluge port improvement - startup scripts Message-ID: <497BE96E.7050004@gmail.com>
next in thread | raw e-mail | index | archive | help
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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?497BE96E.7050004>