summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Hood <squinky86@gentoo.org>2004-07-15 14:51:53 +0000
committerJon Hood <squinky86@gentoo.org>2004-07-15 14:51:53 +0000
commitdcce7a8f7b8bfcbba8fd50ea3339c37d2c4da28d (patch)
tree30d67ec0bbfafc8a722885398681feb8ee6ed259 /net-p2p/mldonkey
parentfix depend, the junit tests depend on a 1.4 jdk (Manifest recommit) (diff)
downloadgentoo-2-dcce7a8f7b8bfcbba8fd50ea3339c37d2c4da28d.tar.gz
gentoo-2-dcce7a8f7b8bfcbba8fd50ea3339c37d2c4da28d.tar.bz2
gentoo-2-dcce7a8f7b8bfcbba8fd50ea3339c37d2c4da28d.zip
more prettiful init script
Diffstat (limited to 'net-p2p/mldonkey')
-rw-r--r--net-p2p/mldonkey/ChangeLog6
-rw-r--r--net-p2p/mldonkey/files/mldonkey127
2 files changed, 121 insertions, 12 deletions
diff --git a/net-p2p/mldonkey/ChangeLog b/net-p2p/mldonkey/ChangeLog
index e9abcb6f98ca..ab5d8c635168 100644
--- a/net-p2p/mldonkey/ChangeLog
+++ b/net-p2p/mldonkey/ChangeLog
@@ -1,6 +1,10 @@
# ChangeLog for net-p2p/mldonkey
# Copyright 2002-2004 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/net-p2p/mldonkey/ChangeLog,v 1.52 2004/07/06 20:49:20 squinky86 Exp $
+# $Header: /var/cvsroot/gentoo-x86/net-p2p/mldonkey/ChangeLog,v 1.53 2004/07/15 14:51:53 squinky86 Exp $
+
+ 15 Jul 2004; Jon Hood <squinky86@gentoo.org> files/mldonkey:
+ fix mldonkey init script for more options; thanks to Matthias Bernges
+ <matthiasbernges@gmx.de> for the updates
*mldonkey-2.5.16-r7 (06 Jul 2004)
diff --git a/net-p2p/mldonkey/files/mldonkey b/net-p2p/mldonkey/files/mldonkey
index 6a407cd64679..84aa9b3db367 100644
--- a/net-p2p/mldonkey/files/mldonkey
+++ b/net-p2p/mldonkey/files/mldonkey
@@ -1,15 +1,120 @@
-#!/bin/sh
+#!/sbin/runscript
-. /etc/conf.d/mldonkey
+opts="start stop restart slow fast info"
-if [ ! -d ${HOME}/.mldonkey ] ; then
- echo "Creating subdirectory \".mldonkey\" in your home"
- echo "to store config files and downloaded files..."
-
- if ! mkdir ${HOME}/.mldonkey ; then
- echo "Creation of subdirectory failed! Exiting..."
- exit 1
+depend() {
+ need net
+}
+
+start() {
+ ebegin "Starting mldonkey"
+ if [ ! -d ${BASEDIR}/${SUBDIR} ]
+ then
+ einfo "Directory ${BASEDIR}/${SUBDIR} not existing, trying to create..."
+ su ${USER} -c "mkdir ${BASEDIR}/${SUBDIR}"
+ if [ ! -d ${BASEDIR}/${SUBDIR} ]
+ then
+ eerror "Directory ${BASEDIR}/${SUBDIR} could not be created!"
+ return 1
+ fi
+ einfo "...ok!"
+ fi
+ cd ${BASEDIR}/${SUBDIR}/
+ env HOME=${BASEDIR} start-stop-daemon --quiet --start -c ${USER} \
+ -x /usr/bin/mlnet &>${LOG} &
+ sleep 5
+ if ! pgrep -u ${USER} mlnet >/dev/null
+ then
+ eerror "MLDonkey could not be started! Check logfile: ${LOG}"
+ fi
+ renice ${NICE} -u ${USER} >/dev/null
+ eend $?
+}
+
+stop() {
+ BASE="http://"
+ if [[ -n ${USERNAME} && -n ${PASSWORD} ]]
+ then
+ BASE=${BASE}${USERNAME}:${PASSWORD}@
+ fi
+ BASE=${BASE}${SERVER}:${PORT}
+ ebegin "Stopping mldonkey - please wait"
+ wget --spider ${BASE}/submit?q=close_fds -q
+ wget --spider ${BASE}/submit?q=save -q
+ wget --spider ${BASE}/submit?q=kill -q
+ sleep 10
+ start-stop-daemon --oknodo --stop -x /usr/bin/mlnet &>/dev/null
+ eend $?
+}
+
+restart() {
+ svc_stop
+ sleep 5
+ svc_start
+}
+
+slow() {
+ if ! service_started mldonkey
+ then
+ start_service mldonkey
+ fi
+ ebegin "Reducing bandwidth to ${LOW_DOWN}k/${LOW_UP}k"
+
+ BASE="http://"
+ if [[ -n ${USERNAME} && -n ${PASSWORD} ]]
+ then
+ BASE=${BASE}${USERNAME}:${PASSWORD}@
+ fi
+ BASE=${BASE}${SERVER}:${PORT}
+
+ wget --spider ${BASE}/submit?q=set+max_hard_download_rate+${LOW_DOWN} -q
+
+ wget --spider ${BASE}/submit?q=set+max_hard_upload_rate+${LOW_UP} -q
+
+ eend $?
+}
+
+fast() {
+ if ! service_started mldonkey
+ then
+ start_service mldonkey
fi
-fi
+ ebegin "Increasing bandwidth to ${HIGH_DOWN}k/${HIGH_UP}k"
+
+ BASE="http://"
+ if [[ -n ${USERNAME} && -n ${PASSWORD} ]]
+ then
+ BASE=${BASE}${USERNAME}:${PASSWORD}@
+ fi
+ BASE=${BASE}${SERVER}:${PORT}
+
+ wget --spider ${BASE}/submit?q=set+max_hard_download_rate+${HIGH_DOWN} -q
-cd ${HOME}/.mldonkey && exec /usr/bin/mlnet
+ wget --spider ${BASE}/submit?q=set+max_hard_upload_rate+${HIGH_UP} -q
+
+ eend $?
+}
+
+
+info() {
+ if service_started mldonkey
+ then
+ BASE="http://"
+ if [[ -n ${USERNAME} && -n ${PASSWORD} ]]
+ then
+ BASE=${BASE}${USERNAME}:${PASSWORD}@
+ fi
+
+ BASE=${BASE}${SERVER}:${PORT}
+ VALUE=$(/usr/bin/wget -O - ${BASE}/submit?q=vo 2> /dev/null| /bin/grep -C1 max_hard_upload|/usr/bin/tail -n 1|/bin/cut -d\" -f2)
+ if [[ ${VALUE} -eq ${LOW_UP} ]]
+ then
+ INFO="mldonkey runs slow"
+ else
+ INFO="mldonkey runs fast"
+ fi
+ else
+ INFO="mldonkey is not running"
+ fi
+ einfo "$INFO"
+}