1 |
commit: 4d5ed7c028714d20734af683d45755a095840ec0 |
2 |
Author: Jesus P Rey (Chuso) <gentoo <AT> chuso <DOT> net> |
3 |
AuthorDate: Mon Nov 1 18:40:55 2021 +0000 |
4 |
Commit: Joonas Niilola <juippis <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Feb 28 07:25:56 2022 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=4d5ed7c0 |
7 |
|
8 |
net-p2p/mldonkey: rework init.d/service files |
9 |
|
10 |
Add systemd service unit and remove obsolete settings from the OpenRC |
11 |
script. |
12 |
|
13 |
Signed-off-by: Jesus P Rey <gentoo <AT> chuso.net> |
14 |
Closes: https://bugs.gentoo.org/480050 |
15 |
Closes: https://github.com/gentoo/gentoo/pull/22851 |
16 |
Signed-off-by: Joonas Niilola <juippis <AT> gentoo.org> |
17 |
|
18 |
net-p2p/mldonkey/files/mldonkey.confd | 22 +--- |
19 |
net-p2p/mldonkey/files/mldonkey.initd | 112 ++------------------- |
20 |
net-p2p/mldonkey/files/mldonkey.service | 14 +++ |
21 |
...ey-3.1.7-r2.ebuild => mldonkey-3.1.7-r3.ebuild} | 25 ++--- |
22 |
4 files changed, 33 insertions(+), 140 deletions(-) |
23 |
|
24 |
diff --git a/net-p2p/mldonkey/files/mldonkey.confd b/net-p2p/mldonkey/files/mldonkey.confd |
25 |
index 7cdb2b7134ed..509409b02232 100644 |
26 |
--- a/net-p2p/mldonkey/files/mldonkey.confd |
27 |
+++ b/net-p2p/mldonkey/files/mldonkey.confd |
28 |
@@ -9,7 +9,7 @@ |
29 |
USER="p2p" |
30 |
|
31 |
# mldonkey's working dir (must be existing) |
32 |
-MLDONKEY_DIR="/home/p2p/mldonkey" |
33 |
+MLDONKEY_DIR="/var/lib/mldonkey" |
34 |
|
35 |
# logfile (/dev/null for nowhere) |
36 |
LOG="/var/log/mldonkey.log" |
37 |
@@ -18,25 +18,5 @@ LOG="/var/log/mldonkey.log" |
38 |
# set log_to_syslog true |
39 |
USE_LOGGER=false |
40 |
|
41 |
-# bandwidth control, values in kb/s |
42 |
-LOW_DOWN="6" |
43 |
-LOW_UP="2" |
44 |
-HIGH_DOWN="30" |
45 |
-HIGH_UP="10" |
46 |
- |
47 |
# nice level, 0<x<19, more nice -> less cpuspeed consumed |
48 |
NICE="19" |
49 |
- |
50 |
-# mldonkey server ip, usually localhost |
51 |
-SERVER="localhost" |
52 |
- |
53 |
-# port for webinterface, usually 4080 |
54 |
-PORT="4080" |
55 |
- |
56 |
-# port for telnet interface, usually 4000 |
57 |
-TELNET_PORT="4000" |
58 |
- |
59 |
-# to enable password restricted access, |
60 |
-# uncomment and set BOTH following vars: |
61 |
-#USERNAME="admin" |
62 |
-#PASSWORD="" |
63 |
|
64 |
diff --git a/net-p2p/mldonkey/files/mldonkey.initd b/net-p2p/mldonkey/files/mldonkey.initd |
65 |
index b7e561372392..c7fa3d5051c5 100644 |
66 |
--- a/net-p2p/mldonkey/files/mldonkey.initd |
67 |
+++ b/net-p2p/mldonkey/files/mldonkey.initd |
68 |
@@ -3,7 +3,6 @@ |
69 |
extra_started_commands="reload slow fast info" |
70 |
|
71 |
MLDONKEY_BINARY=${MLDONKEY_BINARY:-/usr/bin/mlnet} |
72 |
-MLDONKEY_TIMEOUT=${TIMEOUT:-10} |
73 |
|
74 |
depend() { |
75 |
need localmount net |
76 |
@@ -11,13 +10,16 @@ depend() { |
77 |
} |
78 |
|
79 |
start() { |
80 |
+ if [ -n "${BASEDIR}${SUBDIR}${LOW_DOWN}${LOW_UP}${HIGH_DOWN}${HIGH_UP}${SERVER}${PORT}${TELNET_PORT}${USERNAME}${PASSWORD}${MLDONKEY_TIMEOUT}" ]; then |
81 |
+ ewarn "The following settings are deprecated and will be ignored," |
82 |
+ ewarn "please remove them from /etc/conf.d/mldonkey:" |
83 |
+ ewarn "LOW_DOWN LOW_UP HIGH_DOWN HIGH_UP SERVER PORT TELNET_PORT USERNAME PASSWORD MLDONKEY_TIMEOUT" |
84 |
+ fi |
85 |
+ |
86 |
if [ -z "${MLDONKEY_DIR}" ]; then |
87 |
- ewarn "mldonkey's start script has been changed. You should remove" |
88 |
- ewarn "BASEDIR and SUBDIR from /etc/conf.d/mldonkey and set MLDONKEY_DIR" |
89 |
- ewarn "to the correct value (you probably want" |
90 |
- ewarn "MLDONKEY_DIR=${BASEDIR}/${SUBDIR})" |
91 |
- MLDONKEY_DIR="${BASEDIR}/${SUBDIR}" |
92 |
- einfo "Using ${MLDONKEY_DIR} as working directory" |
93 |
+ eerror "Please set MLDONKEY_DIR in /etc/conf.d/mldonkey to the directory" |
94 |
+ eerror "where you want MLDonkey to save its files" |
95 |
+ return 1 |
96 |
fi |
97 |
|
98 |
if [ ! -d "${MLDONKEY_DIR}" ]; then |
99 |
@@ -27,115 +29,21 @@ start() { |
100 |
fi |
101 |
|
102 |
ebegin "Starting ${SVCNAME}" |
103 |
- cd "${MLDONKEY_DIR}" |
104 |
- export MLDONKEY_DIR |
105 |
start-stop-daemon --start --user "${USER}" --nice "${NICE}" \ |
106 |
--exec "${MLDONKEY_BINARY}" --pidfile /var/run/"${SVCNAME}".pid \ |
107 |
- --background --make-pidfile |
108 |
+ --env "MLDONKEY_DIR=${MLDONKEY_DIR}" --background --make-pidfile |
109 |
eend $? |
110 |
} |
111 |
|
112 |
-send_telnet_commands() { |
113 |
- if [ -z "${TELNET_PORT+x}" ]; then |
114 |
- return 1 |
115 |
- fi |
116 |
- local cmds= |
117 |
- if [ -n "${USERNAME}" -a -n "${PASSWORD}" ]; then |
118 |
- cmds="auth ${USERNAME} ${PASSWORD}\n" |
119 |
- fi |
120 |
- cmds="$cmds\nansi false\n" |
121 |
- while [ $# -gt 0 ]; do |
122 |
- cmds="$cmds$1\n" |
123 |
- shift |
124 |
- done |
125 |
- printf "$cmds\nexit\n" | nc -w "${MLDONKEY_TIMEOUT}" localhost "${TELNET_PORT}" 2> /dev/null |
126 |
- return $? |
127 |
-} |
128 |
- |
129 |
-send_http_commands() { |
130 |
- if [ -z "${PORT+x}" ]; then |
131 |
- return 1 |
132 |
- fi |
133 |
- local base="http://" |
134 |
- if [ -n "${USERNAME}" -a -n "${PASSWORD}" ]; then |
135 |
- base="${base}${USERNAME}:${PASSWORD}@" |
136 |
- fi |
137 |
- base="${base}${SERVER}:${PORT}" |
138 |
- local retval=0 |
139 |
- while [ $retval -eq 0 -a $# -gt 0 ]; do |
140 |
- wget -q -O /dev/stdout --timeout="${MLDONKEY_TIMEOUT}" "${base}/submit?q=${1// /+}" 2> /dev/null |
141 |
- retval=$? |
142 |
- shift |
143 |
- done |
144 |
- return $retval |
145 |
-} |
146 |
- |
147 |
-send_commands() { |
148 |
- send_telnet_commands "$@" &> /dev/null || send_http_commands "$@" &> /dev/null |
149 |
- return $? |
150 |
-} |
151 |
- |
152 |
stop() { |
153 |
- ebegin "Stopping ${SVCNAME} -- please wait" |
154 |
- |
155 |
- send_commands close_fds save kill |
156 |
- |
157 |
- # give it a chance to die: |
158 |
- local timeout=${MLDONKEY_TIMEOUT} |
159 |
- while [ $timeout -gt 0 ]; do |
160 |
- if ! start-stop-daemon --test --quiet --quiet --stop \ |
161 |
- --exec "${MLDONKEY_BINARY}" \ |
162 |
- --pidfile /var/run/"${SVCNAME}".pid ; then |
163 |
- eend 0 |
164 |
- return 0 |
165 |
- fi |
166 |
- sleep 1 |
167 |
- timeout=$((${timeout} - 1)) |
168 |
- done |
169 |
- |
170 |
- eend 1 "Failed to cleanly stop ${SVCNAME}" |
171 |
- ebegin "Forcing ${SVCNAME} to stop" |
172 |
start-stop-daemon --stop --exec "${MLDONKEY_BINARY}" \ |
173 |
--pidfile /var/run/"${SVCNAME}".pid |
174 |
eend $? |
175 |
} |
176 |
|
177 |
-# This doesn't work for baselayout-2 |
178 |
-restart() { |
179 |
- svc_stop |
180 |
- sleep 5 |
181 |
- svc_start |
182 |
-} |
183 |
- |
184 |
reload() { |
185 |
ebegin "Reloading ${SVCNAME}" |
186 |
start-stop-daemon --stop --signal HUP --oknodo \ |
187 |
--exec "${MLDONKEY_BINARY}" --pidfile /var/run/"${SVCNAME}".pid |
188 |
eend $? |
189 |
} |
190 |
- |
191 |
-slow() { |
192 |
- ebegin "Reducing bandwidth to ${LOW_DOWN}k/${LOW_UP}k" |
193 |
- send_commands "set max_hard_download_rate ${LOW_DOWN}" "set max_hard_upload_rate ${LOW_UP}" |
194 |
- eend $? |
195 |
-} |
196 |
- |
197 |
-fast() { |
198 |
- ebegin "Increasing bandwidth to ${HIGH_DOWN}k/${HIGH_UP}k" |
199 |
- send_commands "set max_hard_upload_rate ${HIGH_UP}" "set max_hard_download_rate ${HIGH_DOWN}" |
200 |
- eend $? |
201 |
-} |
202 |
- |
203 |
- |
204 |
-info() { |
205 |
- set -o pipefail |
206 |
- local result=$( |
207 |
- send_telnet_commands "voo max_hard_upload_rate" | grep -a 'max_hard_upload_rate.* =' | cut -d \ -f 3 || |
208 |
- send_http_commands "voo max_hard_upload_rate" | fgrep name=value | sed -e 's/.*value="//' -e 's/".*//' |
209 |
- ) |
210 |
- if [ "${result}" = "${LOW_UP}" ]; then |
211 |
- einfo "${SVCNAME} runs slow" |
212 |
- else |
213 |
- einfo "${SVCNAME} runs fast" |
214 |
- fi |
215 |
-} |
216 |
|
217 |
diff --git a/net-p2p/mldonkey/files/mldonkey.service b/net-p2p/mldonkey/files/mldonkey.service |
218 |
new file mode 100644 |
219 |
index 000000000000..4cc0b7fc945b |
220 |
--- /dev/null |
221 |
+++ b/net-p2p/mldonkey/files/mldonkey.service |
222 |
@@ -0,0 +1,14 @@ |
223 |
+[Unit] |
224 |
+Description=MLDonkey multi-network P2P client service |
225 |
+After=network.target |
226 |
+ |
227 |
+[Service] |
228 |
+User=p2p |
229 |
+LimitNICE=+19 |
230 |
+Environment=MLDONKEY_DIR=/var/lib/mldonkey |
231 |
+ExecStart=/usr/bin/mlnet |
232 |
+ExecReload=/bin/kill -HUP $MAINPID |
233 |
+KillMode=process |
234 |
+ |
235 |
+[Install] |
236 |
+WantedBy=multi-user.target |
237 |
|
238 |
diff --git a/net-p2p/mldonkey/mldonkey-3.1.7-r2.ebuild b/net-p2p/mldonkey/mldonkey-3.1.7-r3.ebuild |
239 |
similarity index 86% |
240 |
rename from net-p2p/mldonkey/mldonkey-3.1.7-r2.ebuild |
241 |
rename to net-p2p/mldonkey/mldonkey-3.1.7-r3.ebuild |
242 |
index c1bb19df5b69..af7d2cea2000 100644 |
243 |
--- a/net-p2p/mldonkey/mldonkey-3.1.7-r2.ebuild |
244 |
+++ b/net-p2p/mldonkey/mldonkey-3.1.7-r3.ebuild |
245 |
@@ -3,7 +3,7 @@ |
246 |
|
247 |
EAPI="7" |
248 |
|
249 |
-inherit autotools desktop flag-o-matic toolchain-funcs |
250 |
+inherit autotools desktop flag-o-matic systemd toolchain-funcs |
251 |
|
252 |
DESCRIPTION="Multi-network P2P application written in Ocaml, with Gtk, web & telnet interface" |
253 |
HOMEPAGE="http://mldonkey.sourceforge.net/ https://github.com/ygrek/mldonkey" |
254 |
@@ -17,7 +17,7 @@ IUSE="bittorrent doc fasttrack gd gnutella gtk guionly magic +ocamlopt upnp" |
255 |
|
256 |
REQUIRED_USE="guionly? ( gtk )" |
257 |
|
258 |
-COMMON_DEPEND="dev-lang/perl |
259 |
+RDEPEND="dev-lang/perl |
260 |
dev-ml/camlp4:= |
261 |
gd? ( media-libs/gd[truetype] ) |
262 |
gtk? ( |
263 |
@@ -35,12 +35,10 @@ COMMON_DEPEND="dev-lang/perl |
264 |
) |
265 |
!guionly? ( acct-user/p2p ) |
266 |
" |
267 |
-RDEPEND="${COMMON_DEPEND} |
268 |
- || ( net-analyzer/netcat net-analyzer/openbsd-netcat )" |
269 |
# Can't yet use newer OCaml |
270 |
# -unsafe-string usage: |
271 |
# https://github.com/ygrek/mldonkey/issues/46 |
272 |
-DEPEND="${COMMON_DEPEND} |
273 |
+DEPEND="${RDEPEND} |
274 |
<dev-lang/ocaml-4.10:=[ocamlopt?] |
275 |
bittorrent? ( |
276 |
|| ( |
277 |
@@ -141,8 +139,8 @@ src_install() { |
278 |
done |
279 |
use bittorrent && newbin "make_torrent${myext}" make_torrent |
280 |
|
281 |
+ systemd_dounit "${FILESDIR}/${PN}.service" |
282 |
newconfd "${FILESDIR}/mldonkey.confd" mldonkey |
283 |
- fperms 600 /etc/conf.d/mldonkey |
284 |
newinitd "${FILESDIR}/mldonkey.initd" mldonkey |
285 |
fi |
286 |
|
287 |
@@ -171,16 +169,9 @@ src_install() { |
288 |
} |
289 |
|
290 |
pkg_postinst() { |
291 |
- if ! use guionly; then |
292 |
- echo |
293 |
- einfo "If you want to start MLDonkey as a system service, use" |
294 |
- einfo "the /etc/init.d/mldonkey script. To control bandwidth, use" |
295 |
- einfo "the 'slow' and 'fast' arguments. Be sure to have a look at" |
296 |
- einfo "/etc/conf.d/mldonkey also." |
297 |
- echo |
298 |
- else |
299 |
- echo |
300 |
- einfo "Simply run mlgui to start the chosen MLDonkey gui." |
301 |
- einfo "It puts its config files into ~/.mldonkey" |
302 |
+ 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 |
303 |
+ ewarn "The following settings are deprecated and will be ignored," |
304 |
+ ewarn "please remove them from /etc/conf.d/mldonkey:" |
305 |
+ ewarn "LOW_DOWN LOW_UP HIGH_DOWN HIGH_UP SERVER PORT TELNET_PORT USERNAME PASSWORD MLDONKEY_TIMEOUT" |
306 |
fi |
307 |
} |