Install the amule

From OpenFSG
Jump to: navigation, search


Installation

This is a satisfying experience beginning from the scratch:

  1. Use FSGA to install a clean root file system.
  2. Update firmware to version 3.1.29
  3. Download and install:
    http://ipkg.nslu2-linux.org/feeds/optware/fsg3/cross/stable/fsg3-bootstrap_1.0-5_armeb.xsh
  4. Install amule package as root with:
    ipkg install amule
  5. Create amule user
  6. Log as amule and execute /opt/bin/amuled (-f daemon, -o shows log for debugging)
  7. First time you execute amuled it generates a config file:
    /home/amule/.aMule/amule.conf
  8. Edit the file as described here:
    1. With an editor, edit the /home/amule/.aMule/amule.conf file, search for the line containing "AcceptExternalConnections", and change the 0 to 1.
      The ECPassword needs an MD5 hash of your password, which can be computed with a simple procedure. For example, if you want your password to be touche, you'd calculate the value for ECPassword like this:
      $ echo -n "yourpassword" | md5sum | awk '{print 1}'
       Return: 75dfa1c8b9f1b1d8e599f2ed98f1ecd0
      It is possible to follow the same sequence to complete the web passwords in amule.conf [web section].
  9. Download and substitute server.met (/home/amule/.aMule/server.met) from here:
    http://srv1000.com/azz/server.met (This is an example)
  10. Finally...
    1. As amule user:
      execute amuled -f
    2. Force creation of /home/amule/.aMule/remote.conf:
      execute amuleweb --create-config-from=/home/amule/.aMule/amule.conf
    3. Run the shell:
      execute amuleweb
    4. Or if you want with another shell:
      execute amulecmd.
    5. That's all! Enjoy your mule.


Annexes

ANNEX I

Simple solution to solve the Low ID problem

You can create this script as root and run it when you want to open amule ports.

#! /bin/sh
WAN_TYPE=$(grep wan_type  /etc/master.conf | cut -d= -f2)
if [ $WAN_TYPE = "pppoe" ]; then
   EXIF=ppp0
else
   EXIF=eth1
fi

iptables -I INPUT -i $EXIF -m state --state NEW,ESTABLISHED,RELATED -p tcp --dport 4662 -j ACCEPT
iptables -I INPUT -i $EXIF -m state --state NEW,ESTABLISHED,RELATED -p udp --dport 4665 -j ACCEPT
iptables -I INPUT -i $EXIF -m state --state NEW,ESTABLISHED,RELATED -p udp --dport 4672 -j ACCEPT


ANNEX II

Enhanced Amule Startup and Port Opening

This is a solution in order to solve Amule Start up problem and Port opening through crontab.

Modified /etc/init.d/croninit to generate two new entries in crontab table.

Caution! As you can see in crontab table, there are two task declaration one for root and one for amule (in my installation amule is the owner of amuled -f process)

    #! /bin/sh
    case "$1" in
        start)
            rm -f /etc/crontab
            INaddr=$(ifconfig eth0 2>/dev/null | grep inet | cut -d: -f2)
            if [ "$INaddr" != "" ]; then
              set $INaddr
              INaddr=$1
            fi
            for ADDR in $(grep "^vpn=1#" /etc/master.conf | cut -d# -f10); do
              if [ $ADDR ]; then
                echo "0,15,30,45 * * * * root /usr/bin/ping -c 1 -I $INaddr $ADDR" >> /etc/crontab
              fi
            done
            grep -q ^ntp_use=1 /etc/master.conf
            if [ $? = "0" ]; then
                    PERIOD=$(grep ^ntp_period=  /etc/master.conf | cut -d= -f2)
                    case "$PERIOD" in
                            1)  # every hour (x:00)
                            PERIOD="0 * * * * root /etc/init.d/ntpupdate"
                            ;;
                            2)  # every day (0:00)
                            PERIOD="0 0 * * * root /etc/init.d/ntpupdate"
                            ;;
                            3)  # every week (0:00 monday)
                            PERIOD="0 0 * * 1 root /etc/init.d/ntpupdate"
                            ;;
                    esac
                    echo "$PERIOD" >> /etc/crontab
            fi
            # only start if specified in configuration
            if [ -s /etc/crontab ]; then
              echo "Starting cron."
              /bin/cron &
            fi
            #RECENTLY ADDED LINES
            #amule cron open port'''
            echo "* * * * * amule /home/amule/.aMule/amulecron_create" >> /etc/crontab'''
            echo "* * * * * root /home/amule/.aMule/amulecron_ports" >> /etc/crontab'''
        ;;
        stop)
            echo "Shutting down cron."
            killall -9 cron
        ;;
        reconfig)
        ;;
        *)
            echo "Usage: $0 {start|stop|reconfig}"
            exit 1
    esac
    exit 0

Then I created as root this script /etc/init.d/amule:

    #! /bin/sh
    WAN_TYPE=$(grep wan_type  /etc/master.conf | cut -d= -f2)
    if [ $WAN_TYPE = "pppoe" ]; then
         EXIF=ppp0
    else
         EXIF=eth1
    fi
    /sbin/iptables -I INPUT -i $EXIF -m state --state NEW,ESTABLISHED,RELATED -p tcp --dport 4662 -j ACCEPT
    /sbin/iptables -I INPUT -i $EXIF -m state --state NEW,ESTABLISHED,RELATED -p udp --dport 4665 -j ACCEPT
    /sbin/iptables -I INPUT -i $EXIF -m state --state NEW,ESTABLISHED,RELATED -p udp --dport 4672 -j ACCEPT

Also I create two scripts:

1. As amule user: /home/amule/.aMule/amulecron_create

    #! /bin/sh
    PROG=$(/bin/ps|grep "amuled -f"|grep -v cron|cut -c 7-11|cut -d" " -f1|head -n 1)
    if [ "$PROG" != "amule" ] ;then
        echo Amule Created ...>>/home/amule/amule.log
        date>>/home/amule/amule.log
        echo "5">/home/amule/amule.hold
        echo Amule starting 5 ...>>/home/amule/amule.log
        killall -9 amulecmd
        killall -9 amuleweb
        /opt/bin/amuled -f
    else
       if [ -e /home/amule/amule.hold ] ;then
          TIME=$(cat /home/amule/amule.hold)
          case "$TIME" in
          5)
              echo "4">/home/amule/amule.hold
              echo Amule starting 4 ...>>/home/amule/amule.log
          ;;
          4)
              echo "3">/home/amule/amule.hold
              echo Amule starting 3 ...>>/home/amule/amule.log
          ;;
          3)
              echo "2">/home/amule/amule.hold
              echo Amule starting 2 ...>>/home/amule/amule.log
          ;;
          2)
              echo "1">/home/amule/amule.hold
              echo Amule starting 1 ...>>/home/amule/amule.log
          ;;
          1)
              rm -rf /home/amule/amule.hold
              echo Amule started ...>>/home/amule/amule.log
          ;;
          esac
       fi
    fi

2. As root user: /home/amule/.aMule/amulecron_ports

    #! /bin/sh
    PROG=$(/bin/ps|grep "amuled -f"|grep -v cron|cut -c 7-11|cut -d" " -f1|head -n 1)
    if [ ! -e /home/amule/amule.hold ] ;then
        if [ "$PROG" = "amule" ] ;then
            ID=$(/opt/bin/amulecmd -P [Your Password] -c status |grep ID|cut -d"]" -f2|cut -d" " -f3|sed "s/ //g")
            if  [ "$ID" = "LowID" ] ;then
                echo Low ID Detected ...>>/home/amule/amule.log
                date>>/home/amule/amule.log
                /opt/bin/amulecmd -P [Your Password] -c disconnect
                sleep 10
                /etc/init.d/amule
                sleep 10
                /opt/bin/amulecmd -P [Your Password] -c connect
            fi
        fi
    else
        echo Amuled hold, waiting ...>>/home/amule/amule.log
    fi

Explanation

With this system Cron have two tasks:

  1. Monitoring Amule Start up, Both after boot up and also after a crash.
  2. Port opening, also both after boot up and after some iptables uncotrolled modification, which will cause a LowId.

This system generates an amule.log file in /home/amule in order to know each time amuled is restarted or ports are reopened.

In my installation the user who runs amule know is amule, not root or admin. I tested this solution during a week and It seems to run OK.

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox