PDA

View Full Version : MLDonkey automated CVS guide



sardaukar_siet
8th March 2007, 07:02 PM
I use Fedora Core 6 and I think MLDonkey rocks. But I wasn't satisfied with the Livna rpm, it's stuck at 2.7.6 and the other RPM I had (ATRpms) didn't start the daemon correctly. So, I though : what if I install the working Livna RPM and then just replace the binary with a CVS version? It worked, so I automated it. You might find it useful.

There's two parts to this solution : a cron job and a modification to the /etc/init.d/mldonkey file - this modification is done to replace the mlnet binary with the latest version upon startup of the service, since it can't be replaced while running.

Since it's supposed to run as root, it creates a mldonkey sub-directory under /root.

The cron job :


#!/bin/bash

# Automated MLDonkey build script - sardaukar.siet@gmail.com

MESSAGE="step incomplete"

echo $MESSAGE > /tmp/cvs-update.log
echo $MESSAGE > /tmp/configure.log
echo $MESSAGE > /tmp/make.log

START='build started '`date +"%m-%d-%Y %T"`

if [ -e /root/mldonkey/mlnet ]; then
rm /root/mldonkey/mlnet
fi

cd /root
cvs -z9 -d:pserver:anonymous@cvs.sv.gnu.org:/sources/mldonkey co -P mldonkey &> /tmp/cvs-update.log && cd mldonkey && ./configure &> /tmp/configure.log && make &> /tmp/make.log

END='build ended '`date +"%m-%d-%Y %T"`

EMAIL="YOUR EMAIL HERE"

if [ -e /root/mldonkey/mlnet ]; then
{
SUM=`md5sum /root/mldonkey/mlnet | cut -d " " -f1`;
echo "$START

$END" | mutt -s "mldonkey build successful [$SUM]" $EMAIL -a /tmp/cvs-update.log -a /tmp/configure.log -a /tmp/make.log ;
}
else
echo "$START

$END" | mutt -s "mldonkey build failed" $EMAIL -a /tmp/cvs-update.log -a /tmp/configure.log -a /tmp/make.log
fi

rm /tmp/cvs-update.log
rm /tmp/configure.log
rm /tmp/make.log


The /etc/init.d/mldonkey file after being modified :


#!/bin/bash
#
# Startup script for Mldonkey
#
# Laurent Culioli <laurent@pschit.net>
#
# chkconfig: - 90 15
# description: Mldonkey is client to access multiple peer-to-peer network
# processname: mldonkey
# config: /etc/sysconfig/mldonkey

# Source function library.
. /etc/rc.d/init.d/functions

# Source some options
. /etc/sysconfig/mldonkey

[ -z $LOGFILE ] && LOGFILE="/dev/null"

RETVAL=0

# Path to the mldonkey binarie.
fullpath=/usr/libexec/mldonkey/mlnet

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0

prog=mldonkey

start() {
echo -n $"Starting $prog: "
cd $DIRECTORY
# MODIFICATION STARTS HERE
if [ -e /root/mldonkey/mlnet ]; then
cp /root/mldonkey/mlnet /usr/libexec/mldonkey/ && echo " CVS version installed!"
fi
# MODIFICATION ENDS HERE
daemon --user mldonkey --check mldonkey $NICE "$fullpath > $LOGFILE 2>&1 &"
RETVAL=$?
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/mldonkey
echo
}
stop() {
echo -n $"Stopping $prog: "
killproc $fullpath
rm -fr /var/lock/subsys/mldonkey
echo
}


# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
stop
start
;;
condrestart)
if status mlnet >/dev/null; then
stop
start
else
echo $"$prog is stopped"
fi
;;
status)
status mlnet
;;
*)
echo -ne "Usage: $0 {start|stop|restart|reload|condrestart|status}\n"
RETVAL=1
esac
exit $RETVAL


In Fedora Core, you just have to place the cronjob in a file, call it build-mlnet.sh for example, chmod +x it and copy it to /etc/cron.weekly to run every week. For the truly bleeding edge, make it daily.

I'm happy with the default configure flags, so I don't change them, but you can add flags on the ./configure call on the cronjob. The cronjob also mails you logs of the CVS, configure and make stages separately.

Hope you find it useful.