Friday, November 02, 2007

aMule restart script

Accidentally discovered that some people still use my old aMule watchdog script. The script can be downloaded here. It is quite trivial - it simply checks from time to time that somebody is still listening on the aMule port. Since aMule tends to crash and freeze quite often (at least used to when I was using it) it is rather handy.

The script:

#!/bin/sh

# aMule watchdog
# Checks on aMule every 5 (configurable parameter) minutes
# and restarts it if aMule does not respond.
# Requires Netcat
#
# Created by Demiurg - sasha.sirotkin [AT] gmail.com
# Have fun.

MULENAME=amule
MULE=`which ${MULENAME}`
NC=`which nc`

TCPPORT=4642
SLEEP=300

test -e ${MULE} || (echo "${MULE} not found. Dying" ; exit 1)
test -e ${NC} || (echo "Netcat not found. Dying" ; exit 1)

FIRSTLOOP=1

rm ~/.aMule/muleLock

while true; do
# echo "Waiting"
test ${FIRSTLOOP} || sleep ${SLEEP}
unset FIRSTLOOP
# echo "Checking"
nc localhost ${TCPPORT} < /dev/null && continue
echo "Restarting"
date
killall -9 ${MULENAME}
sleep 1
${MULE} &
# echo "Running"
done

Labels: , , ,

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home