diff options
author | Jesus P Rey (Chuso) <gentoo@chuso.net> | 2021-01-30 20:18:29 +0100 |
---|---|---|
committer | Joonas Niilola <juippis@gentoo.org> | 2021-02-18 10:24:51 +0200 |
commit | 30cf999cd2ab9c4d29751305c986d4e692721d2c (patch) | |
tree | fca6ed2da7466ab18c7320d3e5fee6394bd3262d /net-p2p | |
parent | sys-cluster/charliecloud: Drop old. (diff) | |
download | gentoo-30cf999cd2ab9c4d29751305c986d4e692721d2c.tar.gz gentoo-30cf999cd2ab9c4d29751305c986d4e692721d2c.tar.bz2 gentoo-30cf999cd2ab9c4d29751305c986d4e692721d2c.zip |
net-p2p/mldonkey: revision bump to 3.1.7-r1
Adds support to send init.d commands via telnet in addition to http.
Signed-off-by: Jesus P Rey <gentoo@chuso.net>
Closes: https://bugs.gentoo.org/338017
Signed-off-by: Joonas Niilola <juippis@gentoo.org>
Diffstat (limited to 'net-p2p')
-rw-r--r-- | net-p2p/mldonkey/files/mldonkey.confd (renamed from net-p2p/mldonkey/files/mldonkey.confd-2.8) | 3 | ||||
-rw-r--r-- | net-p2p/mldonkey/files/mldonkey.initd | 70 | ||||
-rw-r--r-- | net-p2p/mldonkey/mldonkey-3.1.7-r1.ebuild (renamed from net-p2p/mldonkey/mldonkey-3.1.7.ebuild) | 3 |
3 files changed, 50 insertions, 26 deletions
diff --git a/net-p2p/mldonkey/files/mldonkey.confd-2.8 b/net-p2p/mldonkey/files/mldonkey.confd index 1d1f282234f7..7cdb2b7134ed 100644 --- a/net-p2p/mldonkey/files/mldonkey.confd-2.8 +++ b/net-p2p/mldonkey/files/mldonkey.confd @@ -33,6 +33,9 @@ SERVER="localhost" # port for webinterface, usually 4080 PORT="4080" +# port for telnet interface, usually 4000 +TELNET_PORT="4000" + # to enable password restricted access, # uncomment and set BOTH following vars: #USERNAME="admin" diff --git a/net-p2p/mldonkey/files/mldonkey.initd b/net-p2p/mldonkey/files/mldonkey.initd index 12dd599de7be..b7e561372392 100644 --- a/net-p2p/mldonkey/files/mldonkey.initd +++ b/net-p2p/mldonkey/files/mldonkey.initd @@ -35,26 +35,55 @@ start() { eend $? } -setup_uri() { - BASE="http://" +send_telnet_commands() { + if [ -z "${TELNET_PORT+x}" ]; then + return 1 + fi + local cmds= if [ -n "${USERNAME}" -a -n "${PASSWORD}" ]; then - BASE="${BASE}${USERNAME}:${PASSWORD}@" + cmds="auth ${USERNAME} ${PASSWORD}\n" fi - BASE="${BASE}${SERVER}:${PORT}" + cmds="$cmds\nansi false\n" + while [ $# -gt 0 ]; do + cmds="$cmds$1\n" + shift + done + printf "$cmds\nexit\n" | nc -w "${MLDONKEY_TIMEOUT}" localhost "${TELNET_PORT}" 2> /dev/null + return $? +} + +send_http_commands() { + if [ -z "${PORT+x}" ]; then + return 1 + fi + local base="http://" + if [ -n "${USERNAME}" -a -n "${PASSWORD}" ]; then + base="${base}${USERNAME}:${PASSWORD}@" + fi + base="${base}${SERVER}:${PORT}" + local retval=0 + while [ $retval -eq 0 -a $# -gt 0 ]; do + wget -q -O /dev/stdout --timeout="${MLDONKEY_TIMEOUT}" "${base}/submit?q=${1// /+}" 2> /dev/null + retval=$? + shift + done + return $retval +} + +send_commands() { + send_telnet_commands "$@" &> /dev/null || send_http_commands "$@" &> /dev/null + return $? } stop() { ebegin "Stopping ${SVCNAME} -- please wait" - setup_uri - wget --spider --timeout="${MLDONKEY_TIMEOUT}" "${BASE}"/submit?q=close_fds -q - wget --spider --timeout="${MLDONKEY_TIMEOUT}" "${BASE}"/submit?q=save -q - wget --spider --timeout="${MLDONKEY_TIMEOUT}" "${BASE}"/submit?q=kill -q + send_commands close_fds save kill # give it a chance to die: local timeout=${MLDONKEY_TIMEOUT} while [ $timeout -gt 0 ]; do - if ! start-stop-daemon --test --quiet --stop \ + if ! start-stop-daemon --test --quiet --quiet --stop \ --exec "${MLDONKEY_BINARY}" \ --pidfile /var/run/"${SVCNAME}".pid ; then eend 0 @@ -87,32 +116,23 @@ reload() { slow() { ebegin "Reducing bandwidth to ${LOW_DOWN}k/${LOW_UP}k" - setup_uri - wget --spider --timeout="${MLDONKEY_TIMEOUT}" \ - "${BASE}/submit?q=set+max_hard_download_rate+${LOW_DOWN}" -q - wget --spider --timeout=${MLDONKEY_TIMEOUT} \ - "${BASE}/submit?q=set+max_hard_upload_rate+${LOW_UP}" -q + send_commands "set max_hard_download_rate ${LOW_DOWN}" "set max_hard_upload_rate ${LOW_UP}" eend $? } fast() { ebegin "Increasing bandwidth to ${HIGH_DOWN}k/${HIGH_UP}k" - - setup_uri - wget --spider --timeout="${MLDONKEY_TIMEOUT}" \ - "${BASE}/submit?q=set+max_hard_upload_rate+${HIGH_UP}" -q - wget --spider --timeout="${MLDONKEY_TIMEOUT}" \ - "${BASE}/submit?q=set+max_hard_download_rate+${HIGH_DOWN}" -q + send_commands "set max_hard_upload_rate ${HIGH_UP}" "set max_hard_download_rate ${HIGH_DOWN}" eend $? } info() { - setup_uri - local result=$(wget --timeout="${MLDONKEY_TIMEOUT}" \ - -O - "${BASE}"/submit?q=vo 2>/dev/null | \ - grep -C1 max_hard_upload | \ - grep value=\" | cut -d\" -f2) + set -o pipefail + local result=$( + send_telnet_commands "voo max_hard_upload_rate" | grep -a 'max_hard_upload_rate.* =' | cut -d \ -f 3 || + send_http_commands "voo max_hard_upload_rate" | fgrep name=value | sed -e 's/.*value="//' -e 's/".*//' + ) if [ "${result}" = "${LOW_UP}" ]; then einfo "${SVCNAME} runs slow" else diff --git a/net-p2p/mldonkey/mldonkey-3.1.7.ebuild b/net-p2p/mldonkey/mldonkey-3.1.7-r1.ebuild index 07ce1065498f..0eaeac9e7461 100644 --- a/net-p2p/mldonkey/mldonkey-3.1.7.ebuild +++ b/net-p2p/mldonkey/mldonkey-3.1.7-r1.ebuild @@ -19,6 +19,7 @@ REQUIRED_USE="guionly? ( gtk )" RDEPEND="dev-lang/perl dev-ml/camlp4:= + net-analyzer/netcat gd? ( media-libs/gd[truetype] ) gtk? ( gnome-base/librsvg @@ -137,7 +138,7 @@ src_install() { done use bittorrent && newbin "make_torrent${myext}" make_torrent - newconfd "${FILESDIR}/mldonkey.confd-2.8" mldonkey + newconfd "${FILESDIR}/mldonkey.confd" mldonkey fperms 600 /etc/conf.d/mldonkey newinitd "${FILESDIR}/mldonkey.initd" mldonkey fi |