summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesus P Rey (Chuso) <gentoo@chuso.net>2021-11-01 19:40:55 +0100
committerJoonas Niilola <juippis@gentoo.org>2022-02-28 09:25:56 +0200
commit4d5ed7c028714d20734af683d45755a095840ec0 (patch)
tree2b96c215aec5a9c1c7d46fe5695c1ca7e866c06b /net-p2p
parentdev-db/sqliteman: EAPI-8 bump, switch to cmake.eclass, xdg.eclass (diff)
downloadgentoo-4d5ed7c028714d20734af683d45755a095840ec0.tar.gz
gentoo-4d5ed7c028714d20734af683d45755a095840ec0.tar.bz2
gentoo-4d5ed7c028714d20734af683d45755a095840ec0.zip
net-p2p/mldonkey: rework init.d/service files
Add systemd service unit and remove obsolete settings from the OpenRC script. Signed-off-by: Jesus P Rey <gentoo@chuso.net> Closes: https://bugs.gentoo.org/480050 Closes: https://github.com/gentoo/gentoo/pull/22851 Signed-off-by: Joonas Niilola <juippis@gentoo.org>
Diffstat (limited to 'net-p2p')
-rw-r--r--net-p2p/mldonkey/files/mldonkey.confd22
-rw-r--r--net-p2p/mldonkey/files/mldonkey.initd112
-rw-r--r--net-p2p/mldonkey/files/mldonkey.service14
-rw-r--r--net-p2p/mldonkey/mldonkey-3.1.7-r3.ebuild (renamed from net-p2p/mldonkey/mldonkey-3.1.7-r2.ebuild)25
4 files changed, 33 insertions, 140 deletions
diff --git a/net-p2p/mldonkey/files/mldonkey.confd b/net-p2p/mldonkey/files/mldonkey.confd
index 7cdb2b7134ed..509409b02232 100644
--- a/net-p2p/mldonkey/files/mldonkey.confd
+++ b/net-p2p/mldonkey/files/mldonkey.confd
@@ -9,7 +9,7 @@
USER="p2p"
# mldonkey's working dir (must be existing)
-MLDONKEY_DIR="/home/p2p/mldonkey"
+MLDONKEY_DIR="/var/lib/mldonkey"
# logfile (/dev/null for nowhere)
LOG="/var/log/mldonkey.log"
@@ -18,25 +18,5 @@ LOG="/var/log/mldonkey.log"
# set log_to_syslog true
USE_LOGGER=false
-# bandwidth control, values in kb/s
-LOW_DOWN="6"
-LOW_UP="2"
-HIGH_DOWN="30"
-HIGH_UP="10"
-
# nice level, 0<x<19, more nice -> less cpuspeed consumed
NICE="19"
-
-# mldonkey server ip, usually localhost
-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"
-#PASSWORD=""
diff --git a/net-p2p/mldonkey/files/mldonkey.initd b/net-p2p/mldonkey/files/mldonkey.initd
index b7e561372392..c7fa3d5051c5 100644
--- a/net-p2p/mldonkey/files/mldonkey.initd
+++ b/net-p2p/mldonkey/files/mldonkey.initd
@@ -3,7 +3,6 @@
extra_started_commands="reload slow fast info"
MLDONKEY_BINARY=${MLDONKEY_BINARY:-/usr/bin/mlnet}
-MLDONKEY_TIMEOUT=${TIMEOUT:-10}
depend() {
need localmount net
@@ -11,13 +10,16 @@ depend() {
}
start() {
+ if [ -n "${BASEDIR}${SUBDIR}${LOW_DOWN}${LOW_UP}${HIGH_DOWN}${HIGH_UP}${SERVER}${PORT}${TELNET_PORT}${USERNAME}${PASSWORD}${MLDONKEY_TIMEOUT}" ]; then
+ ewarn "The following settings are deprecated and will be ignored,"
+ ewarn "please remove them from /etc/conf.d/mldonkey:"
+ ewarn "LOW_DOWN LOW_UP HIGH_DOWN HIGH_UP SERVER PORT TELNET_PORT USERNAME PASSWORD MLDONKEY_TIMEOUT"
+ fi
+
if [ -z "${MLDONKEY_DIR}" ]; then
- ewarn "mldonkey's start script has been changed. You should remove"
- ewarn "BASEDIR and SUBDIR from /etc/conf.d/mldonkey and set MLDONKEY_DIR"
- ewarn "to the correct value (you probably want"
- ewarn "MLDONKEY_DIR=${BASEDIR}/${SUBDIR})"
- MLDONKEY_DIR="${BASEDIR}/${SUBDIR}"
- einfo "Using ${MLDONKEY_DIR} as working directory"
+ eerror "Please set MLDONKEY_DIR in /etc/conf.d/mldonkey to the directory"
+ eerror "where you want MLDonkey to save its files"
+ return 1
fi
if [ ! -d "${MLDONKEY_DIR}" ]; then
@@ -27,115 +29,21 @@ start() {
fi
ebegin "Starting ${SVCNAME}"
- cd "${MLDONKEY_DIR}"
- export MLDONKEY_DIR
start-stop-daemon --start --user "${USER}" --nice "${NICE}" \
--exec "${MLDONKEY_BINARY}" --pidfile /var/run/"${SVCNAME}".pid \
- --background --make-pidfile
+ --env "MLDONKEY_DIR=${MLDONKEY_DIR}" --background --make-pidfile
eend $?
}
-send_telnet_commands() {
- if [ -z "${TELNET_PORT+x}" ]; then
- return 1
- fi
- local cmds=
- if [ -n "${USERNAME}" -a -n "${PASSWORD}" ]; then
- cmds="auth ${USERNAME} ${PASSWORD}\n"
- fi
- 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"
-
- 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 --quiet --stop \
- --exec "${MLDONKEY_BINARY}" \
- --pidfile /var/run/"${SVCNAME}".pid ; then
- eend 0
- return 0
- fi
- sleep 1
- timeout=$((${timeout} - 1))
- done
-
- eend 1 "Failed to cleanly stop ${SVCNAME}"
- ebegin "Forcing ${SVCNAME} to stop"
start-stop-daemon --stop --exec "${MLDONKEY_BINARY}" \
--pidfile /var/run/"${SVCNAME}".pid
eend $?
}
-# This doesn't work for baselayout-2
-restart() {
- svc_stop
- sleep 5
- svc_start
-}
-
reload() {
ebegin "Reloading ${SVCNAME}"
start-stop-daemon --stop --signal HUP --oknodo \
--exec "${MLDONKEY_BINARY}" --pidfile /var/run/"${SVCNAME}".pid
eend $?
}
-
-slow() {
- ebegin "Reducing bandwidth to ${LOW_DOWN}k/${LOW_UP}k"
- 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"
- send_commands "set max_hard_upload_rate ${HIGH_UP}" "set max_hard_download_rate ${HIGH_DOWN}"
- eend $?
-}
-
-
-info() {
- 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
- einfo "${SVCNAME} runs fast"
- fi
-}
diff --git a/net-p2p/mldonkey/files/mldonkey.service b/net-p2p/mldonkey/files/mldonkey.service
new file mode 100644
index 000000000000..4cc0b7fc945b
--- /dev/null
+++ b/net-p2p/mldonkey/files/mldonkey.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=MLDonkey multi-network P2P client service
+After=network.target
+
+[Service]
+User=p2p
+LimitNICE=+19
+Environment=MLDONKEY_DIR=/var/lib/mldonkey
+ExecStart=/usr/bin/mlnet
+ExecReload=/bin/kill -HUP $MAINPID
+KillMode=process
+
+[Install]
+WantedBy=multi-user.target
diff --git a/net-p2p/mldonkey/mldonkey-3.1.7-r2.ebuild b/net-p2p/mldonkey/mldonkey-3.1.7-r3.ebuild
index c1bb19df5b69..af7d2cea2000 100644
--- a/net-p2p/mldonkey/mldonkey-3.1.7-r2.ebuild
+++ b/net-p2p/mldonkey/mldonkey-3.1.7-r3.ebuild
@@ -3,7 +3,7 @@
EAPI="7"
-inherit autotools desktop flag-o-matic toolchain-funcs
+inherit autotools desktop flag-o-matic systemd toolchain-funcs
DESCRIPTION="Multi-network P2P application written in Ocaml, with Gtk, web & telnet interface"
HOMEPAGE="http://mldonkey.sourceforge.net/ https://github.com/ygrek/mldonkey"
@@ -17,7 +17,7 @@ IUSE="bittorrent doc fasttrack gd gnutella gtk guionly magic +ocamlopt upnp"
REQUIRED_USE="guionly? ( gtk )"
-COMMON_DEPEND="dev-lang/perl
+RDEPEND="dev-lang/perl
dev-ml/camlp4:=
gd? ( media-libs/gd[truetype] )
gtk? (
@@ -35,12 +35,10 @@ COMMON_DEPEND="dev-lang/perl
)
!guionly? ( acct-user/p2p )
"
-RDEPEND="${COMMON_DEPEND}
- || ( net-analyzer/netcat net-analyzer/openbsd-netcat )"
# Can't yet use newer OCaml
# -unsafe-string usage:
# https://github.com/ygrek/mldonkey/issues/46
-DEPEND="${COMMON_DEPEND}
+DEPEND="${RDEPEND}
<dev-lang/ocaml-4.10:=[ocamlopt?]
bittorrent? (
|| (
@@ -141,8 +139,8 @@ src_install() {
done
use bittorrent && newbin "make_torrent${myext}" make_torrent
+ systemd_dounit "${FILESDIR}/${PN}.service"
newconfd "${FILESDIR}/mldonkey.confd" mldonkey
- fperms 600 /etc/conf.d/mldonkey
newinitd "${FILESDIR}/mldonkey.initd" mldonkey
fi
@@ -171,16 +169,9 @@ src_install() {
}
pkg_postinst() {
- if ! use guionly; then
- echo
- einfo "If you want to start MLDonkey as a system service, use"
- einfo "the /etc/init.d/mldonkey script. To control bandwidth, use"
- einfo "the 'slow' and 'fast' arguments. Be sure to have a look at"
- einfo "/etc/conf.d/mldonkey also."
- echo
- else
- echo
- einfo "Simply run mlgui to start the chosen MLDonkey gui."
- einfo "It puts its config files into ~/.mldonkey"
+ if [ -f /etc/conf.d/mldonkey ] && grep -qE "^(BASEDIR|SUBDIR|LOW_DOWN|LOW_UP|HIGH_DOWN|HIGH_UP|SERVER|PORT|TELNET_PORT|USERNAME|PASSWORD|MLDONKEY_TIMEOUT)=" /etc/conf.d/mldonkey; then
+ ewarn "The following settings are deprecated and will be ignored,"
+ ewarn "please remove them from /etc/conf.d/mldonkey:"
+ ewarn "LOW_DOWN LOW_UP HIGH_DOWN HIGH_UP SERVER PORT TELNET_PORT USERNAME PASSWORD MLDONKEY_TIMEOUT"
fi
}