Tools

From AMule Project FAQ
Revision as of 13:57, 26 October 2010 by Shuttle (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Linux

Bash script to restart aMule whenever connection is lost

Sometimes aMule loses the connection and not reconnects automtically (it's could happen when aMule is running for many days). Here is the bash script for Linux, posted by telefono in the aMule-Forum, which checks if aMule has lost the connection and, if yes, restarts the aMule daemon.

The script simple checks if aMule is not downloading and if the total sources is less than 50. In order to use the script, you need to put it in /etc/cron.hourly/ and call it "amulereset".

sudo touch /etc/cron.hourly/amulereset

now set some permissions:

sudo chmod 755  /etc/cron.hourly/amulereset

and open it…

sudo gedit  /etc/cron.hourly/amulereset

then copy and paste the follow script:

#!/bin/bash

# some settings
host=localhost
port=4712
pass=YOUPASSWORD

# if the clients on quee is lees than the setted number, restart (if not downloading)
minClientOnQuee=50

#cheking the status
r=`amulecmd -h $host -p $port -P $pass -c status`

#retrieving info
download=`echo $r | grep -o 'Download: .* Up' | sed -e 's/Download: //' -e 's/ > Up//' | sed -e 's/Download: //' -e 's/ kB\/s//' | sed -e 's/Download: //' -e 's/ bytes\/sec//'`
upload=`echo $r | grep -o 'Upload: .* Cl' | sed -e 's/Upload: //' -e 's/ kB\/s > Cl//'`
ed2k=`echo $r | grep -o 'eD2k: .* Kad' | sed -e 's/eD2k: //' -e 's/ > Kad//'`
kad=`echo $r | grep -o 'Kad: .* Dow' | sed -e 's/Kad: //' -e 's/ > Dow//'`
clientsOnQuee=`echo $r | grep -o 'Clients in queue: .* > Tot' | sed -e 's/Clients in queue: //' -e 's/ > Tot//'`
totalSources=`echo $r | grep -o 'Total sources: .*' | sed -e 's/Total sources: //' -e 's/ //'`

#some echo's for debug
echo "Download : $download"
echo "Upload   : $upload"
echo "clientsOnQuee : $clientsOnQuee"
echo "totalSources : $totalSources"

# only if not downloading
if [ "$download" = 0 ]
then

    if [ "$clientsOnQuee" -lt "$minClientOnQuee" ]
    then
        /etc/init.d/amule-daemon restart
        exit
    fi

fi

exit

Custom menu with aMule tools

Here the bash scripts by Shuttle (Talk | contribs) which creates a GUI menu that asks you what action you want to do.

#!/bin/bash

ans=$(zenity --list --height=250 --width=250 --title="aMule" --text="What do you want?" --column="Action" "Start aMule" "Start the daemon only" "Stop the daemon" "Kill the daemon" "Remote controls")

if [ "$ans" = "Start aMule" ]
then
/usr/bin/amule

elif [ "$ans" = "Start the daemon only" ]
then
/usr/bin/amuled

elif [ "$ans" = "Stop the daemon" ]
then
/usr/bin/amulecmd -c shutdown

elif [ "$ans" = "Kill the daemon" ]
then
/usr/bin/pkill amuled

elif [ "$ans" = "Remote controls" ]
then
/usr/bin/amulegui
fi