--- mldonkey.orig 2009-02-08 20:25:02.000000000 +0300 +++ mldonkey 2009-03-01 12:31:16.000000000 +0300 @@ -16,7 +16,11 @@ fi confdir=$(su $MLDUSER -s /bin/sh -c 'echo $HOME')/.mldonkey -pidfile=${confdir}/mlnet.pid + +if [ -z $PID ] ; then + PID=${confdir}/mlnet.pid +fi +piddir=$(dirname $PID) [ -f /tmp/mldonkey.log ] && rm -f /tmp/mldonkey.log @@ -25,17 +29,21 @@ stat_busy "Starting MLDonkey" [ ! -d $confdir ] && su $MLDUSER -s /bin/sh -c "mkdir -p $confdir" + if [ ! -d $piddir ] ; then + mkdir -p $piddir + chown $MLDUSER $piddir + fi - if [ -f $pidfile ] ; then + if [ -f $PID ] ; then stat_fail echo "Unable to run MLDonkey, it seems to be already running. If you're sure MLDonkey \ - is not running, you can remove ${pidfile}." + is not running, you can remove ${PID}." exit 2 elif [ -f ${confdir}/config_files_space.tmp ] ; then rm -f ${confdir}/config_files_space.tmp fi - su $MLDUSER -s /bin/sh -c "/usr/bin/mlnet &> /tmp/mldonkey.log &" + su $MLDUSER -s /bin/sh -c "/usr/bin/mlnet -pid $piddir $PARAMS &> /tmp/mldonkey.log &" i=0 while [ "$i" -lt 20 ] ; do @@ -59,8 +67,8 @@ stop) stat_busy "Stopping MLDonkey" - if [ -f $pidfile ] ; then - kill $( cat $pidfile ) &> /dev/null + if [ -f $PID ] ; then + kill $( cat $PID ) &> /dev/null else stat_fail echo "Unable to stop MLDonkey. It is not running." @@ -70,7 +78,7 @@ if [ $? -gt 0 ]; then stat_fail else - rm -f $pidfile + rm -f $PID rm_daemon mldonkey stat_done fi